mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-18 00:25:30 +01:00
Remove boss bar registration system
This commit is contained in:
parent
404d6aa45e
commit
45f6d4b80c
@ -25,16 +25,13 @@ final class BossBarHolder implements Viewable {
|
||||
protected final UUID uuid = UUID.randomUUID();
|
||||
protected final Set<Player> players = new CopyOnWriteArraySet<>();
|
||||
protected final BossBar bar;
|
||||
protected boolean registered;
|
||||
|
||||
BossBarHolder(@NotNull BossBar bar) {
|
||||
this.bar = bar;
|
||||
this.registered = false;
|
||||
}
|
||||
|
||||
@NotNull BossBarPacket createRemovePacket() {
|
||||
return this.createGenericPacket(REMOVE, packet -> {
|
||||
});
|
||||
return this.createGenericPacket(REMOVE, packet -> { });
|
||||
}
|
||||
|
||||
@NotNull BossBarPacket createAddPacket() {
|
||||
|
@ -56,7 +56,7 @@ class BossBarListener implements BossBar.Listener {
|
||||
private void doIfRegistered(@NotNull BossBar bar, @NotNull Consumer<BossBarHolder> consumer) {
|
||||
BossBarHolder holder = this.manager.bars.get(bar);
|
||||
|
||||
if (holder != null && holder.registered) {
|
||||
if (holder != null) {
|
||||
consumer.accept(holder);
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ public class BossBarManager {
|
||||
* @param bar the boss bar to hide
|
||||
*/
|
||||
public void removeBossBar(@NotNull Player player, @NotNull BossBar bar) {
|
||||
BossBarHolder holder = this.getOrCreateHandler(bar);
|
||||
BossBarHolder holder = this.bars.get(bar);
|
||||
|
||||
if (holder.removeViewer(player)) {
|
||||
if (holder != null && holder.removeViewer(player)) {
|
||||
player.getPlayerConnection().sendPacket(holder.createRemovePacket());
|
||||
this.removePlayer(player, holder);
|
||||
}
|
||||
@ -96,18 +96,21 @@ public class BossBarManager {
|
||||
* @param bar the boss bar to hide
|
||||
*/
|
||||
public void removeBossBar(@NotNull Collection<Player> players, @NotNull BossBar bar) {
|
||||
BossBarHolder holder = this.getOrCreateHandler(bar);
|
||||
Collection<Player> removedPlayers = new ArrayList<>();
|
||||
BossBarHolder holder = this.bars.get(bar);
|
||||
|
||||
for (Player player : players) {
|
||||
if (holder.removeViewer(player)) {
|
||||
removedPlayers.add(player);
|
||||
this.removePlayer(player, holder);
|
||||
if (holder != null) {
|
||||
Collection<Player> removedPlayers = new ArrayList<>();
|
||||
|
||||
for (Player player : players) {
|
||||
if (holder.removeViewer(player)) {
|
||||
removedPlayers.add(player);
|
||||
this.removePlayer(player, holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!removedPlayers.isEmpty()) {
|
||||
PacketUtils.sendGroupedPacket(removedPlayers, holder.createRemovePacket());
|
||||
if (!removedPlayers.isEmpty()) {
|
||||
PacketUtils.sendGroupedPacket(removedPlayers, holder.createRemovePacket());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user