Improved fill progress saving & restoring
+ Added fill progress save to autosave, to avoid lost progress on hard-crashes + Prevented fill progress from being deleted except when properly finished or terminated. + In case fill progress is saved, but world is not loaded yet when config is loaded, running /wb reload should now resume filling if the world is loaded then. + Updated restoreprogress default values to match the current defaults.
This commit is contained in:
parent
0d45093fa6
commit
c1d99e560c
|
@ -489,10 +489,10 @@ public class Config
|
||||||
logConfig("Border-checking timed task stopped.");
|
logConfig("Border-checking timed task stopped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StopFillTask()
|
public static void StopFillTask(boolean SaveFill)
|
||||||
{
|
{
|
||||||
if (fillTask != null && fillTask.valid())
|
if (fillTask != null && fillTask.valid())
|
||||||
fillTask.cancel();
|
fillTask.cancel(SaveFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StoreFillTask()
|
public static void StoreFillTask()
|
||||||
|
@ -682,16 +682,15 @@ public class Config
|
||||||
if (storedFillTask != null)
|
if (storedFillTask != null)
|
||||||
{
|
{
|
||||||
String worldName = storedFillTask.getString("world");
|
String worldName = storedFillTask.getString("world");
|
||||||
int fillDistance = storedFillTask.getInt("fillDistance", 176);
|
int fillDistance = storedFillTask.getInt("fillDistance", 208);
|
||||||
int chunksPerRun = storedFillTask.getInt("chunksPerRun", 5);
|
int chunksPerRun = storedFillTask.getInt("chunksPerRun", 1);
|
||||||
int tickFrequency = storedFillTask.getInt("tickFrequency", 20);
|
int tickFrequency = storedFillTask.getInt("tickFrequency", 1);
|
||||||
int fillX = storedFillTask.getInt("x", 0);
|
int fillX = storedFillTask.getInt("x", 0);
|
||||||
int fillZ = storedFillTask.getInt("z", 0);
|
int fillZ = storedFillTask.getInt("z", 0);
|
||||||
int fillLength = storedFillTask.getInt("length", 0);
|
int fillLength = storedFillTask.getInt("length", 0);
|
||||||
int fillTotal = storedFillTask.getInt("total", 0);
|
int fillTotal = storedFillTask.getInt("total", 0);
|
||||||
boolean forceLoad = storedFillTask.getBoolean("forceLoad", false);
|
boolean forceLoad = storedFillTask.getBoolean("forceLoad", false);
|
||||||
RestoreFillTask(worldName, fillDistance, chunksPerRun, tickFrequency, fillX, fillZ, fillLength, fillTotal, forceLoad);
|
RestoreFillTask(worldName, fillDistance, chunksPerRun, tickFrequency, fillX, fillZ, fillLength, fillTotal, forceLoad);
|
||||||
save(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logIt)
|
if (logIt)
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class WorldBorder extends JavaPlugin
|
||||||
DynMapFeatures.removeAllBorders();
|
DynMapFeatures.removeAllBorders();
|
||||||
Config.StopBorderTimer();
|
Config.StopBorderTimer();
|
||||||
Config.StoreFillTask();
|
Config.StoreFillTask();
|
||||||
Config.StopFillTask();
|
Config.StopFillTask(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for other plugins to hook into
|
// for other plugins to hook into
|
||||||
|
|
|
@ -120,7 +120,8 @@ public class WorldFillTask implements Runnable
|
||||||
sendMessage("You must specify a world!");
|
sendMessage("You must specify a world!");
|
||||||
else
|
else
|
||||||
sendMessage("World \"" + worldName + "\" not found!");
|
sendMessage("World \"" + worldName + "\" not found!");
|
||||||
this.stop();
|
//In case world is not loaded yet, do not delete saved progress
|
||||||
|
this.stop(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ public class WorldFillTask implements Runnable
|
||||||
if (this.border == null)
|
if (this.border == null)
|
||||||
{
|
{
|
||||||
sendMessage("No border found for world \"" + worldName + "\"!");
|
sendMessage("No border found for world \"" + worldName + "\"!");
|
||||||
this.stop();
|
this.stop(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ public class WorldFillTask implements Runnable
|
||||||
worldData = WorldFileData.create(world, notifyPlayer);
|
worldData = WorldFileData.create(world, notifyPlayer);
|
||||||
if (worldData == null)
|
if (worldData == null)
|
||||||
{
|
{
|
||||||
this.stop();
|
this.stop(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ public class WorldFillTask implements Runnable
|
||||||
|
|
||||||
public void setTaskID(int ID)
|
public void setTaskID(int ID)
|
||||||
{
|
{
|
||||||
if (ID == -1) this.stop();
|
if (ID == -1) this.stop(false);
|
||||||
this.taskID = ID;
|
this.taskID = ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +357,9 @@ public class WorldFillTask implements Runnable
|
||||||
lastLegX = x;
|
lastLegX = x;
|
||||||
lastLegZ = z;
|
lastLegZ = z;
|
||||||
lastLegTotal = reportTotal + reportNum;
|
lastLegTotal = reportTotal + reportNum;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
refX = lastLegX;
|
refX = lastLegX;
|
||||||
refZ = lastLegZ;
|
refZ = lastLegZ;
|
||||||
refTotal = lastLegTotal;
|
refTotal = lastLegTotal;
|
||||||
|
@ -422,18 +425,22 @@ public class WorldFillTask implements Runnable
|
||||||
world.save();
|
world.save();
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new WorldBorderFillFinishedEvent(world, reportTotal));
|
Bukkit.getServer().getPluginManager().callEvent(new WorldBorderFillFinishedEvent(world, reportTotal));
|
||||||
sendMessage("task successfully completed for world \"" + refWorld() + "\"!");
|
sendMessage("task successfully completed for world \"" + refWorld() + "\"!");
|
||||||
this.stop();
|
this.stop(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for cancelling prematurely
|
// for cancelling prematurely
|
||||||
public void cancel()
|
public void cancel(boolean SaveFill)
|
||||||
{
|
{
|
||||||
this.stop();
|
this.stop(SaveFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're done, whether finished or cancelled
|
// we're done, whether finished or cancelled
|
||||||
private void stop()
|
private void stop(boolean SaveFill)
|
||||||
{
|
{
|
||||||
|
//If being called by onDisable(), don't delete fill progress
|
||||||
|
if (!SaveFill)
|
||||||
|
Config.UnStoreFillTask();
|
||||||
|
|
||||||
if (server == null)
|
if (server == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -482,8 +489,7 @@ public class WorldFillTask implements Runnable
|
||||||
Config.StoreFillTask();
|
Config.StoreFillTask();
|
||||||
reportProgress();
|
reportProgress();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Config.UnStoreFillTask();
|
|
||||||
}
|
}
|
||||||
public boolean isPaused()
|
public boolean isPaused()
|
||||||
{
|
{
|
||||||
|
@ -524,6 +530,8 @@ public class WorldFillTask implements Runnable
|
||||||
lastAutosave = lastReport;
|
lastAutosave = lastReport;
|
||||||
sendMessage("Saving the world to disk, just to be on the safe side.");
|
sendMessage("Saving the world to disk, just to be on the safe side.");
|
||||||
world.save();
|
world.save();
|
||||||
|
//In case of hard-crashes
|
||||||
|
Config.StoreFillTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,6 +567,11 @@ public class WorldFillTask implements Runnable
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.reportTotal = totalDone;
|
this.reportTotal = totalDone;
|
||||||
this.continueNotice = true;
|
this.continueNotice = true;
|
||||||
|
//Prevents saving zeroes on first StoreFillTask after restoring
|
||||||
|
this.refX = x;
|
||||||
|
this.refZ = z;
|
||||||
|
this.refLength = length;
|
||||||
|
this.refTotal = totalDone;
|
||||||
}
|
}
|
||||||
public int refX()
|
public int refX()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class CmdFill extends WBCmd
|
||||||
return;
|
return;
|
||||||
sender.sendMessage(C_HEAD + "Cancelling the world map generation task.");
|
sender.sendMessage(C_HEAD + "Cancelling the world map generation task.");
|
||||||
fillDefaults();
|
fillDefaults();
|
||||||
Config.StopFillTask();
|
Config.StopFillTask(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (check.equals("pause"))
|
else if (check.equals("pause"))
|
||||||
|
|
Loading…
Reference in New Issue