mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 05:05:16 +01:00
Removed redundant configuration values and made use of customizable join/quit messages.
This commit is contained in:
parent
d4a2d2d32f
commit
e1e13df4b2
@ -65,15 +65,10 @@ web:
|
||||
# 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"
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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'])}]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user