Remove unnecessary contains before add and remove on HashSet
This commit is contained in:
parent
001e3ea754
commit
4b9c4a97c3
|
@ -132,9 +132,7 @@ public abstract class NPC implements PacketHandler, ActionHandler {
|
|||
shown.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
if (!autoHidden.contains(player.getUniqueId())) {
|
||||
autoHidden.add(player.getUniqueId());
|
||||
}
|
||||
autoHidden.add(player.getUniqueId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -154,9 +152,7 @@ public abstract class NPC implements PacketHandler, ActionHandler {
|
|||
if (player.getLocation().distance(location) <= autoHideDistance) {
|
||||
sendShowPackets(player);
|
||||
} else {
|
||||
if (!autoHidden.contains(player.getUniqueId())) {
|
||||
autoHidden.add(player.getUniqueId());
|
||||
}
|
||||
autoHidden.add(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,9 +185,7 @@ public abstract class NPC implements PacketHandler, ActionHandler {
|
|||
if (player.getWorld().equals(location.getWorld()) && player.getLocation().distance(location) <= autoHideDistance) {
|
||||
sendHidePackets(player, scheduler);
|
||||
} else {
|
||||
if (autoHidden.contains(player.getUniqueId())) {
|
||||
autoHidden.remove(player.getUniqueId());
|
||||
}
|
||||
autoHidden.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,10 @@ public class PlayerListener implements Listener {
|
|||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
for (NPC npc : NPCManager.getAllNPCs()) {
|
||||
if (npc.getAutoHidden().contains(player.getUniqueId())) {
|
||||
npc.getAutoHidden().remove(player.getUniqueId());
|
||||
}
|
||||
npc.getAutoHidden().remove(player.getUniqueId());
|
||||
|
||||
// Don't need to use NPC#hide since the entity is not registered in the NMS server.
|
||||
if (npc.getShown().contains(player.getUniqueId())) {
|
||||
npc.getShown().remove(player.getUniqueId());
|
||||
}
|
||||
npc.getShown().remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue