mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-02-17 21:11:26 +01:00
Minor tweaks
This commit is contained in:
parent
fd37adaac8
commit
e158b4d222
@ -11,7 +11,6 @@ import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -105,74 +104,69 @@ public class Rollback extends FaweCommand {
|
||||
SetQueue.IMP.addTask(this);
|
||||
}
|
||||
};
|
||||
TaskManager.IMP.async(task);
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void rollback(final FawePlayer player, final boolean shallow, final String[] args, final RunnableVal<List<DiskStorageHistory>> result) {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UUID user = null;
|
||||
int radius = Integer.MAX_VALUE;
|
||||
long time = Long.MAX_VALUE;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String[] split = args[i].split(":");
|
||||
if (split.length != 2) {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>");
|
||||
UUID user = null;
|
||||
int radius = Integer.MAX_VALUE;
|
||||
long time = Long.MAX_VALUE;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String[] split = args[i].split(":");
|
||||
if (split.length != 2) {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>");
|
||||
return;
|
||||
}
|
||||
switch (split[0].toLowerCase()) {
|
||||
case "username":
|
||||
case "user":
|
||||
case "u": {
|
||||
try {
|
||||
if (split[1].length() > 16) {
|
||||
user = UUID.fromString(split[1]);
|
||||
} else {
|
||||
user = Fawe.imp().getUUID(split[1]);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {}
|
||||
if (user == null) {
|
||||
player.sendMessage("&dInvalid user: " + split[1]);
|
||||
return;
|
||||
}
|
||||
switch (split[0].toLowerCase()) {
|
||||
case "username":
|
||||
case "user":
|
||||
case "u": {
|
||||
try {
|
||||
if (split[1].length() > 16) {
|
||||
user = UUID.fromString(split[1]);
|
||||
} else {
|
||||
user = Fawe.imp().getUUID(split[1]);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {}
|
||||
if (user == null) {
|
||||
player.sendMessage("&dInvalid user: " + split[1]);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "r":
|
||||
case "radius": {
|
||||
if (!MathMan.isInteger(split[1])) {
|
||||
player.sendMessage("&dInvalid radius: " + split[1]);
|
||||
return;
|
||||
}
|
||||
radius = Integer.parseInt(split[1]);
|
||||
break;
|
||||
}
|
||||
case "t":
|
||||
case "time": {
|
||||
time = MainUtil.timeToSec(split[1]) * 1000;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "r":
|
||||
case "radius": {
|
||||
if (!MathMan.isInteger(split[1])) {
|
||||
player.sendMessage("&dInvalid radius: " + split[1]);
|
||||
return;
|
||||
}
|
||||
radius = Integer.parseInt(split[1]);
|
||||
break;
|
||||
}
|
||||
FaweLocation origin = player.getLocation();
|
||||
List<DiskStorageHistory> edits = MainUtil.getBDFiles(origin, user, radius, time, shallow);
|
||||
if (edits == null) {
|
||||
player.sendMessage("&cToo broad, try refining your search!");
|
||||
case "t":
|
||||
case "time": {
|
||||
time = MainUtil.timeToSec(split[1]) * 1000;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>");
|
||||
return;
|
||||
}
|
||||
if (edits.size() == 0) {
|
||||
player.sendMessage("&cNo edits found!");
|
||||
return;
|
||||
}
|
||||
result.run(edits);
|
||||
}
|
||||
});
|
||||
}
|
||||
FaweLocation origin = player.getLocation();
|
||||
List<DiskStorageHistory> edits = MainUtil.getBDFiles(origin, user, radius, time, shallow);
|
||||
if (edits == null) {
|
||||
player.sendMessage("&cToo broad, try refining your search!");
|
||||
return;
|
||||
}
|
||||
if (edits.size() == 0) {
|
||||
player.sendMessage("&cNo edits found!");
|
||||
return;
|
||||
}
|
||||
result.run(edits);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.object;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
public abstract class FaweCommand<T> {
|
||||
public final String perm;
|
||||
@ -20,13 +21,18 @@ public abstract class FaweCommand<T> {
|
||||
} else {
|
||||
if (player.getMeta("fawe_action") != null) {
|
||||
BBC.WORLDEDIT_COMMAND_LIMIT.send(player);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
player.setMeta("fawe_action", true);
|
||||
boolean result = execute(player, args);
|
||||
player.deleteMeta("fawe_action");
|
||||
return result;
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
execute(player, args);
|
||||
player.deleteMeta("fawe_action");
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract boolean execute(final FawePlayer<T> player, final String... args);
|
||||
|
@ -394,8 +394,8 @@ public class DiskStorageHistory implements ChangeSet, FaweChangeSet {
|
||||
}
|
||||
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];
|
||||
int combined2 = buffer[8];
|
||||
int combined1 = buffer[7] & 0xFF;
|
||||
int combined2 = buffer[8] & 0xFF;
|
||||
summary.add(x, z, ((combined2 << 4) + (combined1 >> 4)));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -164,16 +164,13 @@ public class MainUtil {
|
||||
if (file.getName().endsWith(".bd")) {
|
||||
if (timediff > Integer.MAX_VALUE || now - file.lastModified() <= timediff) {
|
||||
files.add(file);
|
||||
if (files.size() > 64) {
|
||||
if (files.size() > 2048) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (files.size() > 64) {
|
||||
return null;
|
||||
}
|
||||
World world = origin.getWorld();
|
||||
Collections.sort(files, new Comparator<File>() {
|
||||
@Override
|
||||
@ -190,8 +187,10 @@ public class MainUtil {
|
||||
RegionWrapper region = new RegionWrapper(summary.minX, summary.maxX, summary.minZ, summary.maxZ);
|
||||
if (region.distance(origin.x, origin.z) <= radius) {
|
||||
result.add(dsh);
|
||||
if (result.size() > 64) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user