diff options
author | Thinkofdeath <thinkofdeath@spigotmc.org> | 2016-03-01 08:30:03 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-03-01 08:30:03 +1100 |
commit | 2023127d5587259cc6b282354d410e8fe3aedf33 (patch) | |
tree | 03213d7c715b0f11cc9ea121361c6a8f982c8a88 | |
parent | a21d8c465bd7adc9c189d5ac03373afe9da47e53 (diff) | |
download | bukkit-2023127d5587259cc6b282354d410e8fe3aedf33.tar bukkit-2023127d5587259cc6b282354d410e8fe3aedf33.tar.gz bukkit-2023127d5587259cc6b282354d410e8fe3aedf33.tar.lz bukkit-2023127d5587259cc6b282354d410e8fe3aedf33.tar.xz bukkit-2023127d5587259cc6b282354d410e8fe3aedf33.zip |
Implement BossBar API
-rw-r--r-- | src/main/java/org/bukkit/Bukkit.java | 18 | ||||
-rw-r--r-- | src/main/java/org/bukkit/boss/BarColor.java | 11 | ||||
-rw-r--r-- | src/main/java/org/bukkit/boss/BarFlag.java | 17 | ||||
-rw-r--r-- | src/main/java/org/bukkit/boss/BarStyle.java | 24 | ||||
-rw-r--r-- | src/main/java/org/bukkit/boss/BossBar.java | 126 |
5 files changed, 196 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index d7b88d6e..2ace8c15 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/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; @@ -1131,6 +1135,20 @@ public final class Bukkit { } /** + * 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/src/main/java/org/bukkit/boss/BarColor.java b/src/main/java/org/bukkit/boss/BarColor.java new file mode 100644 index 00000000..e191d9ff --- /dev/null +++ b/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/src/main/java/org/bukkit/boss/BarFlag.java b/src/main/java/org/bukkit/boss/BarFlag.java new file mode 100644 index 00000000..69e02998 --- /dev/null +++ b/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/src/main/java/org/bukkit/boss/BarStyle.java b/src/main/java/org/bukkit/boss/BarStyle.java new file mode 100644 index 00000000..3e499eb7 --- /dev/null +++ b/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/src/main/java/org/bukkit/boss/BossBar.java b/src/main/java/org/bukkit/boss/BossBar.java new file mode 100644 index 00000000..bf472a76 --- /dev/null +++ b/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<Player> getPlayers(); + + /** + * Shows the previously hidden boss bar to all attached players + */ + void show(); + + /** + * Hides this boss bar from all attached players + */ + void hide(); +} |