mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-04 14:12:20 -07:00
Add API to manipulate boss bar of entities and those created by commands
By: Yannick Lamprecht <yannicklamprecht@live.de>
This commit is contained in:
@@ -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;
|
||||
@@ -1194,6 +1195,80 @@ public final class Bukkit {
|
||||
return server.createBossBar(title, color, style, 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
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
Reference in New Issue
Block a user