mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 11:05:13 +01:00
SPIGOT-7349: Player#setDisplayName not working when message/format unmodified
By: md_5 <git@md-5.net>
This commit is contained in:
parent
1b9d617ddc
commit
223ea107d2
2 changed files with 16 additions and 48 deletions
|
@ -1,26 +0,0 @@
|
||||||
--- a/net/minecraft/network/chat/ChatMessageType.java
|
|
||||||
+++ b/net/minecraft/network/chat/ChatMessageType.java
|
|
||||||
@@ -2,6 +2,7 @@
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
||||||
+import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.commands.CommandListenerWrapper;
|
|
||||||
@@ -27,6 +28,7 @@
|
|
||||||
public static final ResourceKey<ChatMessageType> TEAM_MSG_COMMAND_INCOMING = create("team_msg_command_incoming");
|
|
||||||
public static final ResourceKey<ChatMessageType> TEAM_MSG_COMMAND_OUTGOING = create("team_msg_command_outgoing");
|
|
||||||
public static final ResourceKey<ChatMessageType> EMOTE_COMMAND = create("emote_command");
|
|
||||||
+ public static final ResourceKey<ChatMessageType> RAW = create("raw"); // CraftBukkit
|
|
||||||
|
|
||||||
private static ResourceKey<ChatMessageType> create(String s) {
|
|
||||||
return ResourceKey.create(Registries.CHAT_TYPE, new MinecraftKey(s));
|
|
||||||
@@ -40,6 +42,7 @@
|
|
||||||
bootstapcontext.register(ChatMessageType.TEAM_MSG_COMMAND_INCOMING, new ChatMessageType(ChatDecoration.teamMessage("chat.type.team.text"), ChatDecoration.withSender("chat.type.text.narrate")));
|
|
||||||
bootstapcontext.register(ChatMessageType.TEAM_MSG_COMMAND_OUTGOING, new ChatMessageType(ChatDecoration.teamMessage("chat.type.team.sent"), ChatDecoration.withSender("chat.type.text.narrate")));
|
|
||||||
bootstapcontext.register(ChatMessageType.EMOTE_COMMAND, new ChatMessageType(ChatDecoration.withSender("chat.type.emote"), ChatDecoration.withSender("chat.type.emote")));
|
|
||||||
+ bootstapcontext.register(ChatMessageType.RAW, new ChatMessageType(new ChatDecoration("%s", List.of(ChatDecoration.a.CONTENT), ChatModifier.EMPTY), new ChatDecoration("%s", List.of(ChatDecoration.a.CONTENT), ChatModifier.EMPTY))); // CraftBukkit
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ChatMessageType.a bind(ResourceKey<ChatMessageType> resourcekey, Entity entity) {
|
|
|
@ -984,7 +984,7 @@
|
||||||
this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false));
|
this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false));
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
} else {
|
} else {
|
||||||
@@ -1465,6 +2011,122 @@
|
@@ -1465,6 +2011,116 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,9 +1023,6 @@
|
||||||
+ if (originalFormat.equals(queueEvent.getFormat()) && originalMessage.equals(queueEvent.getMessage()) && queueEvent.getPlayer().getName().equalsIgnoreCase(queueEvent.getPlayer().getDisplayName())) {
|
+ if (originalFormat.equals(queueEvent.getFormat()) && originalMessage.equals(queueEvent.getMessage()) && queueEvent.getPlayer().getName().equalsIgnoreCase(queueEvent.getPlayer().getDisplayName())) {
|
||||||
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) PlayerConnection.this.player));
|
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) PlayerConnection.this.player));
|
||||||
+ return null;
|
+ return null;
|
||||||
+ } else if (CraftChatMessage.fromComponent(original.decoratedContent()).equals(message)) {
|
|
||||||
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.RAW, (Entity) PlayerConnection.this.player));
|
|
||||||
+ return null;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ for (EntityPlayer recipient : server.getPlayerList().players) {
|
+ for (EntityPlayer recipient : server.getPlayerList().players) {
|
||||||
|
@ -1062,9 +1059,6 @@
|
||||||
+ if (originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) {
|
+ if (originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) {
|
||||||
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) PlayerConnection.this.player));
|
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) PlayerConnection.this.player));
|
||||||
+ return;
|
+ return;
|
||||||
+ } else if (CraftChatMessage.fromComponent(original.decoratedContent()).equals(s)) {
|
|
||||||
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.RAW, (Entity) PlayerConnection.this.player));
|
|
||||||
+ return;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ for (EntityPlayer recipient : server.getPlayerList().players) {
|
+ for (EntityPlayer recipient : server.getPlayerList().players) {
|
||||||
|
@ -1107,7 +1101,7 @@
|
||||||
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
|
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
|
||||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
|
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
|
||||||
|
|
||||||
@@ -1472,13 +2134,33 @@
|
@@ -1472,13 +2128,33 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
|
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
|
||||||
|
@ -1144,7 +1138,7 @@
|
||||||
this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
|
this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1500,13 +2182,62 @@
|
@@ -1500,13 +2176,62 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
|
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
|
||||||
|
@ -1207,7 +1201,7 @@
|
||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
Entity entity;
|
Entity entity;
|
||||||
IJumpable ijumpable;
|
IJumpable ijumpable;
|
||||||
@@ -1588,6 +2319,12 @@
|
@@ -1588,6 +2313,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
||||||
|
@ -1220,7 +1214,7 @@
|
||||||
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a.toNetwork(this.player.level().registryAccess())));
|
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a.toNetwork(this.player.level().registryAccess())));
|
||||||
this.addPendingMessage(playerchatmessage);
|
this.addPendingMessage(playerchatmessage);
|
||||||
}
|
}
|
||||||
@@ -1603,6 +2340,7 @@
|
@@ -1603,6 +2334,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
|
||||||
|
@ -1228,7 +1222,7 @@
|
||||||
final WorldServer worldserver = this.player.serverLevel();
|
final WorldServer worldserver = this.player.serverLevel();
|
||||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||||
|
|
||||||
@@ -1617,13 +2355,51 @@
|
@@ -1617,13 +2349,51 @@
|
||||||
|
|
||||||
if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
|
if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
|
||||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||||
|
@ -1281,7 +1275,7 @@
|
||||||
if (enuminteractionresult.consumesAction()) {
|
if (enuminteractionresult.consumesAction()) {
|
||||||
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity);
|
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity);
|
||||||
if (enuminteractionresult.shouldSwing()) {
|
if (enuminteractionresult.shouldSwing()) {
|
||||||
@@ -1636,23 +2412,29 @@
|
@@ -1636,23 +2406,29 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInteraction(EnumHand enumhand) {
|
public void onInteraction(EnumHand enumhand) {
|
||||||
|
@ -1314,7 +1308,7 @@
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
|
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
|
||||||
@@ -1675,14 +2457,14 @@
|
@@ -1675,14 +2451,14 @@
|
||||||
case PERFORM_RESPAWN:
|
case PERFORM_RESPAWN:
|
||||||
if (this.player.wonGame) {
|
if (this.player.wonGame) {
|
||||||
this.player.wonGame = false;
|
this.player.wonGame = false;
|
||||||
|
@ -1331,7 +1325,7 @@
|
||||||
if (this.server.isHardcore()) {
|
if (this.server.isHardcore()) {
|
||||||
this.player.setGameMode(EnumGamemode.SPECTATOR);
|
this.player.setGameMode(EnumGamemode.SPECTATOR);
|
||||||
((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
|
((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
|
||||||
@@ -1698,15 +2480,21 @@
|
@@ -1698,15 +2474,21 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
|
||||||
|
@ -1355,7 +1349,7 @@
|
||||||
this.player.containerMenu.sendAllDataToRemote();
|
this.player.containerMenu.sendAllDataToRemote();
|
||||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||||
@@ -1719,7 +2507,284 @@
|
@@ -1719,7 +2501,284 @@
|
||||||
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
|
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
|
||||||
|
|
||||||
this.player.containerMenu.suppressRemoteUpdates();
|
this.player.containerMenu.suppressRemoteUpdates();
|
||||||
|
@ -1641,7 +1635,7 @@
|
||||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
||||||
|
|
||||||
while (objectiterator.hasNext()) {
|
while (objectiterator.hasNext()) {
|
||||||
@@ -1759,6 +2824,7 @@
|
@@ -1759,6 +2818,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
|
||||||
|
@ -1649,7 +1643,7 @@
|
||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
|
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
|
||||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||||
@@ -1801,6 +2867,43 @@
|
@@ -1801,6 +2861,43 @@
|
||||||
|
|
||||||
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
|
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
|
||||||
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
||||||
|
@ -1693,7 +1687,7 @@
|
||||||
|
|
||||||
if (flag1 && flag2) {
|
if (flag1 && flag2) {
|
||||||
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).setByPlayer(itemstack);
|
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).setByPlayer(itemstack);
|
||||||
@@ -1823,6 +2926,7 @@
|
@@ -1823,6 +2920,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
|
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
|
||||||
|
@ -1701,7 +1695,7 @@
|
||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
WorldServer worldserver = this.player.serverLevel();
|
WorldServer worldserver = this.player.serverLevel();
|
||||||
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
||||||
@@ -1843,6 +2947,7 @@
|
@@ -1843,6 +2941,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
|
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
|
||||||
|
@ -1709,7 +1703,7 @@
|
||||||
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
|
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
|
||||||
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
||||||
|
|
||||||
@@ -1857,7 +2962,17 @@
|
@@ -1857,7 +2956,17 @@
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
|
||||||
|
@ -1728,7 +1722,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1866,8 +2981,50 @@
|
@@ -1866,8 +2975,50 @@
|
||||||
this.player.updateOptions(packetplayinsettings);
|
this.player.updateOptions(packetplayinsettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue