Interface BossBar
public sealed interface BossBar
Represents an in-game bossbar which can be shown to the client.
A bossbar consists of:
- name
- the title of the bossbar
- progress
- a number in the range [0,1] representing how much of the bossbar should be filled
- color
- the
BossBar.Colorof the bossbar; platforms may downsample this for versions below Java Edition 1.9 - overlay
BossBar.Overlays decide if the bossbar is continuous or split into segments- flags(optional)
BossBar.Flags are extra actions that can be triggered whenever the bossbar is displayed
- Since:
- 4.0.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatThe maximum value the progress can be.static final floatThe minimum value the progress can be. -
Method Summary
Modifier and TypeMethodDescriptionaddFlag(BossBar.Flag flag) Adds a flag to this bossbar.addFlags(Iterable<BossBar.Flag> flags) Adds flags to this bossbar.addFlags(BossBar.Flag... flags) Adds flags to this bossbar.addListener(BossBar.Listener listener) Adds a listener.default BossBarShow this bossbar toviewer.static BossBarbossBar(ComponentLike name, float progress, BossBar.Color color, BossBar.Overlay overlay) Creates a new bossbar.static BossBarbossBar(ComponentLike name, float progress, BossBar.Color color, BossBar.Overlay overlay, Set<BossBar.Flag> flags) Creates a new bossbar.static BossBarbossBar(Component name, float progress, BossBar.Color color, BossBar.Overlay overlay) Creates a new bossbar.static BossBarbossBar(Component name, float progress, BossBar.Color color, BossBar.Overlay overlay, Set<BossBar.Flag> flags) Creates a new bossbar.color()Gets the color.color(BossBar.Color color) Sets the color.@UnmodifiableView Set<BossBar.Flag> flags()Gets the flags.flags(Set<BossBar.Flag> flags) Sets the flags.booleanhasFlag(BossBar.Flag flag) Checks if this bossbar has a flag.name()Gets the name.Sets the name.default BossBarname(ComponentLike name) Sets the name.overlay()Gets the overlay.overlay(BossBar.Overlay overlay) Sets the overlay.floatprogress()Gets the progress.progress(float progress) Sets the progress.removeFlag(BossBar.Flag flag) Removes a flag from this bossbar.removeFlags(Iterable<BossBar.Flag> flags) Removes flags from this bossbar.removeFlags(BossBar.Flag... flags) Removes flags from this bossbar.removeListener(BossBar.Listener listener) Removes a listener.default BossBarremoveViewer(Audience viewer) Hide this bossbar fromviewer.@UnmodifiableView Iterable<? extends BossBarViewer> viewers()Gets an unmodifiable view of the viewers of this bossbar.
-
Field Details
-
MIN_PROGRESS
static final float MIN_PROGRESSThe minimum value the progress can be.- Since:
- 4.2.0
- See Also:
-
MAX_PROGRESS
static final float MAX_PROGRESSThe maximum value the progress can be.- Since:
- 4.2.0
- See Also:
-
-
Method Details
-
bossBar
static BossBar bossBar(ComponentLike name, float progress, BossBar.Color color, BossBar.Overlay overlay) Creates a new bossbar.- Parameters:
name- the nameprogress- the progress, between 0 and 1color- the coloroverlay- the overlay- Returns:
- a bossbar
- Throws:
IllegalArgumentException- if progress is less than 0 or greater than 1- Since:
- 4.3.0
-
bossBar
static BossBar bossBar(Component name, float progress, BossBar.Color color, BossBar.Overlay overlay) Creates a new bossbar.- Parameters:
name- the nameprogress- the progress, between 0 and 1color- the coloroverlay- the overlay- Returns:
- a bossbar
- Throws:
IllegalArgumentException- if progress is less than 0 or greater than 1- Since:
- 4.0.0
-
bossBar
static BossBar bossBar(ComponentLike name, float progress, BossBar.Color color, BossBar.Overlay overlay, Set<BossBar.Flag> flags) Creates a new bossbar.- Parameters:
name- the nameprogress- the progress, between 0 and 1color- the coloroverlay- the overlayflags- the flags- Returns:
- a bossbar
- Throws:
IllegalArgumentException- if progress is less than 0 or greater than 1- Since:
- 4.3.0
-
bossBar
static BossBar bossBar(Component name, float progress, BossBar.Color color, BossBar.Overlay overlay, Set<BossBar.Flag> flags) Creates a new bossbar.- Parameters:
name- the nameprogress- the progress, between 0 and 1color- the coloroverlay- the overlayflags- the flags- Returns:
- a bossbar
- Throws:
IllegalArgumentException- if progress is less than 0 or greater than 1- Since:
- 4.0.0
-
name
-
name
Sets the name.- Parameters:
name- the name- Returns:
- the bossbar
- Since:
- 4.3.0
-
name
-
progress
float progress()Gets the progress.The progress is a value between 0 and 1.
- Returns:
- the progress
- Since:
- 4.0.0
-
progress
Sets the progress.The progress is a value between 0 and 1.
- Parameters:
progress- the progress- Returns:
- the bossbar
- Throws:
IllegalArgumentException- if progress is less than 0 or greater than 1- Since:
- 4.0.0
-
color
-
color
Sets the color.- Parameters:
color- the color- Returns:
- the bossbar
- Since:
- 4.0.0
-
overlay
-
overlay
Sets the overlay.- Parameters:
overlay- the overlay- Returns:
- the bossbar
- Since:
- 4.0.0
-
flags
-
flags
Sets the flags.- Parameters:
flags- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
hasFlag
Checks if this bossbar has a flag.- Parameters:
flag- the flag- Returns:
trueif this bossbar has the flag,falseotherwise- Since:
- 4.0.0
-
addFlag
Adds a flag to this bossbar.- Parameters:
flag- the flag- Returns:
- the bossbar
- Since:
- 4.0.0
-
removeFlag
Removes a flag from this bossbar.- Parameters:
flag- the flag- Returns:
- the bossbar
- Since:
- 4.0.0
-
addFlags
Adds flags to this bossbar.- Parameters:
flags- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
removeFlags
Removes flags from this bossbar.- Parameters:
flags- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
addFlags
Adds flags to this bossbar.- Parameters:
flags- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
removeFlags
Removes flags from this bossbar.- Parameters:
flags- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
addListener
Adds a listener.- Parameters:
listener- a listener- Returns:
- the bossbar
- Since:
- 4.0.0
-
removeListener
Removes a listener.- Parameters:
listener- a listener- Returns:
- the bossbar
- Since:
- 4.0.0
-
viewers
@UnmodifiableView Iterable<? extends BossBarViewer> viewers()Gets an unmodifiable view of the viewers of this bossbar.The returned value may be empty if this method is unsupported.
- Returns:
- an unmodifiable view of the viewers of this bossbar
- Since:
- 4.14.0
-
addViewer
-
removeViewer
-