Add 'fullrenderplayerlimit' - pause fullrender when number of active players reaches optional limit, resumes after

This commit is contained in:
Mike Primm 2011-12-03 13:16:15 +08:00 committed by mikeprimm
parent de6b90784f
commit 19f9733aab
2 changed files with 25 additions and 0 deletions

View File

@ -82,6 +82,8 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
boolean fencejoin = false; boolean fencejoin = false;
public CompassMode compassmode = CompassMode.PRE19; public CompassMode compassmode = CompassMode.PRE19;
private int config_hashcode; /* Used to signal need to reload web configuration (world changes, config update, etc) */ private int config_hashcode; /* Used to signal need to reload web configuration (world changes, config update, etc) */
private int fullrenderplayerlimit; /* Number of online players that will cause fullrender processing to pause */
private boolean didfullpause;
public enum CompassMode { public enum CompassMode {
PRE19, /* Default for 1.8 and earlier (east is Z+) */ PRE19, /* Default for 1.8 and earlier (east is Z+) */
@ -272,6 +274,8 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
compassmode = CompassMode.NEWROSE; compassmode = CompassMode.NEWROSE;
else else
compassmode = CompassMode.PRE19; compassmode = CompassMode.PRE19;
/* Load full render processing player limit */
fullrenderplayerlimit = configuration.getInteger("fullrenderplayerlimit", 0);
loadDebuggers(); loadDebuggers();
@ -285,9 +289,27 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
PlayerListener pl = new PlayerListener() { PlayerListener pl = new PlayerListener() {
public void onPlayerJoin(PlayerJoinEvent evt) { public void onPlayerJoin(PlayerJoinEvent evt) {
playerList.updateOnlinePlayers(null); playerList.updateOnlinePlayers(null);
if(fullrenderplayerlimit > 0) {
if((getServer().getOnlinePlayers().length+1) >= fullrenderplayerlimit) {
if(getPauseFullRadiusRenders() == false) { /* If not paused, pause it */
setPauseFullRadiusRenders(true);
Log.info("Pause full/radius renders - player limit reached");
didfullpause = true;
}
}
}
} }
public void onPlayerQuit(PlayerQuitEvent evt) { public void onPlayerQuit(PlayerQuitEvent evt) {
playerList.updateOnlinePlayers(evt.getPlayer()); playerList.updateOnlinePlayers(evt.getPlayer());
if(fullrenderplayerlimit > 0) {
if((getServer().getOnlinePlayers().length-1) < fullrenderplayerlimit) {
if(didfullpause) { /* Only unpause if we did the pause */
setPauseFullRadiusRenders(false);
Log.info("Resume full/radius renders - below player limit");
didfullpause = false;
}
}
}
} }
}; };
registerEvent(Type.PLAYER_JOIN, pl); registerEvent(Type.PLAYER_JOIN, pl);

View File

@ -223,6 +223,9 @@ progressloginterval: 100
# Interval the browser should poll for updates. # Interval the browser should poll for updates.
updaterate: 2000 updaterate: 2000
# If nonzero, server will pause fullrender/radiusrender processing when 'fullrenderplayerlimit' or more user's are logged in
fullrenderplayerlimit: 0
showplayerfacesinmenu: true showplayerfacesinmenu: true
# Set sidebaropened: 'true' to pin menu sidebar opened permanently, 'pinned' to default the sidebar to pinned, but allow it to unpin # Set sidebaropened: 'true' to pin menu sidebar opened permanently, 'pinned' to default the sidebar to pinned, but allow it to unpin