summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYannick Lamprecht <yannicklamprecht@live.de>2018-11-10 20:22:05 +1100
committermd_5 <git@md-5.net>2018-11-10 20:23:13 +1100
commitdfbb9a1c9e32240fc52c0c10d69070ccf1551840 (patch)
tree655917a4b725157d05973c9e4e4a8f2da058d01a /src
parent1627782b1c341cc9928c13bc7729fd53e6fee449 (diff)
downloadbukkit-dfbb9a1c9e32240fc52c0c10d69070ccf1551840.tar
bukkit-dfbb9a1c9e32240fc52c0c10d69070ccf1551840.tar.gz
bukkit-dfbb9a1c9e32240fc52c0c10d69070ccf1551840.tar.lz
bukkit-dfbb9a1c9e32240fc52c0c10d69070ccf1551840.tar.xz
bukkit-dfbb9a1c9e32240fc52c0c10d69070ccf1551840.zip
Add API to manipulate boss bar of entities and those created by commands
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/Bukkit.java75
-rw-r--r--src/main/java/org/bukkit/Server.java67
-rw-r--r--src/main/java/org/bukkit/boss/KeyedBossBar.java9
-rw-r--r--src/main/java/org/bukkit/entity/Boss.java16
-rw-r--r--src/main/java/org/bukkit/entity/EnderDragon.java2
-rw-r--r--src/main/java/org/bukkit/entity/Wither.java2
6 files changed, 169 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 5a4654fd..d16357ea 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -19,6 +19,7 @@ import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
+import org.bukkit.boss.KeyedBossBar;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@@ -1195,6 +1196,80 @@ public final class Bukkit {
}
/**
+ * Creates a boss bar instance to display to players. The progress defaults
+ * to 1.0.
+ * <br>
+ * This instance is added to the persistent storage of the server and will
+ * be editable by commands and restored after restart.
+ *
+ * @param key the key of the boss bar that is used to access the boss bar
+ * @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 KeyedBossBar createBossBar(NamespacedKey key, String title, BarColor color, BarStyle style, BarFlag... flags) {
+ return server.createBossBar(key, title, color, style, flags);
+ }
+
+ /**
+ * Gets an unmodifiable iterator through all persistent bossbars.
+ * <ul>
+ * <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
+ * <li>
+ * <b>not</b> created using
+ * {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
+ * </li>
+ * </ul>
+ *
+ * e.g. bossbars created using the bossbar command
+ *
+ * @return a bossbar iterator
+ */
+ public static Iterator<KeyedBossBar> getBossBars() {
+ return server.getBossBars();
+ }
+
+ /**
+ * Gets the {@link KeyedBossBar} specified by this key.
+ * <ul>
+ * <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
+ * <li>
+ * <b>not</b> created using
+ * {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
+ * </li>
+ * </ul>
+ *
+ * e.g. bossbars created using the bossbar command
+ *
+ * @param key unique bossbar key
+ * @return bossbar or null if not exists
+ */
+ public static KeyedBossBar getBossBar(NamespacedKey key) {
+ return server.getBossBar(key);
+ }
+
+ /**
+ * Removes a {@link KeyedBossBar} specified by this key.
+ * <ul>
+ * <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
+ * <li>
+ * <b>not</b> created using
+ * {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
+ * </li>
+ * </ul>
+ *
+ * e.g. bossbars created using the bossbar command
+ *
+ * @param key unique bossbar key
+ * @return true if removal succeeded or false
+ */
+ public static boolean removeBossBar(NamespacedKey key) {
+ return server.removeBossBar(key);
+ }
+
+ /**
* Gets an entity on the server by its UUID
*
* @param uuid the UUID of the entity
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 21ed6aeb..23b1344b 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -19,6 +19,7 @@ import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
+import org.bukkit.boss.KeyedBossBar;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@@ -987,6 +988,72 @@ public interface Server extends PluginMessageRecipient {
BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags);
/**
+ * Creates a boss bar instance to display to players. The progress defaults
+ * to 1.0.
+ * <br>
+ * This instance is added to the persistent storage of the server and will
+ * be editable by commands and restored after restart.
+ *
+ * @param key the key of the boss bar that is used to access the boss bar
+ * @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
+ */
+ KeyedBossBar createBossBar(NamespacedKey key, String title, BarColor color, BarStyle style, BarFlag... flags);
+
+ /**
+ * Gets an unmodifiable iterator through all persistent bossbars.
+ * <ul>
+ * <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
+ * <li>
+ * <b>not</b> created using
+ * {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
+ * </li>
+ * </ul>
+ *
+ * e.g. bossbars created using the bossbar command
+ *
+ * @return a bossbar iterator
+ */
+ Iterator<KeyedBossBar> getBossBars();
+
+ /**
+ * Gets the {@link KeyedBossBar} specified by this key.
+ * <ul>
+ * <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
+ * <li>
+ * <b>not</b> created using
+ * {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
+ * </li>
+ * </ul>
+ *
+ * e.g. bossbars created using the bossbar command
+ *
+ * @param key unique bossbar key
+ * @return bossbar or null if not exists
+ */
+ KeyedBossBar getBossBar(NamespacedKey key);
+
+ /**
+ * Removes a {@link KeyedBossBar} specified by this key.
+ * <ul>
+ * <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
+ * <li>
+ * <b>not</b> created using
+ * {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
+ * </li>
+ * </ul>
+ *
+ * e.g. bossbars created using the bossbar command
+ *
+ * @param key unique bossbar key
+ * @return true if removal succeeded or false
+ */
+ boolean removeBossBar(NamespacedKey key);
+
+ /**
* Gets an entity on the server by its UUID
*
* @param uuid the UUID of the entity
diff --git a/src/main/java/org/bukkit/boss/KeyedBossBar.java b/src/main/java/org/bukkit/boss/KeyedBossBar.java
new file mode 100644
index 00000000..6a1fe5f9
--- /dev/null
+++ b/src/main/java/org/bukkit/boss/KeyedBossBar.java
@@ -0,0 +1,9 @@
+package org.bukkit.boss;
+
+import org.bukkit.Keyed;
+
+/**
+ * Represents a custom {@link BossBar} that has a
+ * {@link org.bukkit.NamespacedKey}
+ */
+public interface KeyedBossBar extends BossBar, Keyed { }
diff --git a/src/main/java/org/bukkit/entity/Boss.java b/src/main/java/org/bukkit/entity/Boss.java
new file mode 100644
index 00000000..78105359
--- /dev/null
+++ b/src/main/java/org/bukkit/entity/Boss.java
@@ -0,0 +1,16 @@
+package org.bukkit.entity;
+
+import org.bukkit.boss.BossBar;
+
+/**
+ * Represents the Boss Entity.
+ */
+public interface Boss extends Entity {
+
+ /**
+ * Returns the {@link BossBar} of the {@link Boss}
+ *
+ * @return the {@link BossBar} of the entity
+ */
+ BossBar getBossBar();
+}
diff --git a/src/main/java/org/bukkit/entity/EnderDragon.java b/src/main/java/org/bukkit/entity/EnderDragon.java
index 4ea0e44e..7170d37a 100644
--- a/src/main/java/org/bukkit/entity/EnderDragon.java
+++ b/src/main/java/org/bukkit/entity/EnderDragon.java
@@ -3,7 +3,7 @@ package org.bukkit.entity;
/**
* Represents an Ender Dragon
*/
-public interface EnderDragon extends ComplexLivingEntity {
+public interface EnderDragon extends ComplexLivingEntity, Boss {
/**
* Represents a phase or action that an Ender Dragon can perform.
diff --git a/src/main/java/org/bukkit/entity/Wither.java b/src/main/java/org/bukkit/entity/Wither.java
index 0922c5c6..3bc332ee 100644
--- a/src/main/java/org/bukkit/entity/Wither.java
+++ b/src/main/java/org/bukkit/entity/Wither.java
@@ -3,5 +3,5 @@ package org.bukkit.entity;
/**
* Represents a Wither boss
*/
-public interface Wither extends Monster {
+public interface Wither extends Monster, Boss {
}