From c8d32f6ca3efe59f99f9ef935965b14686e21236 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 25 Mar 2023 08:49:26 +1100 Subject: [PATCH] SPIGOT-7312: Entity#setVisibleByDefault on player causes skin reset on this player client By: md_5 --- .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 05f2258adc..df39b5f00b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1340,6 +1340,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } void resetAndHideEntity(org.bukkit.entity.Entity entity) { + // SPIGOT-7312: Can't show/hide self + if (equals(entity)) { + return; + } + if (invertedVisibilityEntities.remove(entity.getUniqueId()) == null) { untrackAndHideEntity(entity); } @@ -1413,6 +1418,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } void resetAndShowEntity(org.bukkit.entity.Entity entity) { + // SPIGOT-7312: Can't show/hide self + if (equals(entity)) { + return; + } + if (invertedVisibilityEntities.remove(entity.getUniqueId()) == null) { trackAndShowEntity(entity); } @@ -1429,7 +1439,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean canSee(org.bukkit.entity.Entity entity) { - return entity.isVisibleByDefault() ^ invertedVisibilityEntities.containsKey(entity.getUniqueId()); + return equals(entity) || entity.isVisibleByDefault() ^ invertedVisibilityEntities.containsKey(entity.getUniqueId()); // SPIGOT-7312: Can always see self } public boolean canSee(UUID uuid) {