From 6a322f7f25d6356d09a03e7f8b4b0111905c5615 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sun, 5 Aug 2012 14:15:04 +0800 Subject: [PATCH] Support spaces in names for /npc rename --- .../net/citizensnpcs/command/command/HelpCommands.java | 8 ++++---- .../net/citizensnpcs/command/command/NPCCommands.java | 2 +- src/main/java/net/citizensnpcs/npc/CitizensNPC.java | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/citizensnpcs/command/command/HelpCommands.java b/src/main/java/net/citizensnpcs/command/command/HelpCommands.java index 88739d326..b61c40ce3 100644 --- a/src/main/java/net/citizensnpcs/command/command/HelpCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/HelpCommands.java @@ -47,12 +47,12 @@ public class HelpCommands { List lines = new ArrayList(); for (Command cmd : plugin.getCommands(baseCommand)) { if (cmds.contains(cmd) - || (!sender.hasPermission("citizens.admin") && !sender - .hasPermission("citizens." + cmd.permission()))) + || (!sender.hasPermission("citizens.admin") && !sender.hasPermission("citizens." + + cmd.permission()))) continue; - lines.add("<7>/" + cmd.aliases()[0] + (cmd.usage().isEmpty() ? "" : " " + cmd.usage()) + " <7>- " - + cmd.desc()); + lines.add("<7>/" + cmd.aliases()[0] + (cmd.usage().isEmpty() ? "" : " " + cmd.usage()) + + " <7>- " + cmd.desc()); if (cmd.modifiers().length > 1) cmds.add(cmd); } diff --git a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java index 6054faef6..726db2814 100644 --- a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java @@ -423,7 +423,7 @@ public class NPCCommands { permission = "npc.rename") public void rename(CommandContext args, CommandSender sender, NPC npc) { String oldName = npc.getName(); - String newName = args.getString(1); + String newName = args.getJoinedStrings(1); if (newName.length() > 16) { Messaging.sendError(sender, "NPC names cannot be longer than 16 characters. The name has been shortened."); diff --git a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index f12369f64..f8b498661 100644 --- a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -79,10 +79,12 @@ public abstract class CitizensNPC extends AbstractNPC { Trait trait = CitizensAPI.getTraitFactory().getTrait(traitKey.name()); if (trait == null) { Messaging.severeF( - "Skipped missing trait '%s' while loading NPC ID: '%d'. Has the name changed?", + "Skipped broken or missing trait '%s' while loading ID '%d'. Has the name changed?", traitKey.name(), getId()); continue; } + if (traitKey.keyExists("enabled") && !traitKey.getBoolean("enabled")) + continue; addTrait(trait); try { trait.load(traitKey);