diff --git a/TODO b/TODO index c54722140..58427c9e8 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ -Citizens2 TODO List- --Better inventory handling/saving --Add proper color parsing for names -Add NPC templates -Finish pathfinding API -Add database support (MySQL and/or SQLite) \ No newline at end of file diff --git a/lib/CitizensAPI.jar b/lib/CitizensAPI.jar index d518fa676..b1675fedb 100644 Binary files a/lib/CitizensAPI.jar and b/lib/CitizensAPI.jar differ diff --git a/src/net/citizensnpcs/command/command/NPCCommands.java b/src/net/citizensnpcs/command/command/NPCCommands.java index b7a138c1f..4a44c5fdc 100644 --- a/src/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/net/citizensnpcs/command/command/NPCCommands.java @@ -43,7 +43,7 @@ public class NPCCommands { @Requirements public void createNPC(CommandContext args, Player player, NPC npc) { String name = args.getString(1); - if (args.getString(1).length() > 16) { + if (name.length() > 16) { Messaging.sendError(player, "NPC names cannot be longer than 16 characters. The name has been shortened."); name = name.substring(0, 15); } @@ -55,7 +55,7 @@ public class NPCCommands { Messaging.sendError(player, "'" + args.getString(2) + "' is not a valid mob type. Using default NPC."); } NPC create = npcManager.createNPC(type, name); - String successMsg = ChatColor.GREEN + "You created " + StringHelper.wrap(create.getName()); + String successMsg = ChatColor.GREEN + "You created " + create.getName(); boolean success = true; if (args.argsLength() == 4) { if (characterManager.getInstance(args.getString(3), create) == null) { diff --git a/src/net/citizensnpcs/npc/entity/CitizensHumanNPC.java b/src/net/citizensnpcs/npc/entity/CitizensHumanNPC.java index 54a0f9633..2a88f098d 100644 --- a/src/net/citizensnpcs/npc/entity/CitizensHumanNPC.java +++ b/src/net/citizensnpcs/npc/entity/CitizensHumanNPC.java @@ -3,6 +3,7 @@ package net.citizensnpcs.npc.entity; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.CitizensNPCManager; import net.citizensnpcs.resource.lib.EntityHumanNPC; +import net.citizensnpcs.util.StringHelper; import net.minecraft.server.EntityLiving; import net.minecraft.server.ItemInWorldManager; import net.minecraft.server.WorldServer; @@ -31,8 +32,8 @@ public class CitizensHumanNPC extends CitizensNPC { @Override protected EntityLiving createHandle(Location loc) { WorldServer ws = ((CraftWorld) loc.getWorld()).getHandle(); - EntityHumanNPC handle = new EntityHumanNPC(ws.getServer().getServer(), ws, getFullName(), - new ItemInWorldManager(ws)); + EntityHumanNPC handle = new EntityHumanNPC(ws.getServer().getServer(), ws, + StringHelper.parseColors(getFullName()), new ItemInWorldManager(ws)); handle.removeFromPlayerMap(getFullName()); handle.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); return handle; diff --git a/src/net/citizensnpcs/util/Messaging.java b/src/net/citizensnpcs/util/Messaging.java index 82cdff8ec..a6f029255 100644 --- a/src/net/citizensnpcs/util/Messaging.java +++ b/src/net/citizensnpcs/util/Messaging.java @@ -28,12 +28,7 @@ public class Messaging { } public static void send(Player player, Object msg) { - String send = msg.toString(); - - for (ChatColor color : ChatColor.values()) - send = send.replace("<" + color.getChar() + ">", color.toString()); - - player.sendMessage(send); + player.sendMessage(StringHelper.parseColors(msg.toString())); } public static void sendError(Player player, Object msg) { diff --git a/src/net/citizensnpcs/util/StringHelper.java b/src/net/citizensnpcs/util/StringHelper.java index 34a737d5e..7914b1dc6 100644 --- a/src/net/citizensnpcs/util/StringHelper.java +++ b/src/net/citizensnpcs/util/StringHelper.java @@ -56,4 +56,11 @@ public class StringHelper { public static String wrap(Object string) { return ChatColor.YELLOW + string.toString() + ChatColor.GREEN; } + + public static String parseColors(Object string) { + String parsed = string.toString(); + for (ChatColor color : ChatColor.values()) + parsed = parsed.replace("<" + color.getChar() + ">", color.toString()); + return parsed; + } } \ No newline at end of file