mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 03:43:40 +01:00
Implement BossBar API
By: Thinkofdeath <thinkofdeath@spigotmc.org>
This commit is contained in:
parent
2e3099f3cf
commit
b54073a1e1
5 changed files with 196 additions and 0 deletions
|
@ -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
|
||||
|
|
11
paper-api/src/main/java/org/bukkit/boss/BarColor.java
Normal file
11
paper-api/src/main/java/org/bukkit/boss/BarColor.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package org.bukkit.boss;
|
||||
|
||||
public enum BarColor {
|
||||
PINK,
|
||||
BLUE,
|
||||
RED,
|
||||
GREEN,
|
||||
YELLOW,
|
||||
PURPLE,
|
||||
WHITE
|
||||
}
|
17
paper-api/src/main/java/org/bukkit/boss/BarFlag.java
Normal file
17
paper-api/src/main/java/org/bukkit/boss/BarFlag.java
Normal file
|
@ -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,
|
||||
}
|
24
paper-api/src/main/java/org/bukkit/boss/BarStyle.java
Normal file
24
paper-api/src/main/java/org/bukkit/boss/BarStyle.java
Normal file
|
@ -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,
|
||||
}
|
126
paper-api/src/main/java/org/bukkit/boss/BossBar.java
Normal file
126
paper-api/src/main/java/org/bukkit/boss/BossBar.java
Normal file
|
@ -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();
|
||||
}
|
Loading…
Reference in a new issue