added "unqueued" counter, currently unused

This commit is contained in:
BuildTools 2016-11-28 17:48:48 -05:00
parent 845a0e56e5
commit 2e07dcbb1a
4 changed files with 29 additions and 29 deletions

View file

@ -5,11 +5,10 @@ import org.bukkit.configuration.file.FileConfiguration;
public class ConfigProcess implements Runnable { public class ConfigProcess implements Runnable {
static Main plugin; //initialized in Main onEnable()
static FileConfiguration config;//
final String name;
//================================STATIC================================ //================================STATIC================================
static Main plugin;
static FileConfiguration config;
//----------------------------------------------------------------------
static final boolean isNew(String name) static final boolean isNew(String name)
{ {
return !config.contains(name); return !config.contains(name);
@ -53,6 +52,8 @@ public class ConfigProcess implements Runnable {
} }
//===============================INSTANCE=============================== //===============================INSTANCE===============================
final String name;
//----------------------------------------------------------------------
ConfigProcess(String name) ConfigProcess(String name)
{ {
this.name = name; this.name = name;

View file

@ -10,6 +10,7 @@ public class LoadProcess implements Runnable
private final World world; private final World world;
final int totalRegions; final int totalRegions;
int[] currentRegion; int[] currentRegion;
LoadProcess(String name, WorldObj newWorld) LoadProcess(String name, WorldObj newWorld)
{ {
ConfigProcess.addNew(name, newWorld); ConfigProcess.addNew(name, newWorld);
@ -18,6 +19,7 @@ public class LoadProcess implements Runnable
totalRegions = newWorld.total; totalRegions = newWorld.total;
currentRegion = newWorld.current; currentRegion = newWorld.current;
} }
LoadProcess(String name) LoadProcess(String name)
{ {
final WorldObj unfinished = ConfigProcess.getUnfinished(name); final WorldObj unfinished = ConfigProcess.getUnfinished(name);
@ -62,7 +64,6 @@ public class LoadProcess implements Runnable
private final boolean setNextRegion() private final boolean setNextRegion()
{ {
if (n == totalRegions) return false; if (n == totalRegions) return false;
if (d == D) if (d == D)
{ {
@ -85,23 +86,30 @@ public class LoadProcess implements Runnable
//==============================GET CHUNKS============================== //==============================GET CHUNKS==============================
private final int[][][] getChunksCurrentRegion() private final int[][][] getChunksCurrentRegion()
{ {
final int[][][] chunks = new int[32][32][2]; final int[][][] chunks = new int[32][32][2];
int xR = currentRegion[0] * 32;
int zR = currentRegion[1] * 32;
int z; int z;
for (int x = 0; x < 32; x++) for (int x = 0; x < 32; x++)
{ {
z = 0; z = 0;
for (; z < 32; z++) for (; z < 32; z++)
{ {
chunks[x][z][0] = (currentRegion[0] * 32) + x; chunks[x][z][0] = xR + x;
chunks[x][z][1] = (currentRegion[1] * 32) + z; chunks[x][z][1] = zR + z;
} }
} }
return chunks; return chunks;
} }
//==================================RUN================================= //==================================RUN=================================
private static volatile boolean ready = true; private static volatile boolean ready = true;
private volatile int unqueued = 0;
public final void run() public final void run()
{ {
if (!ready) return; if (!ready) return;
@ -113,7 +121,7 @@ public class LoadProcess implements Runnable
for (int[] chunk : xRow) for (int[] chunk : xRow)
{ {
world.loadChunk(chunk[0], chunk[1], true); world.loadChunk(chunk[0], chunk[1], true);
world.unloadChunkRequest(chunk[0], chunk[1]); if (!world.unloadChunkRequest(chunk[0], chunk[1])) unqueued++;
} }
} }
if (!setNextRegion()) if (!setNextRegion())

View file

@ -9,10 +9,10 @@ import org.bukkit.scheduler.BukkitTask;
public class TaskManager { public class TaskManager {
static boolean inProgress = false; private static boolean inProgress = false;
static LoadProcess loadProcess; static LoadProcess loadProcess;
static ConfigProcess configProcess; private static ConfigProcess configProcess;
private static BukkitTask loadTask; private static BukkitTask loadTask;
private static BukkitTask configTask; private static BukkitTask configTask;
@ -22,7 +22,7 @@ public class TaskManager {
private static final void schedule(long delay) private static final void schedule(long delay)
{ {
loadTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, loadProcess, delay, 100); loadTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, loadProcess, delay, 100);
configTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, loadProcess, delay, 100); configTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, configProcess, delay, 200);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
private static final boolean start(String[] args, String name) private static final boolean start(String[] args, String name)
@ -50,7 +50,7 @@ public class TaskManager {
} }
return false; return false;
} }
static final void stop_or_finish() private static final void stop_or_finish()
{ {
loadTask.cancel(); loadTask.cancel();
configTask.cancel(); configTask.cancel();
@ -65,25 +65,17 @@ public class TaskManager {
static final void finish() static final void finish()
{ {
configProcess.finish(); configProcess.finish();
stop_or_finish();
} }
static final boolean stop() private static final boolean stop()
{ {
if (inProgress) if (inProgress)
{ {
if (loadProcess.n == loadProcess.totalRegions) finish(); if (loadProcess.n == loadProcess.totalRegions) finish();
else else
{ {
loadTask.cancel();
configTask.cancel();
configProcess.stop(); configProcess.stop();
stop_or_finish();
loadProcess = null;
configProcess = null;
loadTask = null;
configTask = null;
inProgress = false;
} }
return true; return true;
} }

View file

@ -12,7 +12,7 @@ public class WorldObj {
WorldObj() WorldObj()
{ {
total = 1936; //44 * 44 total = 1936;//(44*44)
current = new int[] { -1, -1 }; current = new int[] { -1, -1 };
} }
WorldObj(int total, int[] center) WorldObj(int total, int[] center)
@ -57,7 +57,7 @@ public class WorldObj {
* * * * * * * * * *
* *
* the spiral pattern used in LoadProcess rotates * the spiral pattern used in LoadProcess rotates
* counter-clockwise, so it must begin at minimum * east north west south, so it must begin at minimum
* center. * center.
*/ */
} }
@ -118,7 +118,6 @@ public class WorldObj {
Math.floorDiv( a.center[1] + a.radius, 512 ) Math.floorDiv( a.center[1] + a.radius, 512 )
}; };
//add margins--------------------------------------------------------------- //add margins---------------------------------------------------------------
final int[] edges = new int[4]; final int[] edges = new int[4];
final int[] radii = new int[4]; final int[] radii = new int[4];
final boolean[] margin = new boolean[4]; final boolean[] margin = new boolean[4];