Send disguised chat for vanished players

This commit is contained in:
Nassim Jahnke 2023-02-09 18:15:21 +01:00
parent 5fba40cc67
commit 62048076ef

View file

@ -2269,6 +2269,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Player player = this.getCraftPlayer();
AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(this.server));
String originalFormat = event.getFormat(), originalMessage = event.getMessage();
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
public void sendPlayerChatMessage(PlayerChatMessage message, ChatType.Bound params) {
+ // Paper start
+ if (!this.getCraftPlayer().canSee(message.link().sender())) {
+ this.sendDisguisedChatMessage(message.decoratedContent(), params);
+ return;
+ }
+ // Paper end
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params.toNetwork(this.player.level.registryAccess())));
this.addPendingMessage(message);
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
return;
}
@ -3459,6 +3472,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return !this.hiddenEntities.containsKey(entity.getUniqueId());
}
+ // Paper start
+ public boolean canSee(UUID entityUUID) {
+ return !this.hiddenEntities.containsKey(entityUUID);
+ }
+ // Paper end
+
@Override
public Map<String, Object> serialize() {
Map<String, Object> result = new LinkedHashMap<String, Object>();
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void setResourcePack(String url) {