diff --git a/configuration.txt b/configuration.txt index caba134e..a1733481 100644 --- a/configuration.txt +++ b/configuration.txt @@ -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" diff --git a/src/main/java/org/dynmap/DynmapPlayerChatListener.java b/src/main/java/org/dynmap/DynmapPlayerChatListener.java index 9e00540d..a203b9b6 100644 --- a/src/main/java/org/dynmap/DynmapPlayerChatListener.java +++ b/src/main/java/org/dynmap/DynmapPlayerChatListener.java @@ -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)); } diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index baa14d45..7ef4a096 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -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); diff --git a/src/main/java/org/dynmap/web/handlers/SendMessageHandler.java b/src/main/java/org/dynmap/web/handlers/SendMessageHandler.java index 840a6c78..ab87f2ee 100644 --- a/src/main/java/org/dynmap/web/handlers/SendMessageHandler.java +++ b/src/main/java/org/dynmap/web/handlers/SendMessageHandler.java @@ -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; } } diff --git a/web/js/chat.js b/web/js/chat.js index b10421fa..daf017e4 100644 --- a/web/js/chat.js +++ b/web/js/chat.js @@ -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'])}]); + } } }); });