Add escape sequence '&color;' support for webprefix/websuffix - avoid frequent editor code page problems.

This commit is contained in:
Mike Primm 2011-07-24 20:31:12 -05:00
parent 39a6bee3ca
commit abd7c25d80
4 changed files with 14 additions and 5 deletions

View file

@ -10,4 +10,12 @@ public abstract class Component {
public void dispose() {
}
/* Substitute proper values for escape sequences */
public static String unescapeString(String v) {
/* Replace color code &color; */
v = v.replaceAll("&color;", "\u00A7");
return v;
}
}

View file

@ -19,7 +19,7 @@ public class SimpleWebChatComponent extends Component {
DynmapWebChatEvent evt = new DynmapWebChatEvent(t.source, t.name, t.message);
plugin.getServer().getPluginManager().callEvent(evt);
if(evt.isCancelled() == false)
plugin.getServer().broadcastMessage(plugin.configuration.getString("webprefix", "\u00A72[WEB] ") + t.name + ": " + plugin.configuration.getString("websuffix", "\u00A7f") + t.message);
plugin.getServer().broadcastMessage(unescapeString(plugin.configuration.getString("webprefix", "\u00A72[WEB] ")) + t.name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + t.message);
}
});

View file

@ -28,7 +28,7 @@ public class HeroWebChatComponent extends Component {
if(evt.isCancelled() == false) {
/* Let HeroChat take a look - only broadcast to players if it doesn't handle it */
if (!handler.sendWebMessageToHeroChat(t.name, t.message)) {
plugin.getServer().broadcastMessage(plugin.configuration.getString("webprefix", "\u00A72[WEB] ") + t.name + ": " + plugin.configuration.getString("websuffix", "\u00A7f") + t.message);
plugin.getServer().broadcastMessage(unescapeString(plugin.configuration.getString("webprefix", "\u00A72[WEB] ")) + t.name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + t.message);
}
}
}