Merge pull request #316 from mikeprimm/master

Add escape sequence '&color;' support for webprefix/websuffix - avoid frequent editor code page problems
This commit is contained in:
mikeprimm 2011-07-24 18:32:45 -07:00
commit 4cacc3f92c
4 changed files with 14 additions and 5 deletions

View File

@ -10,4 +10,12 @@ public abstract class Component {
public void dispose() { 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); DynmapWebChatEvent evt = new DynmapWebChatEvent(t.source, t.name, t.message);
plugin.getServer().getPluginManager().callEvent(evt); plugin.getServer().getPluginManager().callEvent(evt);
if(evt.isCancelled() == false) 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) { if(evt.isCancelled() == false) {
/* Let HeroChat take a look - only broadcast to players if it doesn't handle it */ /* Let HeroChat take a look - only broadcast to players if it doesn't handle it */
if (!handler.sendWebMessageToHeroChat(t.name, t.message)) { 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);
} }
} }
} }

View File

@ -139,8 +139,9 @@ showplayerfacesinmenu: true
joinmessage: "%playername% joined" joinmessage: "%playername% joined"
quitmessage: "%playername% quit" quitmessage: "%playername% quit"
spammessage: "You may only chat once every %interval% seconds." spammessage: "You may only chat once every %interval% seconds."
webprefix: "§2[WEB] " # webprefix and websuffix support using '&color;' as escape code for color code
websuffix: "§f" webprefix: "&color;2[WEB] "
websuffix: "&color;f"
# Enable checking for banned IPs via banned-ips.txt (internal web server only) # Enable checking for banned IPs via banned-ips.txt (internal web server only)
check-banned-ips: true check-banned-ips: true
@ -149,7 +150,7 @@ defaultworld: world
# Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to true to enable verbose startup messages - can help with debugging map configuration problems
# Set to false for a much quieter startup log # Set to false for a much quieter startup log
verbose: true verbose: false
# Enables debugging. # Enables debugging.
#debuggers: #debuggers: