fixed the resume bug

This commit is contained in:
BuildTools 2016-12-06 20:20:47 -05:00
parent 42a38642c0
commit 0af18cbe58
3 changed files with 20 additions and 23 deletions

View file

@ -15,13 +15,12 @@ public class ConfigProcess implements Runnable {
}
static final void addNew(String name, WorldObj newWorld)
{
Bukkit.getLogger().info("config: addNew(" + name + ")");
config.set(name + ".total", newWorld.total);
config.set(name + ".currentRegion.x", newWorld.current[0]);
config.set(name + ".currentRegion.z", newWorld.current[1]);
config.set(name + ".n", 1);
config.set(name + ".c", 1);
config.set(name + ".D", 1);
config.set(name + ".s", 1);
config.set(name + ".d", 0);
config.set(name + ".B", false);
plugin.saveConfig();
@ -38,7 +37,7 @@ public class ConfigProcess implements Runnable {
},
config.getInt(name + ".n"),
config.getInt(name + ".c"),
config.getInt(name + ".D"),
config.getInt(name + ".s"),
config.getInt(name + ".d"),
config.getBoolean(name + ".B")
);
@ -66,7 +65,7 @@ public class ConfigProcess implements Runnable {
config.set(name + ".currentRegion.z", TaskManager.loadProcess.currentRegion[1]);
config.set(name + ".n", TaskManager.loadProcess.n);
config.set(name + ".c", TaskManager.loadProcess.c);
config.set(name + ".D", TaskManager.loadProcess.D);
config.set(name + ".s", TaskManager.loadProcess.s);
config.set(name + ".d", TaskManager.loadProcess.d);
config.set(name + ".B", TaskManager.loadProcess.B);
plugin.saveConfig();

View file

@ -14,7 +14,7 @@ public class LoadProcess implements Runnable
//see setNextRegion()
int n;
int c;
int D;
int s;
int d;
boolean B;
@ -23,14 +23,9 @@ public class LoadProcess implements Runnable
LoadProcess(String name) //resume from stored
{
Bukkit.getLogger().info("resuming stored world-load process");
WorldObj unfinishedworld = ConfigProcess.getUnfinished(name);
Bukkit.getLogger().info("resuming stored world-load process "
+ unfinishedworld.n + " "
+ unfinishedworld.c + " "
+ unfinishedworld.D + " "
+ unfinishedworld.d + " "
+ unfinishedworld.B
);
world = Bukkit.getWorld(name);
totalRegions = unfinishedworld.total;
@ -38,7 +33,7 @@ public class LoadProcess implements Runnable
n = unfinishedworld.n;
c = unfinishedworld.c;
D = unfinishedworld.D;
s = unfinishedworld.s;
d = unfinishedworld.d;
B = unfinishedworld.B;
}
@ -54,7 +49,7 @@ public class LoadProcess implements Runnable
n = 1;
c = 1;
D = 1;
s = 1;
d = 0;
B = false;
}
@ -102,18 +97,18 @@ public class LoadProcess implements Runnable
*
* n how many regions have been saved already
* c direction of travel: E,N,W,S - 1,2,3,4
* D distance to travel (side-length)
* d distance already traveled
* s side: distance to travel (side-length)
* d side: distance already traveled
* B OK to increase distance?
*/
private final boolean setNextRegion()
{
if (n == totalRegions) return false;
if (d == D)
if (d == s)
{
d = 1;
if (B) D++;
if (B) s++;
B = !B;
c = c == 4 ? 1 : c + 1;
}

View file

@ -9,7 +9,7 @@ public class WorldObj {
int[] current;
int n;
int c;
int D;
int s;
int d;
boolean B;
@ -24,20 +24,23 @@ public class WorldObj {
this.current = center;
}
WorldObj(int total, int[] current,
int n, int c, int D, int d, boolean B)
int n, int c, int s, int d, boolean B)
{
this.total = total;
this.current = current;
this.n = n;
this.c = c;
this.D = D;
this.D = d;
this.s = s;
this.d = d;
this.B = B;
}
static final WorldObj generate(String[] args)
{
if (args.length == 0) return new WorldObj();
if (args.length == 0)
{
return new WorldObj();
}
int[] bounds = regionBounds(new ParsedArgs(args));