diff --git a/configuration.txt b/configuration.txt index 865f9196..e56127e9 100755 --- a/configuration.txt +++ b/configuration.txt @@ -42,6 +42,9 @@ web: # Interval the browser should poll for updates. updaterate: 2000 + # Handles the clientside updates differently only enable if using jsonfile + jsonfile: false + showchatballoons: true showplayerfacesonmap: true showplayerfacesinmenu: true diff --git a/src/main/java/org/dynmap/Client.java b/src/main/java/org/dynmap/Client.java index d27f3e0b..ae9e7036 100644 --- a/src/main/java/org/dynmap/Client.java +++ b/src/main/java/org/dynmap/Client.java @@ -27,19 +27,23 @@ public class Client { public String type = "chat"; public String playerName; public String message; + public long timestamp; - public ChatMessage(String playerName, String message) { + public ChatMessage(String playerName, String message, long timestamp) { this.playerName = playerName; this.message = message; + this.timestamp = timestamp; } } public static class Tile { public String type = "tile"; public String name; + public long timestamp; - public Tile(String name) { + public Tile(String name, long timestamp) { this.name = name; + this.timestamp = timestamp; } } } diff --git a/src/main/java/org/dynmap/DynmapPlayerListener.java b/src/main/java/org/dynmap/DynmapPlayerListener.java index 7f30456a..ddac3dc2 100644 --- a/src/main/java/org/dynmap/DynmapPlayerListener.java +++ b/src/main/java/org/dynmap/DynmapPlayerListener.java @@ -67,6 +67,6 @@ public class DynmapPlayerListener extends PlayerListener { * Relevant event details */ public void onPlayerChat(PlayerChatEvent event) { - mgr.pushUpdate(new Client.ChatMessage(event.getPlayer().getName(), event.getMessage())); + mgr.pushUpdate(new Client.ChatMessage(event.getPlayer().getName(), event.getMessage(), System.currentTimeMillis())); } } \ No newline at end of file diff --git a/src/main/java/org/dynmap/JsonTimerTask.java b/src/main/java/org/dynmap/JsonTimerTask.java index 23d3745c..99d34d4f 100644 --- a/src/main/java/org/dynmap/JsonTimerTask.java +++ b/src/main/java/org/dynmap/JsonTimerTask.java @@ -37,8 +37,6 @@ class JsonTimerTask extends TimerTask long current = System.currentTimeMillis(); Client.Update update = new Client.Update(); - update.timestamp = current; - update.servertime = world.getTime(); update.timestamp = current; update.servertime = world.getTime() % 24000; diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 4c172e1d..1bf76b16 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -159,7 +159,7 @@ public class MapManager { public boolean render(MapTile tile) { boolean result = tile.getMap().render(tile, getTileFile(tile)); - pushUpdate(tile.getWorld(), new Client.Tile(tile.getFilename())); + pushUpdate(tile.getWorld(), new Client.Tile(tile.getFilename(), System.currentTimeMillis())); return result; } diff --git a/web/map.js b/web/map.js index fc86da18..c0823464 100644 --- a/web/map.js +++ b/web/map.js @@ -221,7 +221,6 @@ DynMap.prototype = { $.getJSON(me.options.updateUrl + "world/" + me.world + "/" + me.lasttimestamp, function(update) { me.alertbox.hide(); - me.lasttimestamp = update.timestamp; me.clock.setTime(update.servertime); var typeVisibleMap = {}; @@ -243,12 +242,16 @@ DynMap.prototype = { $.each(update.updates, function(index, update) { swtch(update.type, { tile: function() { - me.onTileUpdated(update.name); + + if(me.lasttimestamp <= update.timestamp || !me.options.jsonfile) + me.onTileUpdated(update.name); }, chat: function() { if (!me.options.showchatballoons) return; - me.onPlayerChat(update.playerName, update.message); + + if(me.lasttimestamp <= update.timestamp || !me.options.jsonfile) + me.onPlayerChat(update.playerName, update.message); } }, function(type) { console.log('Unknown type ', value, '!'); @@ -265,6 +268,7 @@ DynMap.prototype = { delete me.markers[m]; } } + me.lasttimestamp = update.timestamp; setTimeout(function() { me.update(); }, me.options.updaterate); }, function(request, statusText, ex) { me.alertbox