Add check for existing viewers before adding them
Updated the addViewer method to verify if a player is already in the viewers list before adding. Adjusted the order of operations to ensure the scoreboard is updated correctly before adding the player to the viewers.
This commit is contained in:
parent
6c6a87e6c2
commit
d4eccf478f
|
|
@ -88,11 +88,13 @@ public class Leaderboard {
|
|||
}
|
||||
|
||||
public void addViewer(Player player) {
|
||||
if (viewers.put(player.getUniqueId(), player) == null) {
|
||||
if (viewers.containsKey(player.getUniqueId())) {
|
||||
return; //Player was already in viewers list
|
||||
}
|
||||
protocolManager.sendServerPacket(player, title.entitySpawnPacket());
|
||||
lines.forEach(line -> protocolManager.sendServerPacket(player, line.entitySpawnPacket()));
|
||||
updateScoreboard(player);
|
||||
viewers.put(player.getUniqueId(), player);
|
||||
}
|
||||
|
||||
public void removeViewer(Player player) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user