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