Fix rollback
This commit is contained in:
parent
0d7c0474cc
commit
598928053d
@ -45,7 +45,7 @@ public class Rollback extends FaweCommand {
|
||||
}
|
||||
player.deleteMeta("rollback");
|
||||
final FaweLocation origin = player.getLocation();
|
||||
rollback(player, true, Arrays.copyOfRange(args, 1, args.length), new RunnableVal<List<DiskStorageHistory>>() {
|
||||
rollback(player, !player.hasPermission("fawe.rollback.deep"), Arrays.copyOfRange(args, 1, args.length), new RunnableVal<List<DiskStorageHistory>>() {
|
||||
@Override
|
||||
public void run(List<DiskStorageHistory> edits) {
|
||||
long total = 0;
|
||||
|
@ -271,44 +271,48 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
if (summary != null) {
|
||||
return summary;
|
||||
}
|
||||
if (bdFile.exists()) {
|
||||
int ox = getOriginX();
|
||||
int oz = getOriginZ();
|
||||
if ((ox != 0 || oz != 0) && !requiredRegion.isIn(ox, oz)) {
|
||||
return summary = new DiskStorageSummary(ox, oz);
|
||||
}
|
||||
try (FileInputStream fis = new FileInputStream(bdFile)) {
|
||||
FaweInputStream gis = MainUtil.getCompressedIS(fis);
|
||||
// skip mode
|
||||
gis.skip(1);
|
||||
// origin
|
||||
ox = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + (gis.read() << 0));
|
||||
oz = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + (gis.read() << 0));
|
||||
setOrigin(ox, oz);
|
||||
summary = new DiskStorageSummary(ox, oz);
|
||||
if (!requiredRegion.isIn(ox, oz)) {
|
||||
fis.close();
|
||||
gis.close();
|
||||
return summary;
|
||||
try {
|
||||
if (bdFile.exists()) {
|
||||
int ox = getOriginX();
|
||||
int oz = getOriginZ();
|
||||
if ((ox != 0 || oz != 0) && !requiredRegion.isIn(ox, oz)) {
|
||||
return summary = new DiskStorageSummary(ox, oz);
|
||||
}
|
||||
byte[] buffer = new byte[9];
|
||||
int i = 0;
|
||||
while (!shallow && i < Settings.BUFFER_SIZE) {
|
||||
i++;
|
||||
if (gis.read(buffer) == -1) {
|
||||
try (FileInputStream fis = new FileInputStream(bdFile)) {
|
||||
FaweInputStream gis = MainUtil.getCompressedIS(fis);
|
||||
// skip mode
|
||||
gis.skip(1);
|
||||
// origin
|
||||
ox = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + (gis.read() << 0));
|
||||
oz = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + (gis.read() << 0));
|
||||
setOrigin(ox, oz);
|
||||
summary = new DiskStorageSummary(ox, oz);
|
||||
if (!requiredRegion.isIn(ox, oz)) {
|
||||
fis.close();
|
||||
gis.close();
|
||||
return summary;
|
||||
}
|
||||
int x = ((byte) buffer[0] & 0xFF) + ((byte) buffer[1] << 8) + ox;
|
||||
int z = ((byte) buffer[2] & 0xFF) + ((byte) buffer[3] << 8) + oz;
|
||||
int combined1 = buffer[7] & 0xFF;
|
||||
int combined2 = buffer[8] & 0xFF;
|
||||
summary.add(x, z, ((combined2 << 4) + (combined1 >> 4)));
|
||||
byte[] buffer = new byte[9];
|
||||
int i = 0;
|
||||
int amount = (Settings.BUFFER_SIZE - HEADER_SIZE) / 9;
|
||||
while (!shallow && ++i < amount) {
|
||||
if (gis.read(buffer) == -1) {
|
||||
fis.close();
|
||||
gis.close();
|
||||
return summary;
|
||||
}
|
||||
int x = ((byte) buffer[0] & 0xFF) + ((byte) buffer[1] << 8) + ox;
|
||||
int z = ((byte) buffer[2] & 0xFF) + ((byte) buffer[3] << 8) + oz;
|
||||
int combined1 = buffer[7] & 0xFF;
|
||||
int combined2 = buffer[8] & 0xFF;
|
||||
summary.add(x, z, ((combined2 << 4) + (combined1 >> 4)));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return summary;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user