diff --git a/configuration.txt b/configuration.txt old mode 100755 new mode 100644 index 10d54410..7bd144ae --- a/configuration.txt +++ b/configuration.txt @@ -69,6 +69,7 @@ web: # showchat: modal/balloons showchat: modal + allowchat: true messagettl: 15000 showplayerfacesonmap: true diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index 8ac9f555..9805c370 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -132,15 +132,18 @@ public class DynmapPlugin extends JavaPlugin { webServer.handlers.put("/up/configuration", new ClientConfigurationHandler((Map) configuration.getProperty("web"))); SendMessageHandler messageHandler = new SendMessageHandler(); - messageHandler.onMessageReceived.addListener(new Listener() { - @Override - public void triggered(Message t) { - mapManager.pushUpdate(new Client.WebChatMessage(t.name, t.message)); - log.info("[WEB]" + t.name + ": " + t.message); - getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message); - } - }); - webServer.handlers.put("/up/sendmessage", messageHandler); + boolean allowchat = configuration.getBoolean("allowchat", true); + if (allowchat == true) { + messageHandler.onMessageReceived.addListener(new Listener() { + @Override + public void triggered(Message t) { + mapManager.pushUpdate(new Client.WebChatMessage(t.name, t.message)); + log.info("[WEB]" + t.name + ": " + t.message); + getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message); + } + }); + webServer.handlers.put("/up/sendmessage", messageHandler); + } try { webServer.startServer(); diff --git a/web/map.js b/web/map.js index 326bf977..cce76d9e 100644 --- a/web/map.js +++ b/web/map.js @@ -202,21 +202,23 @@ DynMap.prototype = { var messagelist = me.messagelist = $('
') .addClass('messagelist') .appendTo(chat); - var chatinput = me.chatinput = $('') - .addClass('chatinput') - .attr({ - id: 'chatinput', - type: 'text', - value: '' - }) - .keydown(function(event) { - if (event.keyCode == '13') { - event.preventDefault(); - sendChat(chatinput.val()); - chatinput.val(''); - } - }) - .appendTo(chat); + if (me.options.allowchat === 'true') { + var chatinput = me.chatinput = $('') + .addClass('chatinput') + .attr({ + id: 'chatinput', + type: 'text', + value: '' + }) + .keydown(function(event) { + if (event.keyCode == '13') { + event.preventDefault(); + sendChat(chatinput.val()); + chatinput.val(''); + } + }) + .appendTo(chat); + } } // TODO: Enable hash-links.