summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-06-27 09:31:29 +0100
committerKHobbits <rob@khobbits.co.uk>2013-06-27 09:33:35 +0100
commit0292cb59cd429c1fd6c55ed976c27877d02e9d1e (patch)
tree2664c371837b5d23ad6457d0f186061a541e0e0c
parent3e519f95d5c6b81ee2c18344c1211789019e7647 (diff)
downloadEssentials-0292cb59cd429c1fd6c55ed976c27877d02e9d1e.tar
Essentials-0292cb59cd429c1fd6c55ed976c27877d02e9d1e.tar.gz
Essentials-0292cb59cd429c1fd6c55ed976c27877d02e9d1e.tar.lz
Essentials-0292cb59cd429c1fd6c55ed976c27877d02e9d1e.tar.xz
Essentials-0292cb59cd429c1fd6c55ed976c27877d02e9d1e.zip
Drop messageFormat for simple string replace, remove duped ' marks.
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java25
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java12
3 files changed, 18 insertions, 21 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index 5ce948027..062e2461a 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -27,7 +27,7 @@ public interface ISettings extends IConf
long getBackupInterval();
- MessageFormat getChatFormat(String group);
+ String getChatFormat(String group);
int getChatRadius();
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index e464362b6..c92395849 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -402,26 +402,23 @@ public class Settings implements ISettings
{
return config.getString("backup.command", null);
}
- private Map<String, MessageFormat> chatFormats = Collections.synchronizedMap(new HashMap<String, MessageFormat>());
+ private Map<String, String> chatFormats = Collections.synchronizedMap(new HashMap<String, String>());
@Override
- public MessageFormat getChatFormat(String group)
+ public String getChatFormat(String group)
{
- MessageFormat mFormat = chatFormats.get(group);
+ String mFormat = chatFormats.get(group);
if (mFormat == null)
{
- String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
+ mFormat = config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&r {DISPLAYNAME}&7:&r {MESSAGE}"));
- format = FormatUtil.replaceFormat(format);
- format = format.replace("'", "''");
- format = format.replace("{DISPLAYNAME}", "%1$s");
- format = format.replace("{GROUP}", "{0}");
- format = format.replace("{MESSAGE}", "%2$s");
- format = format.replace("{WORLDNAME}", "{1}");
- format = format.replace("{SHORTWORLDNAME}", "{2}");
- format = format.replaceAll("\\{(\\D*?)\\}", "'\\{$1\\}'");
- format = "§r".concat(format);
- mFormat = new MessageFormat(format);
+ mFormat = FormatUtil.replaceFormat(mFormat);
+ mFormat = mFormat.replace("{DISPLAYNAME}", "%1$s");
+ mFormat = mFormat.replace("{MESSAGE}", "%2$s");
+ mFormat = mFormat.replace("{GROUP}", "{0}");
+ mFormat = mFormat.replace("{WORLDNAME}", "{1}");
+ mFormat = mFormat.replace("{SHORTWORLDNAME}", "{2}");
+ mFormat = "§r".concat(mFormat);
chatFormats.put(group, mFormat);
}
return mFormat;
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java
index a86dcd14f..efd3f5515 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java
@@ -48,13 +48,13 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
event.setMessage(FormatUtil.formatMessage(user, "essentials.chat", event.getMessage()));
String group = user.getGroup();
String world = user.getWorld().getName();
- MessageFormat format = ess.getSettings().getChatFormat(group);
+ String format = ess.getSettings().getChatFormat(group);
+ format = format.replace("{0}", group);
+ format = format.replace("{1}", world);
+ format = format.replace("{2}", world.substring(0, 1).toUpperCase(Locale.ENGLISH));
synchronized (format)
- {
- event.setFormat(format.format(new Object[]
- {
- group, world, world.substring(0, 1).toUpperCase(Locale.ENGLISH)
- }));
+ {
+ event.setFormat(format);
}
}
}