Add 'webmsgformat' setting, deprecate 'webprefix' and 'websuffix'

This commit is contained in:
Mike Primm 2011-11-06 12:02:50 +08:00 committed by mikeprimm
parent 957f6a8dce
commit 8be7e8f68a
3 changed files with 28 additions and 6 deletions

View File

@ -18,8 +18,18 @@ public class SimpleWebChatComponent extends Component {
public void triggered(ChatEvent t) {
DynmapWebChatEvent evt = new DynmapWebChatEvent(t.source, t.name, t.message);
plugin.getServer().getPluginManager().callEvent(evt);
if(evt.isCancelled() == false)
plugin.getServer().broadcastMessage(unescapeString(plugin.configuration.getString("webprefix", "\u00A72[WEB] ")) + t.name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + t.message);
if(evt.isCancelled() == false) {
String msg;
String msgfmt = plugin.configuration.getString("webmsgformat", null);
if(msgfmt != null) {
msgfmt = unescapeString(msgfmt);
msg = msgfmt.replaceAll("%playername%", t.name).replaceAll("%message%", t.message);
}
else {
msg = unescapeString(plugin.configuration.getString("webprefix", "\u00A72[WEB] ")) + t.name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + t.message;
}
plugin.getServer().broadcastMessage(msg);
}
}
});

View File

@ -28,7 +28,16 @@ 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(unescapeString(plugin.configuration.getString("webprefix", "\u00A72[WEB] ")) + t.name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + t.message);
String msg;
String msgfmt = plugin.configuration.getString("webmsgformat", null);
if(msgfmt != null) {
msgfmt = unescapeString(msgfmt);
msg = msgfmt.replaceAll("%playername%", t.name).replaceAll("%message%", t.message);
}
else {
msg = unescapeString(plugin.configuration.getString("webprefix", "\u00A72[WEB] ")) + t.name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + t.message;
}
plugin.getServer().broadcastMessage(msg);
}
}
}

View File

@ -355,9 +355,12 @@ showplayerfacesinmenu: true
joinmessage: "%playername% joined"
quitmessage: "%playername% quit"
spammessage: "You may only chat once every %interval% seconds."
# webprefix and websuffix support using '&color;' as escape code for color code
webprefix: "&color;2[WEB] "
websuffix: "&color;f"
# webprefix and websuffix support using '&color;' as escape code for color code (deprecated: use webmsgformat)
#webprefix: "&color;2[WEB] "
#websuffix: "&color;f"
# format for messages from web: %playername% substitutes sender ID (typically IP), %message% includes text
webmsgformat: "&color;2[WEB] %playername%: &color;f%message%"
# Enable checking for banned IPs via banned-ips.txt (internal web server only)
check-banned-ips: true