From f83498e5cbbbbf662b59adefadc7e8d0508cac5c Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 8 Oct 2012 22:05:19 +0800 Subject: [PATCH] Revert "Move highlight logic to StringHelper" This reverts commit 1acad881ebc879020374165c6dee225ad4b7cf73. --- .../npc/entity/CitizensEndermanNPC.java | 5 ++--- .../java/net/citizensnpcs/trait/text/Text.java | 1 + .../java/net/citizensnpcs/util/Messaging.java | 17 ++++++++++++++++- .../net/citizensnpcs/util/StringHelper.java | 14 -------------- src/main/resources/messages_en.properties | 6 +++--- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java index edeb7f652..b8c86dce2 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java @@ -45,10 +45,9 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable { } ItemStack set = hand; - if (hand.getType() != Material.AIR) { - set = hand.clone(); - set.setAmount(1); + if (set.getType() != Material.AIR) { hand.setAmount(hand.getAmount() - 1); + set.setAmount(1); } getTrait(Equipment.class).set(0, set); } diff --git a/src/main/java/net/citizensnpcs/trait/text/Text.java b/src/main/java/net/citizensnpcs/trait/text/Text.java index 619c7e560..a134f36e6 100644 --- a/src/main/java/net/citizensnpcs/trait/text/Text.java +++ b/src/main/java/net/citizensnpcs/trait/text/Text.java @@ -68,6 +68,7 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve .withEscapeSequence("exit").withModality(false).withFirstPrompt(new StartPrompt(this)) .buildConversation(player); return new Editor() { + @Override public void begin() { Messaging.sendTr(player, Messages.TEXT_EDITOR_BEGIN); diff --git a/src/main/java/net/citizensnpcs/util/Messaging.java b/src/main/java/net/citizensnpcs/util/Messaging.java index cb5be0263..5bfe62af9 100644 --- a/src/main/java/net/citizensnpcs/util/Messaging.java +++ b/src/main/java/net/citizensnpcs/util/Messaging.java @@ -50,8 +50,23 @@ public class Messaging { } private static void sendMessageTo(CommandSender sender, String rawMessage) { + rawMessage = StringHelper.parseColors(rawMessage); for (String message : CHAT_NEWLINE_SPLITTER.split(rawMessage)) { - sender.sendMessage(StringHelper.parseColors(message)); + String trimmed = message.trim(); + String messageColour = StringHelper.parseColors(Setting.MESSAGE_COLOUR.asString()); + if (!trimmed.isEmpty()) { + if (trimmed.charAt(0) == ChatColor.COLOR_CHAR) { + ChatColor test = ChatColor.getByChar(trimmed.substring(1, 2)); + if (test == null) { + message = messageColour + message; + } else + messageColour = test.toString(); + } else + message = messageColour + message; + } + message = message.replace("[[", StringHelper.parseColors(Setting.HIGHLIGHT_COLOUR.asString())); + message = message.replace("]]", messageColour); + sender.sendMessage(message); } } diff --git a/src/main/java/net/citizensnpcs/util/StringHelper.java b/src/main/java/net/citizensnpcs/util/StringHelper.java index edf5e82f7..6bb6b586a 100644 --- a/src/main/java/net/citizensnpcs/util/StringHelper.java +++ b/src/main/java/net/citizensnpcs/util/StringHelper.java @@ -66,20 +66,6 @@ public class StringHelper { parsed = parsed.replace("<" + color.getChar() + ">", color.toString()); } parsed = ChatColor.translateAlternateColorCodes('&', parsed); - String trimmed = parsed.trim(); - String messageColour = parseColors(Setting.MESSAGE_COLOUR.asString()); - if (!trimmed.isEmpty()) { - if (trimmed.charAt(0) == ChatColor.COLOR_CHAR) { - ChatColor test = ChatColor.getByChar(trimmed.substring(1, 2)); - if (test == null) { - parsed = messageColour + parsed; - } else - messageColour = test.toString(); - } else - parsed = messageColour + parsed; - } - parsed = parsed.replace("[[", parseColors(Setting.HIGHLIGHT_COLOUR.asString())); - parsed = parsed.replace("]]", messageColour); return parsed; } diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties index 1179d4084..df44c6998 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -1,22 +1,22 @@ citizens.changed-implementation=Citizens implementation changed, disabling plugin. citizens.commands.citizens.save.help=Use the -a flag to save async (off the main server thread). citizens.commands.console-error=Please report this error: [See console] +citizens.commands.help.command-missing=Command /{0} not found. citizens.commands.help.header=Help -citizens.commands.npc.behaviour.help=The scripts argument is a comma-separated list of file names. Scripts will be loaded automatically and run every tick. Use the [[-r]] flag to remove behaviours. -citizens.commands.npc.age.help=Can only be used on entities that can become babies. Use the [[-l]] flag to lock age over time (note: relogs may be required to see this). citizens.commands.id-not-found=Couldn't find any NPC with ID {0}. citizens.commands.invalid-mobtype={0} is not a valid mobtype. citizens.commands.invalid-number=That is not a valid number. citizens.commands.npc.age.cannot-be-aged=The mob type '{0}' cannot be aged. +citizens.commands.npc.age.help=Can only be used on entities that can become babies. Use the [[-l]] flag to lock age over time (note: relogs may be required to see this). citizens.commands.npc.age.invalid-age=Invalid age. Valid ages are adult, baby, number between -24000 and 0 citizens.commands.npc.age.locked=Age locked. -citizens.commands.help.command-missing=Command /{0} not found. citizens.commands.npc.age.set-adult=[[{0}]] is now an adult. citizens.commands.npc.age.set-baby=[[{0}]] is now a baby. citizens.commands.npc.age.set-normal=[[{0}]] is now age [[{1}]]. citizens.commands.npc.age.set=[[{0}]] is now [[{1}]]. citizens.commands.npc.age.unlocked=Age unlocked. citizens.commands.npc.behaviour.added=Behaviours added. +citizens.commands.npc.behaviour.help=The scripts argument is a comma-separated list of file names. Scripts will be loaded automatically and run every tick. Use the [[-r]] flag to remove behaviours. citizens.commands.npc.behaviour.removed=Behaviours removed. citizens.commands.npc.controllable.not-controllable=[[{0}]] is not controllable. citizens.commands.npc.controllable.removed=[[{0}]] can no longer be controlled.