From fcd29087232b87ab97848b94eb8c5abe956ec816 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sat, 6 Apr 2024 12:41:56 +0800 Subject: [PATCH] Try parsing commands early in /npc rename to avoid index out of bounds --- main/src/main/java/net/citizensnpcs/commands/NPCCommands.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 467e23aad..b4ffb0320 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -2532,9 +2532,9 @@ public class NPCCommands { permission = "citizens.npc.rename") public void rename(CommandContext args, CommandSender sender, NPC npc) { String oldName = npc.getName(); - String newName = args.getJoinedStrings(1); + String newName = Messaging.parseComponents(args.getJoinedStrings(1)); int nameLength = SpigotUtil.getMaxNameLength(npc.getOrAddTrait(MobType.class).getType()); - if (Placeholders.replace(Messaging.parseComponents(newName), sender, npc).length() > nameLength) { + if (newName.length() > nameLength) { Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength); newName = newName.substring(0, nameLength); }