Removed redundant configuration values and made use of customizable join/quit messages.

This commit is contained in:
FrozenCow 2011-04-05 22:30:43 +02:00
parent d4a2d2d32f
commit e1e13df4b2
5 changed files with 14 additions and 26 deletions

View File

@ -61,19 +61,14 @@ worlds:
web:
# Handles the clientside updates differently only enable if using jsonfile
jsonfile: false
# Interval the browser should poll for updates.
updaterate: 2000
showchatballoons: false
focuschatballoons: false
showchatwindow: true
allowchat: true
allowwebchat: true
webchat-interval: 5
messagettl: 15
showplayerfacesonmap: true
showplayerfacesinmenu: true
joinmessage: "%playername% joined"

View File

@ -20,14 +20,14 @@ public class DynmapPlayerChatListener extends PlayerListener {
@Override
public void onPlayerJoin(PlayerJoinEvent event) {
String joinMessage = plugin.configuration.getString("joinmessage", "%playername% joined");
String joinMessage = plugin.configuration.getNode("web").getString("joinmessage", "%playername% joined");
joinMessage = joinMessage.replaceAll("%playername%", event.getPlayer().getName());
plugin.mapManager.pushUpdate(new Client.ChatMessage("Server", joinMessage));
}
@Override
public void onPlayerQuit(PlayerQuitEvent event) {
String quitMessage = plugin.configuration.getString("quitmessage", "%playername% quit");
String quitMessage = plugin.configuration.getNode("web").getString("quitmessage", "%playername% quit");
quitMessage = quitMessage.replaceAll("%playername%", event.getPlayer().getName());
plugin.mapManager.pushUpdate(new Client.ChatMessage("Server", quitMessage));
}

View File

@ -235,7 +235,7 @@ public class DynmapPlugin extends JavaPlugin {
}
// To announce when players have joined/quit/chatted.
if (configuration.getNode("web").getBoolean("showchatballoons", false) || configuration.getNode("web").getBoolean("showchatwindow", false)) {
if (configuration.getNode("web").getBoolean("allowchat", false)) {
// To handle webchat.
PlayerListener playerListener = new DynmapPlayerChatListener(this);
//getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);

View File

@ -67,21 +67,9 @@ public class SendMessageHandler implements HttpHandler {
disallowedUsers.put(user.name, user);
disallowedUserQueue.add(user);
} else {
spamMessage = spamMessage.replaceAll("%interval%", Integer.toString(maximumMessageInterval/1000));
byte[] stringBytes = spamMessage.getBytes();
String dateStr = new Date().toString();
response.fields.put("Date", dateStr);
response.fields.put("Content-Type", "text/plain");
response.fields.put("Expires", "Thu, 01 Dec 1994 16:00:00 GMT");
response.fields.put("Last-modified", dateStr);
response.fields.put("Content-Length", Integer.toString(stringBytes.length));
response.status = HttpStatus.OK;
BufferedOutputStream out = null;
out = new BufferedOutputStream(response.getBody());
out.write(stringBytes);
out.flush();
response.fields.put("Content-Length", "0");
response.status = HttpStatus.Forbidden;
response.getBody();
return;
}
}

View File

@ -34,6 +34,11 @@ componentconstructors['chat'] = function(dynmap, configuration) {
if(response) {
$(dynmap).trigger('chat', [{source: 'me', name: ip, text: message}]);
}
},
error: function(xhr) {
if (xhr.status === 403) {
$(dynmap).trigger('chat', [{source: 'me', name: 'Error', text: dynmap.options.spammessage.replace('%interval%', dynmap.options['webchat-interval'])}]);
}
}
});
});