Fix unnecessary and potential not thread-safe chat visibility check
This commit is contained in:
parent
12360a7ece
commit
c1a26b366b
@ -1177,7 +1177,7 @@
|
|||||||
|
|
||||||
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
||||||
+ // CraftBukkit start - SPIGOT-7262: if hidden we have to send as disguised message. Query whether we should send at all (but changing this may not be expected).
|
+ // CraftBukkit start - SPIGOT-7262: if hidden we have to send as disguised message. Query whether we should send at all (but changing this may not be expected).
|
||||||
+ if (!getCraftPlayer().canSee(playerchatmessage.link().sender())) {
|
+ if (!getCraftPlayer().canSeePlayer(playerchatmessage.link().sender())) {
|
||||||
+ sendDisguisedChatMessage(playerchatmessage.decoratedContent(), chatmessagetype_a);
|
+ sendDisguisedChatMessage(playerchatmessage.decoratedContent(), chatmessagetype_a);
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
|
@ -1657,11 +1657,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
return equals(entity) || entity.isVisibleByDefault() ^ invertedVisibilityEntities.containsKey(entity.getUniqueId()); // SPIGOT-7312: Can always see self
|
return equals(entity) || entity.isVisibleByDefault() ^ invertedVisibilityEntities.containsKey(entity.getUniqueId()); // SPIGOT-7312: Can always see self
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSee(UUID uuid) {
|
public boolean canSeePlayer(UUID uuid) {
|
||||||
org.bukkit.entity.Entity entity = getServer().getPlayer(uuid);
|
org.bukkit.entity.Entity entity = getServer().getPlayer(uuid);
|
||||||
if (entity == null) {
|
|
||||||
entity = getServer().getEntity(uuid); // Also includes players, but check players first for efficiency
|
|
||||||
}
|
|
||||||
|
|
||||||
return (entity != null) ? canSee(entity) : false; // If we can't find it, we can't see it
|
return (entity != null) ? canSee(entity) : false; // If we can't find it, we can't see it
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user