diff --git a/configuration.txt b/configuration.txt index c4af0e23..44c82bf8 100644 --- a/configuration.txt +++ b/configuration.txt @@ -246,6 +246,10 @@ worlds: # title: "World" # Use 'enabled: false' to disable a certain world. # enabled: false + # Use sendposition: false to prevent player positions from showing when on this world (if sendposition is globally enabled) + # sendposition: false + # Use sendhealth: false ot prevent player health from showing when on this world (if sendhealth is globally enabled) + # sendhealth: false # # If world isn't contiguous chunks (due to teleporting, for example), fullrender needs to be given other locations to scan for tiles on each patch of chunks # fullrenderlocations: # - x: 10000 diff --git a/src/main/java/org/dynmap/ClientUpdateComponent.java b/src/main/java/org/dynmap/ClientUpdateComponent.java index 4d2f5284..97fa8210 100644 --- a/src/main/java/org/dynmap/ClientUpdateComponent.java +++ b/src/main/java/org/dynmap/ClientUpdateComponent.java @@ -41,8 +41,8 @@ public class ClientUpdateComponent extends Component { s(jp, "name", ChatColor.stripColor(p.getDisplayName())); s(jp, "account", p.getName()); /* Don't leak player location for world not visible on maps, or if sendposition disbaled */ - boolean player_visible = MapManager.mapman.worldsLookup.containsKey(p.getWorld().getName()); - if(configuration.getBoolean("sendpositon", true) && player_visible) { + DynmapWorld pworld = MapManager.mapman.worldsLookup.get(p.getWorld().getName()); + if(configuration.getBoolean("sendpositon", true) && (pworld != null) && pworld.sendposition) { s(jp, "world", p.getWorld().getName()); s(jp, "x", pl.getX()); s(jp, "y", pl.getY()); @@ -55,7 +55,7 @@ public class ClientUpdateComponent extends Component { s(jp, "z", 0.0); } /* Only send health if enabled AND we're on visible world */ - if (configuration.getBoolean("sendhealth", false) && player_visible) { + if (configuration.getBoolean("sendhealth", false) && (pworld != null) && pworld.sendhealth) { s(jp, "health", p.getHealth()); s(jp, "armor", Armor.getArmorPoints(p)); } diff --git a/src/main/java/org/dynmap/DynmapWorld.java b/src/main/java/org/dynmap/DynmapWorld.java index 170792d5..e4896392 100644 --- a/src/main/java/org/dynmap/DynmapWorld.java +++ b/src/main/java/org/dynmap/DynmapWorld.java @@ -13,4 +13,6 @@ public class DynmapWorld { public ConfigurationNode configuration; public List seedloc; public int servertime; + public boolean sendposition; + public boolean sendhealth; } diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 1a9c8cd0..c0e99199 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -295,6 +295,8 @@ public class MapManager { List loclist = worldConfiguration.getNodes("fullrenderlocations"); dynmapWorld.seedloc = new ArrayList(); dynmapWorld.servertime = (int)(w.getTime() % 24000); + dynmapWorld.sendposition = worldConfiguration.getBoolean("sendposition", true); + dynmapWorld.sendhealth = worldConfiguration.getBoolean("sendhealth", true); if(loclist != null) { for(ConfigurationNode loc : loclist) { Location lx = new Location(w, loc.getDouble("x", 0), loc.getDouble("y", 64), loc.getDouble("z", 0)); diff --git a/web/js/map.js b/web/js/map.js index 1e2583b4..4cbc3a4d 100644 --- a/web/js/map.js +++ b/web/js/map.js @@ -91,7 +91,7 @@ DynMap.prototype = { worlds: {}, registeredTiles: [], players: {}, - lasttimestamp: '0', + lasttimestamp: new Date().getUTCMilliseconds(), /* Pseudorandom - prevent cached '?0' */ servertime: 0, serverday: false, inittime: new Date().getTime(), diff --git a/web/js/playermarkers.js b/web/js/playermarkers.js index 0c7fb233..b5a96755 100644 --- a/web/js/playermarkers.js +++ b/web/js/playermarkers.js @@ -5,6 +5,9 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) { var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z); player.marker = new CustomMarker(markerPosition, dynmap.map, function(div) { var playerImage; + + player.marker.toggle(dynmap.world === player.location.world); + $(div) .addClass('Marker') .addClass('playerMarker') @@ -58,8 +61,8 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) { $(dynmap).bind('playerupdated', function(event, player) { // Update the marker. var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z); - player.marker.setPosition(markerPosition); player.marker.toggle(dynmap.world === player.location.world); + player.marker.setPosition(markerPosition); // Update health if (configuration.showplayerhealth) { if (player.health !== undefined && player.armor !== undefined) { @@ -77,7 +80,7 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) { for(name in dynmap.players) { var player = dynmap.players[name]; // Turn off marker - let update turn it back on - player.marker.toggle(false); + player.marker.hide(); } }); // Remove marker on map change - let update place it again