Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Merge pull request #308 from Matsv/boss
Cleanup BossBar class & add new bossbar api method, addPlayers()
Dieser Commit ist enthalten in:
Commit
995dc135b8
@ -69,6 +69,14 @@ public interface BossBar {
|
|||||||
*/
|
*/
|
||||||
BossBar addPlayer(Player player);
|
BossBar addPlayer(Player player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add multiple players
|
||||||
|
*
|
||||||
|
* @param players list of players
|
||||||
|
* @return the bossbar instance
|
||||||
|
*/
|
||||||
|
BossBar addPlayers(Player...players);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the bossbar from a player
|
* Remove the bossbar from a player
|
||||||
*
|
*
|
||||||
|
@ -3,6 +3,7 @@ package us.myles.ViaVersion.boss;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -42,8 +43,7 @@ public class ViaBossBar implements BossBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar setTitle(String title) {
|
public BossBar setTitle(@NonNull String title) {
|
||||||
Validate.notNull(title, "Title cannot be null");
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
sendPacket(UpdateAction.UPDATE_TITLE);
|
sendPacket(UpdateAction.UPDATE_TITLE);
|
||||||
return this;
|
return this;
|
||||||
@ -63,24 +63,22 @@ public class ViaBossBar implements BossBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar setColor(BossColor color) {
|
public BossBar setColor(@NonNull BossColor color) {
|
||||||
Validate.notNull(color, "Color cannot be null");
|
|
||||||
this.color = color;
|
this.color = color;
|
||||||
sendPacket(UpdateAction.UPDATE_STYLE);
|
sendPacket(UpdateAction.UPDATE_STYLE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar setStyle(BossStyle style) {
|
public BossBar setStyle(@NonNull BossStyle style) {
|
||||||
Validate.notNull(style, "Style cannot be null");
|
|
||||||
this.style = style;
|
this.style = style;
|
||||||
sendPacket(UpdateAction.UPDATE_STYLE);
|
sendPacket(UpdateAction.UPDATE_STYLE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar addPlayer(Player player) {
|
public BossBar addPlayer(@NonNull Player player) {
|
||||||
if (player != null && !players.contains(player.getUniqueId())) {
|
if (!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));
|
||||||
@ -89,8 +87,8 @@ public class ViaBossBar implements BossBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar removePlayer(Player player) {
|
public BossBar removePlayer(@NonNull Player player) {
|
||||||
if (player != null && players.contains(player.getUniqueId())) {
|
if (players.contains(player.getUniqueId())) {
|
||||||
players.remove(player.getUniqueId());
|
players.remove(player.getUniqueId());
|
||||||
sendPacket(player.getUniqueId(), getPacket(UpdateAction.REMOVE));
|
sendPacket(player.getUniqueId(), getPacket(UpdateAction.REMOVE));
|
||||||
}
|
}
|
||||||
@ -98,7 +96,14 @@ public class ViaBossBar implements BossBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar addFlag(BossFlag flag) {
|
public BossBar addPlayers(@NonNull Player... players) {
|
||||||
|
for (Player p : players)
|
||||||
|
addPlayer(p);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BossBar addFlag(@NonNull BossFlag flag) {
|
||||||
if (!hasFlag(flag))
|
if (!hasFlag(flag))
|
||||||
flags.add(flag);
|
flags.add(flag);
|
||||||
sendPacket(UpdateAction.UPDATE_FLAGS);
|
sendPacket(UpdateAction.UPDATE_FLAGS);
|
||||||
@ -106,7 +111,7 @@ public class ViaBossBar implements BossBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar removeFlag(BossFlag flag) {
|
public BossBar removeFlag(@NonNull BossFlag flag) {
|
||||||
if (hasFlag(flag))
|
if (hasFlag(flag))
|
||||||
flags.remove(flag);
|
flags.remove(flag);
|
||||||
sendPacket(UpdateAction.UPDATE_FLAGS);
|
sendPacket(UpdateAction.UPDATE_FLAGS);
|
||||||
@ -114,7 +119,7 @@ public class ViaBossBar implements BossBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFlag(BossFlag flag) {
|
public boolean hasFlag(@NonNull BossFlag flag) {
|
||||||
return flags.contains(flag);
|
return flags.contains(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren