Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/main/java/com/wimbli/WorldBorder/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@ public static void StopBorderTimer(boolean logIt)
logConfig("Border-checking timed task stopped.");
}

public static void StopFillTask()
public static void StopFillTask(boolean SaveFill)
{
if (fillTask != null && fillTask.valid())
fillTask.cancel();
fillTask.cancel(SaveFill);
}

public static void StoreFillTask()
Expand Down Expand Up @@ -682,16 +682,15 @@ else if (cfgVersion < 8 && !(msg.substring(0, 1).equals("&")))
if (storedFillTask != null)
{
String worldName = storedFillTask.getString("world");
int fillDistance = storedFillTask.getInt("fillDistance", 176);
int chunksPerRun = storedFillTask.getInt("chunksPerRun", 5);
int tickFrequency = storedFillTask.getInt("tickFrequency", 20);
int fillDistance = storedFillTask.getInt("fillDistance", 208);
int chunksPerRun = storedFillTask.getInt("chunksPerRun", 1);
int tickFrequency = storedFillTask.getInt("tickFrequency", 1);
int fillX = storedFillTask.getInt("x", 0);
int fillZ = storedFillTask.getInt("z", 0);
int fillLength = storedFillTask.getInt("length", 0);
int fillTotal = storedFillTask.getInt("total", 0);
boolean forceLoad = storedFillTask.getBoolean("forceLoad", false);
RestoreFillTask(worldName, fillDistance, chunksPerRun, tickFrequency, fillX, fillZ, fillLength, fillTotal, forceLoad);
save(false);
}

if (logIt)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/wimbli/WorldBorder/WorldBorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void onDisable()
DynMapFeatures.removeAllBorders();
Config.StopBorderTimer();
Config.StoreFillTask();
Config.StopFillTask();
Config.StopFillTask(true);
}

// for other plugins to hook into
Expand Down
35 changes: 24 additions & 11 deletions src/main/java/com/wimbli/WorldBorder/WorldFillTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,24 @@ public WorldFillTask(Server theServer, Player player, String worldName, int fill
sendMessage("You must specify a world!");
else
sendMessage("World \"" + worldName + "\" not found!");
this.stop();
//In case world is not loaded yet, do not delete saved progress
this.stop(true);
return;
}

this.border = (Config.Border(worldName) == null) ? null : Config.Border(worldName).copy();
if (this.border == null)
{
sendMessage("No border found for world \"" + worldName + "\"!");
this.stop();
this.stop(false);
return;
}

// load up a new WorldFileData for the world in question, used to scan region files for which chunks are already fully generated and such
worldData = WorldFileData.create(world, notifyPlayer);
if (worldData == null)
{
this.stop();
this.stop(false);
return;
}

Expand Down Expand Up @@ -169,7 +170,7 @@ public WorldFillTask(Server theServer, Player player, String worldName, int fill

public void setTaskID(int ID)
{
if (ID == -1) this.stop();
if (ID == -1) this.stop(false);
this.taskID = ID;
}

Expand Down Expand Up @@ -356,7 +357,9 @@ public boolean moveToNext()
lastLegX = x;
lastLegZ = z;
lastLegTotal = reportTotal + reportNum;
} else {
}
else
{
refX = lastLegX;
refZ = lastLegZ;
refTotal = lastLegTotal;
Expand Down Expand Up @@ -422,18 +425,22 @@ public void finish()
world.save();
Bukkit.getServer().getPluginManager().callEvent(new WorldBorderFillFinishedEvent(world, reportTotal));
sendMessage("task successfully completed for world \"" + refWorld() + "\"!");
this.stop();
this.stop(false);
}

// for cancelling prematurely
public void cancel()
public void cancel(boolean SaveFill)
{
this.stop();
this.stop(SaveFill);
}

// 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)
return;

Expand Down Expand Up @@ -482,8 +489,7 @@ public void pause(boolean pause)
Config.StoreFillTask();
reportProgress();
}
else
Config.UnStoreFillTask();

}
public boolean isPaused()
{
Expand Down Expand Up @@ -524,6 +530,8 @@ private void reportProgress()
lastAutosave = lastReport;
sendMessage("Saving the world to disk, just to be on the safe side.");
world.save();
//In case of hard-crashes
Config.StoreFillTask();
}
}

Expand Down Expand Up @@ -559,6 +567,11 @@ public void continueProgress(int x, int z, int length, int totalDone)
this.length = length;
this.reportTotal = totalDone;
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()
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/wimbli/WorldBorder/cmd/CmdFill.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void execute(CommandSender sender, Player player, List<String> params, St
return;
sender.sendMessage(C_HEAD + "Cancelling the world map generation task.");
fillDefaults();
Config.StopFillTask();
Config.StopFillTask(false);
return;
}
else if (check.equals("pause"))
Expand Down