From a743524318dffb5fdeaf889570a24cca9f8eab07 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 30 Dec 2011 16:02:27 +0800 Subject: [PATCH] Reconnect active command output to player after restart, logoff/logon --- src/main/java/org/dynmap/DynmapPlugin.java | 3 +++ src/main/java/org/dynmap/MapManager.java | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index a9c1e11e..bab867d7 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -328,6 +328,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI { } ids.addFirst(pid); /* Put us first on list */ } + /* And re-attach to active jobs */ + if(mapManager != null) + mapManager.connectTasksToPlayer(p); } public void onPlayerQuit(PlayerQuitEvent evt) { playerList.updateOnlinePlayers(evt.getPlayer()); diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 764a0661..bb40b4a8 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -26,6 +26,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import org.dynmap.DynmapPlugin.CompassMode; import org.dynmap.DynmapWorld.AutoGenerateOption; import org.dynmap.debug.Debug; @@ -193,6 +194,7 @@ public class MapManager { MapTile tile0 = null; int rendercnt = 0; CommandSender sender; + String player; long timeaccum; HashSet renderedmaps = new HashSet(); String activemaps; @@ -225,6 +227,10 @@ public class MapManager { rendered = new TileFlags(); renderQueue = new LinkedList(); this.sender = sender; + if(sender instanceof Player) + this.player = ((Player)sender).getName(); + else + this.player = ""; if(radius < 0) { cxmin = czmin = Integer.MIN_VALUE; cxmax = czmax = Integer.MAX_VALUE; @@ -301,8 +307,12 @@ public class MapManager { czmax = n.getInteger("czmax", 0); rendertype = n.getString("rendertype", ""); mapname = n.getString("mapname", null); + player = n.getString("player", ""); updaterender = rendertype.equals(RENDERTYPE_UPDATERENDER); sender = null; + if(player.length() > 0) { + sender = plug_in.getServer().getPlayerExact(player); + } } public HashMap saveState() { @@ -339,7 +349,7 @@ public class MapManager { v.put("rendertype", rendertype); if(mapname != null) v.put("mapname", mapname); - + v.put("player", player); return v; } @@ -1378,5 +1388,13 @@ public class MapManager { public void incExtraTickList() { ticklistcalls.incrementAndGet(); } - + /* Connect any jobs tied to this player back to the player (resumes output to player) */ + void connectTasksToPlayer(Player p) { + String pn = p.getName(); + for(FullWorldRenderState job : active_renders.values()) { + if(pn.equals(job.player)) { + job.sender = p; + } + } + } }