Package net.kyori.adventure.bossbar
Interface BossBar
- All Superinterfaces:
net.kyori.examination.Examinable
@NonExtendable
public interface BossBar
extends net.kyori.examination.Examinable
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.Color
of the bossbar; platforms may downsample this for versions below Java Edition 1.9 - overlay
BossBar.Overlay
s decide if the bossbar is continuous or split into segments- flags(optional)
BossBar.Flag
s are extra actions that can be triggered whenever the bossbar is displayed
- Since:
- 4.0.0
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final float
Deprecated.static final float
The maximum value the progress can be.static final float
Deprecated.for removal since 4.2.0, useMIN_PROGRESS
static final float
The minimum value the progress can be. -
Method Summary
Modifier and TypeMethodDescription@NotNull BossBar
addFlag
(@NotNull BossBar.Flag flag) Adds a flag to this bossbar.@NotNull BossBar
addFlags
(@NotNull Iterable<BossBar.Flag> flags) Adds flags to this bossbar.@NotNull BossBar
addFlags
(@NotNull BossBar.Flag @NotNull ... flags) Adds flags to this bossbar.@NotNull BossBar
addListener
(@NotNull BossBar.Listener listener) Adds a listener.default @NotNull BossBar
Show this bossbar toviewer
.static @NotNull BossBar
bossBar
(@NotNull ComponentLike name, float progress, @NotNull BossBar.Color color, @NotNull BossBar.Overlay overlay) Creates a new bossbar.static @NotNull BossBar
bossBar
(@NotNull ComponentLike name, float progress, @NotNull BossBar.Color color, @NotNull BossBar.Overlay overlay, @NotNull Set<BossBar.Flag> flags) Creates a new bossbar.static @NotNull BossBar
bossBar
(@NotNull Component name, float progress, @NotNull BossBar.Color color, @NotNull BossBar.Overlay overlay) Creates a new bossbar.static @NotNull BossBar
bossBar
(@NotNull Component name, float progress, @NotNull BossBar.Color color, @NotNull BossBar.Overlay overlay, @NotNull Set<BossBar.Flag> flags) Creates a new bossbar.@NotNull BossBar.Color
color()
Gets the color.@NotNull BossBar
color
(@NotNull BossBar.Color color) Sets the color.@UnmodifiableView @NotNull Set<BossBar.Flag>
flags()
Gets the flags.@NotNull BossBar
flags
(@NotNull Set<BossBar.Flag> flags) Sets the flags.boolean
hasFlag
(@NotNull BossBar.Flag flag) Checks if this bossbar has a flag.@NotNull Component
name()
Gets the name.@NotNull BossBar
Sets the name.default @NotNull BossBar
name
(@NotNull ComponentLike name) Sets the name.@NotNull BossBar.Overlay
overlay()
Gets the overlay.@NotNull BossBar
overlay
(@NotNull BossBar.Overlay overlay) Sets the overlay.default float
percent()
Deprecated.for removal since 4.2.0, useprogress()
default @NotNull BossBar
percent
(float progress) Deprecated.for removal since 4.2.0, useprogress(float)
float
progress()
Gets the progress.@NotNull BossBar
progress
(float progress) Sets the progress.@NotNull BossBar
removeFlag
(@NotNull BossBar.Flag flag) Removes a flag from this bossbar.@NotNull BossBar
removeFlags
(@NotNull Iterable<BossBar.Flag> flags) Removes flags from this bossbar.@NotNull BossBar
removeFlags
(@NotNull BossBar.Flag @NotNull ... flags) Removes flags from this bossbar.@NotNull BossBar
removeListener
(@NotNull BossBar.Listener listener) Removes a listener.default @NotNull BossBar
removeViewer
(@NotNull Audience viewer) Hide this bossbar fromviewer
.@UnmodifiableView @NotNull Iterable<? extends BossBarViewer>
viewers()
Gets an unmodifiable view of the viewers of this bossbar.Methods inherited from interface net.kyori.examination.Examinable
examinableName, examinableProperties, examine
-
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:
-
MIN_PERCENT
Deprecated.for removal since 4.2.0, useMIN_PROGRESS
The minimum value the progress can be.- Since:
- 4.0.0
- See Also:
-
MAX_PERCENT
Deprecated.for removal since 4.2.0, useMAX_PROGRESS
The maximum value the progress can be.- Since:
- 4.0.0
- See Also:
-
-
Method Details
-
bossBar
@NotNull static @NotNull BossBar bossBar(@NotNull @NotNull ComponentLike name, float progress, @NotNull @NotNull BossBar.Color color, @NotNull @NotNull 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
@NotNull static @NotNull BossBar bossBar(@NotNull @NotNull Component name, float progress, @NotNull @NotNull BossBar.Color color, @NotNull @NotNull 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
@NotNull static @NotNull BossBar bossBar(@NotNull @NotNull ComponentLike name, float progress, @NotNull @NotNull BossBar.Color color, @NotNull @NotNull BossBar.Overlay overlay, @NotNull @NotNull 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
@NotNull static @NotNull BossBar bossBar(@NotNull @NotNull Component name, float progress, @NotNull @NotNull BossBar.Color color, @NotNull @NotNull BossBar.Overlay overlay, @NotNull @NotNull 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
Gets the name.- Returns:
- the name
- Since:
- 4.0.0
-
name
Sets the name.- Parameters:
name
- the name- Returns:
- the bossbar
- Since:
- 4.3.0
-
name
Sets the name.- Parameters:
name
- the name- Returns:
- the bossbar
- Since:
- 4.0.0
-
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
-
percent
Deprecated.for removal since 4.2.0, useprogress()
Gets the progress.The progress is a value between 0 and 1.
- Returns:
- the progress
- Since:
- 4.0.0
-
percent
@ScheduledForRemoval(inVersion="5.0.0") @Contract("_ -> this") @Deprecated @NotNull default @NotNull BossBar percent(float progress) Deprecated.for removal since 4.2.0, useprogress(float)
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
Gets the color.- Returns:
- the color
- Since:
- 4.0.0
-
color
Sets the color.- Parameters:
color
- the color- Returns:
- the bossbar
- Since:
- 4.0.0
-
overlay
Gets the overlay.- Returns:
- the overlay
- Since:
- 4.0.0
-
overlay
Sets the overlay.- Parameters:
overlay
- the overlay- Returns:
- the bossbar
- Since:
- 4.0.0
-
flags
Gets the flags.- Returns:
- the flags
- Since:
- 4.0.0
-
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:
true
if this bossbar has the flag,false
otherwise- 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
@Contract("_ -> this") @NotNull @NotNull BossBar addFlags(@NotNull @NotNull BossBar.Flag @NotNull ... flags) Adds flags to this bossbar.- Parameters:
flags
- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
removeFlags
@Contract("_ -> this") @NotNull @NotNull BossBar removeFlags(@NotNull @NotNull BossBar.Flag @NotNull ... flags) Removes flags from this bossbar.- Parameters:
flags
- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
addFlags
@Contract("_ -> this") @NotNull @NotNull BossBar addFlags(@NotNull @NotNull Iterable<BossBar.Flag> flags) Adds flags to this bossbar.- Parameters:
flags
- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
removeFlags
@Contract("_ -> this") @NotNull @NotNull BossBar removeFlags(@NotNull @NotNull Iterable<BossBar.Flag> flags) Removes flags from this bossbar.- Parameters:
flags
- the flags- Returns:
- the bossbar
- Since:
- 4.0.0
-
addListener
@Contract("_ -> this") @NotNull @NotNull BossBar addListener(@NotNull @NotNull BossBar.Listener listener) Adds a listener.- Parameters:
listener
- a listener- Returns:
- the bossbar
- Since:
- 4.0.0
-
removeListener
@Contract("_ -> this") @NotNull @NotNull BossBar removeListener(@NotNull @NotNull BossBar.Listener listener) Removes a listener.- Parameters:
listener
- a listener- Returns:
- the bossbar
- Since:
- 4.0.0
-
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
Show this bossbar toviewer
.- Parameters:
viewer
- the viewer- Returns:
- the bossbar
- Since:
- 4.14.0
- See Also:
-
removeViewer
Hide this bossbar fromviewer
.- Parameters:
viewer
- the viewer- Returns:
- the bossbar
- Since:
- 4.14.0
- See Also:
-
MAX_PROGRESS