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")
|
date = git.head().date.format("yy.MM.dd")
|
||||||
revision = "-${git.head().abbreviatedId}"
|
revision = "-${git.head().abbreviatedId}"
|
||||||
parents = git.head().parentIds;
|
parents = git.head().parentIds;
|
||||||
index = -70; // Offset to mach CI
|
index = -71; // Offset to mach CI
|
||||||
int major, minor, patch;
|
int major, minor, patch;
|
||||||
major = minor = patch = 0;
|
major = minor = patch = 0;
|
||||||
for (;parents != null && !parents.isEmpty();index++) {
|
for (;parents != null && !parents.isEmpty();index++) {
|
||||||
|
|
|
@ -262,12 +262,12 @@ public class Fawe {
|
||||||
|
|
||||||
if (Settings.IMP.UPDATE && isJava8()) {
|
if (Settings.IMP.UPDATE && isJava8()) {
|
||||||
// Delayed updating
|
// Delayed updating
|
||||||
TaskManager.IMP.async(new Runnable() {
|
TaskManager.IMP.repeatAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Updater.update(IMP.getPlatform(), getVersion());
|
Updater.update(IMP.getPlatform(), getVersion());
|
||||||
}
|
}
|
||||||
});
|
}, 36000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ import java.nio.channels.ReadableByteChannel;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Updater {
|
public class Updater {
|
||||||
|
private static FaweVersion newVersion = null;
|
||||||
|
|
||||||
public static void update(String platform, FaweVersion currentVersion) {
|
public static void update(String platform, FaweVersion currentVersion) {
|
||||||
if (currentVersion == null || platform == null) {
|
if (currentVersion == null || platform == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -21,19 +23,26 @@ public class Updater {
|
||||||
try (Scanner reader = new Scanner(url.openStream())) {
|
try (Scanner reader = new Scanner(url.openStream())) {
|
||||||
String versionString = reader.next();
|
String versionString = reader.next();
|
||||||
FaweVersion version = new FaweVersion(versionString);
|
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));
|
URL download = new URL(downloadUrl.replaceAll("%platform%", platform).replaceAll("%version%", versionString));
|
||||||
try (ReadableByteChannel rbc = Channels.newChannel(download.openStream())) {
|
try (ReadableByteChannel rbc = Channels.newChannel(download.openStream())) {
|
||||||
File jarFile = MainUtil.getJarFile();
|
File jarFile = MainUtil.getJarFile();
|
||||||
File outFile = new File(jarFile.getParent(), "update" + File.separator + jarFile.getName());
|
File outFile = new File(jarFile.getParent(), "update" + File.separator + jarFile.getName());
|
||||||
File outFileParent = outFile.getParentFile();
|
boolean exists = outFile.exists();
|
||||||
if (!outFileParent.exists()) {
|
if (exists) {
|
||||||
outFileParent.mkdirs();
|
outFile.delete();
|
||||||
|
} else {
|
||||||
|
File outFileParent = outFile.getParentFile();
|
||||||
|
if (!outFileParent.exists()) {
|
||||||
|
outFileParent.mkdirs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try (FileOutputStream fos = new FileOutputStream(outFile)) {
|
try (FileOutputStream fos = new FileOutputStream(outFile)) {
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
Fawe.debug("Updated FAWE to " + versionString);
|
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;
|
hasNext = false;
|
||||||
--x;
|
|
||||||
--y;
|
|
||||||
return mutable;
|
return mutable;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -497,7 +497,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (nextX != Integer.MIN_VALUE);
|
return (nextZ != Integer.MIN_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -510,7 +510,17 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||||
if (++nextY > max.getBlockY()) {
|
if (++nextY > max.getBlockY()) {
|
||||||
nextY = min.getBlockY();
|
nextY = min.getBlockY();
|
||||||
if (++nextZ > max.getBlockZ()) {
|
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