diff --git a/build.gradle b/build.gradle index 3c72a325..23163bac 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ ext { date = git.head().date.format("yy.MM.dd") revision = "-${git.head().abbreviatedId}" parents = git.head().parentIds; - index = -70; // Offset to mach CI + index = -71; // Offset to mach CI int major, minor, patch; major = minor = patch = 0; for (;parents != null && !parents.isEmpty();index++) { diff --git a/core/src/main/java/com/boydti/fawe/Fawe.java b/core/src/main/java/com/boydti/fawe/Fawe.java index 6c8922a8..14e6aa3c 100644 --- a/core/src/main/java/com/boydti/fawe/Fawe.java +++ b/core/src/main/java/com/boydti/fawe/Fawe.java @@ -262,12 +262,12 @@ public class Fawe { if (Settings.IMP.UPDATE && isJava8()) { // Delayed updating - TaskManager.IMP.async(new Runnable() { + TaskManager.IMP.repeatAsync(new Runnable() { @Override public void run() { Updater.update(IMP.getPlatform(), getVersion()); } - }); + }, 36000); } } diff --git a/core/src/main/java/com/boydti/fawe/util/Updater.java b/core/src/main/java/com/boydti/fawe/util/Updater.java index e89c3580..25b393bb 100644 --- a/core/src/main/java/com/boydti/fawe/util/Updater.java +++ b/core/src/main/java/com/boydti/fawe/util/Updater.java @@ -10,6 +10,8 @@ import java.nio.channels.ReadableByteChannel; import java.util.Scanner; public class Updater { + private static FaweVersion newVersion = null; + public static void update(String platform, FaweVersion currentVersion) { if (currentVersion == null || platform == null) { return; @@ -21,19 +23,26 @@ public class Updater { try (Scanner reader = new Scanner(url.openStream())) { String versionString = reader.next(); FaweVersion version = new FaweVersion(versionString); - if (currentVersion == null || version.isNewer(currentVersion)) { + if (currentVersion == null || version.isNewer(newVersion != null ? newVersion : currentVersion)) { + newVersion = version; URL download = new URL(downloadUrl.replaceAll("%platform%", platform).replaceAll("%version%", versionString)); try (ReadableByteChannel rbc = Channels.newChannel(download.openStream())) { File jarFile = MainUtil.getJarFile(); File outFile = new File(jarFile.getParent(), "update" + File.separator + jarFile.getName()); - File outFileParent = outFile.getParentFile(); - if (!outFileParent.exists()) { - outFileParent.mkdirs(); + boolean exists = outFile.exists(); + if (exists) { + outFile.delete(); + } else { + File outFileParent = outFile.getParentFile(); + if (!outFileParent.exists()) { + outFileParent.mkdirs(); + } } try (FileOutputStream fos = new FileOutputStream(outFile)) { fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } Fawe.debug("Updated FAWE to " + versionString); + MainUtil.sendAdmin("Restart to update FAWE with these changes: " + "http://boydti.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash)); } } } diff --git a/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 268e4e73..d4cc1e3b 100644 --- a/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -454,9 +454,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } }; } + x = tx; + y = ty; hasNext = false; - --x; - --y; return mutable; } } else { @@ -497,7 +497,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public boolean hasNext() { - return (nextX != Integer.MIN_VALUE); + return (nextZ != Integer.MIN_VALUE); } @Override @@ -510,7 +510,17 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { if (++nextY > max.getBlockY()) { nextY = min.getBlockY(); if (++nextZ > max.getBlockZ()) { - nextX = Integer.MIN_VALUE; + if (nextZ == Integer.MIN_VALUE) { + throw new NoSuchElementException("End of iterator") { + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } + }; + } + nextX = max.getBlockX(); + nextY = max.getBlockY(); + nextZ = Integer.MIN_VALUE; } } }