From 36671daeae3370164a8be56e6d5f75164398624a Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 26 Dec 2022 00:20:21 +0800 Subject: [PATCH] Check parsed name length --- .../src/main/java/net/citizensnpcs/ProtocolLibListener.java | 6 ------ .../main/java/net/citizensnpcs/commands/NPCCommands.java | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/ProtocolLibListener.java b/main/src/main/java/net/citizensnpcs/ProtocolLibListener.java index fcfb5c67b..b597927c5 100644 --- a/main/src/main/java/net/citizensnpcs/ProtocolLibListener.java +++ b/main/src/main/java/net/citizensnpcs/ProtocolLibListener.java @@ -53,9 +53,6 @@ public class ProtocolLibListener { manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.MONITOR, Server.PLAYER_INFO) { @Override public void onPacketSending(PacketEvent event) { - if (event.getPlayer().hasMetadata("NPC")) - return; - int version = VIA_ENABLED ? Via.getAPI().getPlayerVersion(event.getPlayer()) : manager.getProtocolVersion(event.getPlayer()); List list = event.getPacket().getPlayerInfoDataLists() @@ -97,9 +94,6 @@ public class ProtocolLibListener { new PacketAdapter(plugin, ListenerPriority.MONITOR, Server.ENTITY_HEAD_ROTATION, Server.ENTITY_LOOK) { @Override public void onPacketSending(PacketEvent event) { - if (event.getPlayer().hasMetadata("NPC")) - return; - NPC npc = getNPCFromPacket(event); if (npc == null) return; diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 635ce84f0..0e94ab2ff 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -638,7 +638,7 @@ public class NPCCommands { } int nameLength = SpigotUtil.getMaxNameLength(type); - if (name.length() > nameLength && Placeholders.replace(name, sender, npc).length() > nameLength) { + if (Placeholders.replace(Messaging.parseComponents(name), sender, npc).length() > nameLength) { Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength); name = name.substring(0, nameLength); } @@ -2138,7 +2138,7 @@ public class NPCCommands { String oldName = npc.getName(); String newName = args.getJoinedStrings(1); int nameLength = SpigotUtil.getMaxNameLength(npc.getOrAddTrait(MobType.class).getType()); - if (newName.length() > nameLength && Placeholders.replace(newName, sender, npc).length() > nameLength) { + if (Placeholders.replace(Messaging.parseComponents(newName), sender, npc).length() > nameLength) { Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength); newName = newName.substring(0, nameLength); }