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