Skip to content

Commit

Permalink
Make WorldRegen work with the latest Spigot 1.13 release
Browse files Browse the repository at this point in the history
  • Loading branch information
rlf committed Jul 25, 2018
1 parent c1e8ba9 commit 0ce80c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,33 @@ public class WorldRegen extends IncrementalRunnable {
private static final Logger log = Logger.getLogger(WorldRegen.class.getName());
private final World world;
private final List<Vector2D> chunks;
private boolean firstRun = true;

public WorldRegen(uSkyBlock plugin, World world, Set<Vector2D> chunks, Runnable onCompletion) {
super(plugin, onCompletion, 15, -1, 50);
super(plugin, onCompletion);//, 15, -1, 50);
this.world = world;
this.chunks = new ArrayList<>(chunks);
log.log(Level.FINE, "Planning regen of chunks: " + chunks);
}

@Override
protected boolean execute() {
/*
if (firstRun) {
firstRun = false;
chunks.stream().forEach(c -> world.unloadChunk(c.getBlockX(), c.getBlockZ(), false));
}
*/
//while (!chunks.isEmpty()) {
Vector2D chunk = chunks.remove(0);
try {
if (!world.regenerateChunk(chunk.getBlockX(), chunk.getBlockZ())) {
LogUtil.log(Level.WARNING, "Unable to regenerate chunk " + chunk);
while (!chunks.isEmpty()) {
Vector2D chunk = chunks.remove(0);
try {
if (!world.regenerateChunk(chunk.getBlockX(), chunk.getBlockZ())) {
LogUtil.log(Level.WARNING, "Unable to regenerate chunk " + chunk);
chunks.add(chunk);
break;
}
} catch (Exception e) {
LogUtil.log(Level.WARNING, "Exception trying to regenerate chunk " + chunk, e);
chunks.add(chunk);
break;
}
} catch (Exception e) {
LogUtil.log(Level.WARNING, "Exception trying to regenerate chunk " + chunk, e);
chunks.add(chunk);
}
tick();
/* if (!tick()) {
if (!tick()) {
break;
}
}
*/
return chunks.isEmpty();
}
}
Binary file not shown.

0 comments on commit 0ce80c9

Please sign in to comment.