From 38163133cbe733e6e43e2ef9366e1c1ef0276e08 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 3 Jun 2011 08:42:24 -0500 Subject: [PATCH 1/3] Have per-world control of sending player position and health, prevent player icon flicker on addplayer (even when not on world or position is obfuscated) --- configuration.txt | 4 ++++ src/main/java/org/dynmap/ClientUpdateComponent.java | 6 +++--- src/main/java/org/dynmap/DynmapWorld.java | 2 ++ src/main/java/org/dynmap/MapManager.java | 2 ++ web/js/map.js | 2 +- web/js/playermarkers.js | 7 +++++-- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/configuration.txt b/configuration.txt index c4af0e23..d73676eb 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) + # sendpositon: 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..40c7c16c 100644 --- a/web/js/playermarkers.js +++ b/web/js/playermarkers.js @@ -2,7 +2,9 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) { var me = this; $(dynmap).bind('playeradded', function(event, player) { // Create the player-marker. - var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z); + var markerPosition = null; + if(dynmap.world === player.location.world) + 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; $(div) @@ -50,6 +52,7 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) { } } }); + }); $(dynmap).bind('playerremoved', function(event, player) { // Remove the marker. @@ -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) { From 867c31573eb91c1531aeebeca0cda9ac89b60225 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 3 Jun 2011 09:51:41 -0500 Subject: [PATCH 2/3] Remove icon position flicker on first load/player add --- web/js/playermarkers.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/js/playermarkers.js b/web/js/playermarkers.js index 40c7c16c..b5a96755 100644 --- a/web/js/playermarkers.js +++ b/web/js/playermarkers.js @@ -2,11 +2,12 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) { var me = this; $(dynmap).bind('playeradded', function(event, player) { // Create the player-marker. - var markerPosition = null; - if(dynmap.world === player.location.world) - markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z); + 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') @@ -52,7 +53,6 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) { } } }); - }); $(dynmap).bind('playerremoved', function(event, player) { // Remove the marker. @@ -80,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 From d54d26db69bce11314789bd94ef884ae242d2c72 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 3 Jun 2011 09:52:26 -0500 Subject: [PATCH 3/3] Fix typo in example --- configuration.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.txt b/configuration.txt index d73676eb..44c82bf8 100644 --- a/configuration.txt +++ b/configuration.txt @@ -247,7 +247,7 @@ worlds: # 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) - # sendpositon: false + # 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