diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index 638e07a6..76eb6400 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -44,6 +44,8 @@ components: - class: org.dynmap.SimpleWebChatComponent allowchat: true + # If true, web UI users can supply name for chat using 'playername' URL parameter. 'trustclientname' must also be set true. + allowurlname: false #- class: org.dynmap.herochat.HeroWebChatComponent # # Control which HeroChat channel messages from web are directed to # herochatwebchannel: Global diff --git a/web/js/chat.js b/web/js/chat.js index 17b1031f..e789e371 100644 --- a/web/js/chat.js +++ b/web/js/chat.js @@ -17,11 +17,16 @@ componentconstructors['chat'] = function(dynmap, configuration) { } }); }); + var pname = null; + if(configuration.allowurlname) { + pname = dynmap.getParameterByName("playername"); + if(pname == "") pname = null; + } if (dynmap.options.allowwebchat) { // Accepts 'sendchat'-events to send chat messages to the server. $(dynmap).bind('sendchat', function(event, message) { - var data = '{"name":'+JSON.stringify(ip?ip:"")+',"message":'+JSON.stringify(message)+'}'; + var data = '{"name":'+JSON.stringify(pname?pname:(ip?ip:""))+',"message":'+JSON.stringify(message)+'}'; $.ajax({ type: 'POST', url: config.url.sendmessage,