Add '/dynmap pause' command to pause/unpause full/radius and update rendering

This commit is contained in:
Mike Primm 2011-12-03 06:19:55 +08:00 committed by mikeprimm
parent 8f6982265a
commit de6b90784f
3 changed files with 104 additions and 1 deletions

View File

@ -220,7 +220,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
if (permissions == null)
permissions = BukkitPermissions.create("dynmap");
if (permissions == null)
permissions = new OpPermissions(new String[] { "fullrender", "cancelrender", "radiusrender", "resetstats", "reload", "purgequeue" });
permissions = new OpPermissions(new String[] { "fullrender", "cancelrender", "radiusrender", "resetstats", "reload", "purgequeue", "pause" });
dataDirectory = this.getDataFolder();
if(dataDirectory.exists() == false)
@ -742,6 +742,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
"triggerstats",
"resetstats",
"sendtoweb",
"pause",
"purgequeue" }));
@Override
@ -877,6 +878,33 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
mapManager.printStats(sender, args[1]);
} else if (c.equals("triggerstats") && checkPlayerPermission(sender, "stats")) {
mapManager.printTriggerStats(sender);
} else if (c.equals("pause") && checkPlayerPermission(sender, "pause")) {
if(args.length == 1) {
}
else if(args[1].equals("full")) {
setPauseFullRadiusRenders(true);
setPauseUpdateRenders(false);
}
else if(args[1].equals("update")) {
setPauseFullRadiusRenders(false);
setPauseUpdateRenders(true);
}
else if(args[1].equals("all")) {
setPauseFullRadiusRenders(true);
setPauseUpdateRenders(true);
}
else {
setPauseFullRadiusRenders(false);
setPauseUpdateRenders(false);
}
if(getPauseFullRadiusRenders())
sender.sendMessage("Full/Radius renders are PAUSED");
else
sender.sendMessage("Full/Radius renders are ACTIVE");
if(getPauseUpdateRenders())
sender.sendMessage("Update renders are PAUSED");
else
sender.sendMessage("Update renders are ACTIVE");
} else if (c.equals("resetstats") && checkPlayerPermission(sender, "resetstats")) {
if(args.length == 1)
mapManager.resetStats(sender, null);
@ -1352,4 +1380,30 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
public void registerMarkerAPI(MarkerAPIImpl api) {
markerapi = api;
}
/*
* Pause full/radius render processing
* @param dopause - true to pause, false to unpause
*/
public void setPauseFullRadiusRenders(boolean dopause) {
mapManager.setPauseFullRadiusRenders(dopause);
}
/*
* Test if full renders are paused
*/
public boolean getPauseFullRadiusRenders() {
return mapManager.getPauseFullRadiusRenders();
}
/*
* Pause update render processing
* @param dopause - true to pause, false to unpause
*/
public void setPauseUpdateRenders(boolean dopause) {
mapManager.setPauseUpdateRenders(dopause);
}
/*
* Test if update renders are paused
*/
public boolean getPauseUpdateRenders() {
return mapManager.getPauseUpdateRenders();
}
}

View File

@ -50,6 +50,9 @@ public class MapManager {
private boolean saverestorepending = true;
private boolean hideores = false;
private boolean pauseupdaterenders = false;
private boolean pausefullrenders = false;
private int zoomout_period = DEFAULT_ZOOMOUT_PERIOD; /* Zoom-out tile processing period, in seconds */
/* Which fullrenders are active */
private HashMap<String, FullWorldRenderState> active_renders = new HashMap<String, FullWorldRenderState>();
@ -349,6 +352,10 @@ public class MapManager {
return;
}
if(tile0 == null) { /* Not single tile render */
if(pausefullrenders) { /* Update renders are paused? */
scheduleDelayedJob(this, 20*5); /* Delay 5 seconds and retry */
return;
}
/* If render queue is empty, start next map */
if(renderQueue.isEmpty()) {
if(map_index >= 0) { /* Finished a map? */
@ -449,6 +456,10 @@ public class MapManager {
}
}
else { /* Else, single tile render */
if(pauseupdaterenders) {
scheduleDelayedJob(this, 5*20); /* Retry after 5 seconds */
return;
}
tile = tile0;
}
World w = world.world;
@ -1296,4 +1307,36 @@ public class MapManager {
}
return id;
}
/*
* Pause full/radius render processing
* @param dopause - true to pause, false to unpause
*/
void setPauseFullRadiusRenders(boolean dopause) {
if(dopause != pausefullrenders) {
pausefullrenders = dopause;
Log.info("Full/radius render pause set to " + dopause);
}
}
/*
* Test if full renders are paused
*/
boolean getPauseFullRadiusRenders() {
return pausefullrenders;
}
/*
* Pause update render processing
* @param dopause - true to pause, false to unpause
*/
void setPauseUpdateRenders(boolean dopause) {
if(dopause != pauseupdaterenders) {
pauseupdaterenders = dopause;
Log.info("Update render pause set to " + dopause);
}
}
/*
* Test if update renders are paused
*/
boolean getPauseUpdateRenders() {
return pauseupdaterenders;
}
}

View File

@ -26,6 +26,8 @@ commands:
/<command> resetstats world - Reset render statistics for maps on world 'world'.
/<command> sendtoweb msg - Send message to web users
/<command> purgequeue - Set tile update queue to empty
/<command> pause - Show render pause state
/<command> pause <all|none|full|update> - Set render pause state
dmarker:
description: Manipulate map markers
@ -79,6 +81,7 @@ permissions:
dynmap.resetstats: true
dynmap.sendtoweb: true
dynmap.purgequeue: true
dynmap.pause: true
dynmap.marker.add: true
dynmap.marker.update: true
dynmap.marker.movehere: true
@ -136,6 +139,9 @@ permissions:
dynmap.purgequeue:
description: Allows /dynmap purgequeue
default: op
dynmap.pause:
description: Allows /dynmap pause
default: op
dynmap.marker.add:
description: Allows /dmarker add
default: op