Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Merge pull request #280 from HugoDaBosss/apiv2
Make BossBar API easier to use
Dieser Commit ist enthalten in:
Commit
405b6e8047
@ -18,7 +18,7 @@ public interface BossBar {
|
||||
*
|
||||
* @param title Title can be in either JSON or just text
|
||||
*/
|
||||
void setTitle(String title);
|
||||
BossBar setTitle(String title);
|
||||
|
||||
/**
|
||||
* Get the health
|
||||
@ -32,7 +32,7 @@ public interface BossBar {
|
||||
*
|
||||
* @param health this float has to be between 0F - 1F
|
||||
*/
|
||||
void setHealth(float health);
|
||||
BossBar setHealth(float health);
|
||||
|
||||
/**
|
||||
* Get the bossbar color
|
||||
@ -46,7 +46,7 @@ public interface BossBar {
|
||||
*
|
||||
* @param color Whatever color you want!
|
||||
*/
|
||||
void setColor(BossColor color);
|
||||
BossBar setColor(BossColor color);
|
||||
|
||||
/**
|
||||
* Get the bosbar style
|
||||
@ -60,35 +60,35 @@ public interface BossBar {
|
||||
*
|
||||
* @param style BossStyle
|
||||
*/
|
||||
void setStyle(BossStyle style);
|
||||
BossBar setStyle(BossStyle style);
|
||||
|
||||
/**
|
||||
* Show the bossbar to a player.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
void addPlayer(Player player);
|
||||
BossBar addPlayer(Player player);
|
||||
|
||||
/**
|
||||
* Remove the bossbar from a player
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
void removePlayer(Player player);
|
||||
BossBar removePlayer(Player player);
|
||||
|
||||
/**
|
||||
* Add flags
|
||||
*
|
||||
* @param flag
|
||||
*/
|
||||
void addFlag(BossFlag flag);
|
||||
BossBar addFlag(BossFlag flag);
|
||||
|
||||
/**
|
||||
* Remove flags.
|
||||
*
|
||||
* @param flag
|
||||
*/
|
||||
void removeFlag(BossFlag flag);
|
||||
BossBar removeFlag(BossFlag flag);
|
||||
|
||||
/**
|
||||
* @param flag
|
||||
@ -106,12 +106,12 @@ public interface BossBar {
|
||||
/**
|
||||
* Show the bossbar to everyone (In the getPlayer set)
|
||||
*/
|
||||
void show();
|
||||
BossBar show();
|
||||
|
||||
/**
|
||||
* Hide the bossbar from everyone (In the getPlayer set)
|
||||
*/
|
||||
void hide();
|
||||
BossBar hide();
|
||||
|
||||
/**
|
||||
* Is it visible?
|
||||
|
@ -42,17 +42,19 @@ public class ViaBossBar implements BossBar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
public BossBar setTitle(String title) {
|
||||
Validate.notNull(title, "Title cannot be null");
|
||||
this.title = title;
|
||||
sendPacket(UpdateAction.UPDATE_TITLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(float health) {
|
||||
public BossBar setHealth(float health) {
|
||||
Validate.isTrue((health >= 0 && health <= 1), "Health must be between 0 and 1");
|
||||
this.health = health;
|
||||
sendPacket(UpdateAction.UPDATE_HEALTH);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,48 +63,54 @@ public class ViaBossBar implements BossBar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(BossColor color) {
|
||||
public BossBar setColor(BossColor color) {
|
||||
Validate.notNull(color, "Color cannot be null");
|
||||
this.color = color;
|
||||
sendPacket(UpdateAction.UPDATE_STYLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyle(BossStyle style) {
|
||||
public BossBar setStyle(BossStyle style) {
|
||||
Validate.notNull(style, "Style cannot be null");
|
||||
this.style = style;
|
||||
sendPacket(UpdateAction.UPDATE_STYLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayer(Player player) {
|
||||
public BossBar addPlayer(Player player) {
|
||||
if (player != null && !players.contains(player.getUniqueId())) {
|
||||
players.add(player.getUniqueId());
|
||||
if (visible)
|
||||
sendPacket(player.getUniqueId(), getPacket(UpdateAction.ADD));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayer(Player player) {
|
||||
public BossBar removePlayer(Player player) {
|
||||
if (player != null && players.contains(player.getUniqueId())) {
|
||||
players.remove(player.getUniqueId());
|
||||
sendPacket(player.getUniqueId(), getPacket(UpdateAction.REMOVE));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFlag(BossFlag flag) {
|
||||
public BossBar addFlag(BossFlag flag) {
|
||||
if (!hasFlag(flag))
|
||||
flags.add(flag);
|
||||
sendPacket(UpdateAction.UPDATE_FLAGS);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFlag(BossFlag flag) {
|
||||
public BossBar removeFlag(BossFlag flag) {
|
||||
if (hasFlag(flag))
|
||||
flags.remove(flag);
|
||||
sendPacket(UpdateAction.UPDATE_FLAGS);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -116,13 +124,15 @@ public class ViaBossBar implements BossBar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
public BossBar show() {
|
||||
setVisible(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
public BossBar hide() {
|
||||
setVisible(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren