diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index d7b88d6e44..2ace8c15ad 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -13,6 +13,10 @@ import java.util.UUID; import java.util.logging.Logger; import org.bukkit.Warning.WarningState; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BarFlag; +import org.bukkit.boss.BarStyle; +import org.bukkit.boss.BossBar; import org.bukkit.command.CommandException; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; @@ -1130,6 +1134,20 @@ public final class Bukkit { return server.createChunkData(world); } + /** + * Creates a boss bar instance to display to players. The progress + * defaults to 1.0 + * + * @param title the title of the boss bar + * @param color the color of the boss bar + * @param style the style of the boss bar + * @param flags an optional list of flags to set on the boss bar + * @return the created boss bar + */ + public static BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) { + return server.createBossBar(title, color, style, flags); + } + /** * @see UnsafeValues * @return the unsafe values instance diff --git a/paper-api/src/main/java/org/bukkit/boss/BarColor.java b/paper-api/src/main/java/org/bukkit/boss/BarColor.java new file mode 100644 index 0000000000..e191d9ffe8 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/boss/BarColor.java @@ -0,0 +1,11 @@ +package org.bukkit.boss; + +public enum BarColor { + PINK, + BLUE, + RED, + GREEN, + YELLOW, + PURPLE, + WHITE +} diff --git a/paper-api/src/main/java/org/bukkit/boss/BarFlag.java b/paper-api/src/main/java/org/bukkit/boss/BarFlag.java new file mode 100644 index 0000000000..69e02998d0 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/boss/BarFlag.java @@ -0,0 +1,17 @@ +package org.bukkit.boss; + +public enum BarFlag { + + /** + * Darkens the sky like during fighting a wither. + */ + DARKEN_SKY, + /** + * Tells the client to play the Ender Dragon boss music. + */ + PLAY_BOSS_MUSIC, + /** + * Creates fog around the world. + */ + CREATE_FOG, +} diff --git a/paper-api/src/main/java/org/bukkit/boss/BarStyle.java b/paper-api/src/main/java/org/bukkit/boss/BarStyle.java new file mode 100644 index 0000000000..3e499eb779 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/boss/BarStyle.java @@ -0,0 +1,24 @@ +package org.bukkit.boss; + +public enum BarStyle { + /** + * Makes the boss bar solid (no segments) + */ + SOLID, + /** + * Splits the boss bar into 6 segments + */ + SEGMENTED_6, + /** + * Splits the boss bar into 10 segments + */ + SEGMENTED_10, + /** + * Splits the boss bar into 12 segments + */ + SEGMENTED_12, + /** + * Splits the boss bar into 20 segments + */ + SEGMENTED_20, +} diff --git a/paper-api/src/main/java/org/bukkit/boss/BossBar.java b/paper-api/src/main/java/org/bukkit/boss/BossBar.java new file mode 100644 index 0000000000..bf472a7631 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/boss/BossBar.java @@ -0,0 +1,126 @@ +package org.bukkit.boss; + +import org.bukkit.entity.Player; + +import java.util.List; + +public interface BossBar { + + /** + * Returns the title of this boss bar + * + * @return the title of the bar + */ + String getTitle(); + + /** + * Sets the title of this boss bar + * + * @param title the title of the bar + */ + void setTitle(String title); + + /** + * Returns the color of this boss bar + * + * @return the color of the bar + */ + BarColor getColor(); + + /** + * Sets the color of this boss bar. + * + * @param color the color of the bar + */ + void setColor(BarColor color); + + /** + * Returns the style of this boss bar + * + * @return the style of the bar + */ + BarStyle getStyle(); + + /** + * Sets the bar style of this boss bar + * + * @param style the style of the bar + */ + void setStyle(BarStyle style); + + /** + * Remove an existing flag on this boss bar + * + * @param flag the existing flag to remove + */ + void removeFlag(BarFlag flag); + + /** + * Add an optional flag to this boss bar + * + * @param flag an optional flag to set on the boss bar + */ + void addFlag(BarFlag flag); + + /** + * Returns whether this boss bar as the passed flag set + * + * @param flag the flag to check + * @return whether it has the flag + */ + boolean hasFlag(BarFlag flag); + + /** + * Sets the progress of the bar. Values should be between 0.0 (empty) and + * 1.0 (full) + * + * @param progress the progress of the bar + */ + void setProgress(double progress); + + /** + * Returns the progress of the bar between 0.0 and 1.0 + * + * @return the progress of the bar + */ + double getProgress(); + + /** + * Adds the player to this boss bar causing it to display on their screen. + * + * @param player the player to add + */ + void addPlayer(Player player); + + /** + * Removes the player from this boss bar causing it to be removed from their + * screen. + * + * @param player the player to remove + */ + void removePlayer(Player player); + + /** + * Removes all players from this boss bar + * + * @see #removePlayer(Player) + */ + void removeAll(); + + /** + * Returns all players viewing this boss bar + * + * @return a immutable list of players + */ + List getPlayers(); + + /** + * Shows the previously hidden boss bar to all attached players + */ + void show(); + + /** + * Hides this boss bar from all attached players + */ + void hide(); +}