From d6410781a52d60b4c6898f1622621dafcf23ff68 Mon Sep 17 00:00:00 2001 From: aPunch Date: Wed, 8 Feb 2012 14:01:27 -0600 Subject: [PATCH] shorten names when renaming NPC --- .../command/command/NPCCommands.java | 52 ++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/src/net/citizensnpcs/command/command/NPCCommands.java b/src/net/citizensnpcs/command/command/NPCCommands.java index 0e46e1676..c14c9cb4e 100644 --- a/src/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/net/citizensnpcs/command/command/NPCCommands.java @@ -108,6 +108,18 @@ public class NPCCommands { npc.despawn(); Messaging.send(player, ChatColor.GREEN + "You despawned " + StringHelper.wrap(npc.getName()) + "."); } + + @Command( + aliases = { "npc" }, + usage = "editor [editor]", + desc = "Enter an NPC editor", + modifiers = { "editor" }, + min = 2, + max = 2, + permission = "npc.editor") + public void enterEditor(CommandContext args, Player player, NPC npc) { + // TODO + } @Command( aliases = { "npc" }, @@ -119,11 +131,15 @@ public class NPCCommands { permission = "npc.rename") public void renameNPC(CommandContext args, Player player, NPC npc) { String oldName = npc.getName(); - npc.setName(args.getString(1)); - Messaging.send( - player, - ChatColor.GREEN + "You renamed " + StringHelper.wrap(oldName) + " to " - + StringHelper.wrap(args.getString(1)) + "."); + String newName = args.getString(1); + if (newName.length() > 16) { + Messaging.sendError(player, "NPC names cannot be longer than 16 characters. The name has been shortened."); + newName = newName.substring(0, 15); + } + npc.setName(newName); + Messaging.send(player, + ChatColor.GREEN + "You renamed " + StringHelper.wrap(oldName) + " to " + StringHelper.wrap(newName) + + "."); } @Command( @@ -148,6 +164,18 @@ public class NPCCommands { npcManager.selectNPC(player, toSelect); Messaging.sendWithNPC(player, Setting.SELECTION_MESSAGE.asString(), toSelect); } + + @Command( + aliases = { "npc" }, + usage = "character [character]", + desc = "Sets the character of an NPC", + modifiers = { "character" }, + min = 2, + max = 2, + permission = "npc.character") + public void setNPCCharacter(CommandContext args, Player player, NPC npc) { + // TODO + } @Command( aliases = { "npc" }, @@ -207,13 +235,13 @@ public class NPCCommands { } @Command( - aliases = { "npc" }, - usage = "lookclose", - desc = "Toggle an NPC's look-close state", - modifiers = { "lookclose", "look", "rotate" }, - min = 1, - max = 1, - permission = "npc.look-close") + aliases = { "npc" }, + usage = "lookclose", + desc = "Toggle an NPC's look-close state", + modifiers = { "lookclose", "look", "rotate" }, + min = 1, + max = 1, + permission = "npc.look-close") public void toggleNPCLookClose(CommandContext args, Player player, NPC npc) { LookClose trait = npc.getTrait(LookClose.class); trait.toggle();