Fix center + tweak updater
This commit is contained in:
parent
79f7a95fc6
commit
e3a56fcc50
@ -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++) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user