Various minor
Tweak some messages Add command confirmation Optimize surface mask Optimize angle mask (further) Fix help formatting Fix rollback import from disk being a shallow summary
This commit is contained in:
parent
693963a0f3
commit
edd8dcc552
@ -28,7 +28,7 @@ ext {
|
||||
date = git.head().date.format("yy.MM.dd")
|
||||
revision = "-${git.head().abbreviatedId}"
|
||||
parents = git.head().parentIds;
|
||||
index = -93; // Offset to match CI
|
||||
index = -94; // Offset to match CI
|
||||
int major, minor, patch;
|
||||
major = minor = patch = 0;
|
||||
for (;parents != null && !parents.isEmpty();index++) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -61,6 +62,24 @@ public class FawePrimitiveBinding extends BindingHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link com.boydti.fawe.object.FawePlayer} from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @return a FawePlayer
|
||||
* @throws ParameterException on other error
|
||||
*/
|
||||
@BindingMatch(type = FawePlayer.class,
|
||||
behavior = BindingBehavior.PROVIDES)
|
||||
public FawePlayer getFawePlayer(ArgumentStack context) throws ParameterException, InputParseException {
|
||||
Actor sender = context.getContext().getLocals().get(Actor.class);
|
||||
if (sender == null) {
|
||||
throw new ParameterException("Missing 'Actor'");
|
||||
} else {
|
||||
return FawePlayer.wrap(sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link com.sk89q.worldedit.extent.Extent} from a {@link ArgumentStack}.
|
||||
*
|
||||
|
@ -29,7 +29,7 @@ public class Rollback extends FaweCommand {
|
||||
@Override
|
||||
public boolean execute(final FawePlayer player, final String... args) {
|
||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
BBC.SETTING_DISABLE.send(player, "history.use-database");
|
||||
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
|
||||
return false;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
|
@ -172,6 +172,7 @@ public enum BBC {
|
||||
PLACE_DISABLED("Now placing at the block you stand in.", "WorldEdit.General"),
|
||||
|
||||
KILL_SUCCESS("Killed %s0 entities in a radius of %s1.", "WorldEdit.Utility"),
|
||||
NOTHING_CONFIRMED("You have no actions pending confirmation.", "WorldEdit.Utility"),
|
||||
|
||||
|
||||
SCHEMATIC_DELETE("%s0 has been deleted.", "Worldedit.Schematic"),
|
||||
@ -234,6 +235,7 @@ public enum BBC {
|
||||
WORLDEDIT_SOME_FAILS_BLOCKBAG("&cMissing blocks: %s0", "Error"),
|
||||
|
||||
WORLDEDIT_CANCEL_COUNT("&cCancelled %s0 edits.", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_CONFIRM("&7Your selection is large (%s0 -> %s1). Use &c//confirm &7to execute &c%s2", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON("&cYour WorldEdit action was cancelled:&7 %s0&c.", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_MANUAL("Manual cancellation", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_LOW_MEMORY("Low memory", "Cancel"),
|
||||
|
@ -133,6 +133,10 @@ public class Settings extends Config {
|
||||
"Place chunks instead of individual blocks"
|
||||
})
|
||||
public boolean FAST_PLACEMENT = true;
|
||||
@Comment({
|
||||
"Should large edits require confirmation (>16384 chunks)",
|
||||
})
|
||||
public boolean CONFIRM_LARGE = true;
|
||||
}
|
||||
|
||||
public static class HISTORY {
|
||||
@ -402,6 +406,7 @@ public class Settings extends Config {
|
||||
limit.INVENTORY_MODE = Math.min(limit.INVENTORY_MODE, newLimit.INVENTORY_MODE);
|
||||
limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION);
|
||||
limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT;
|
||||
limit.CONFIRM_LARGE &= newLimit.CONFIRM_LARGE;
|
||||
}
|
||||
}
|
||||
return limit;
|
||||
|
@ -16,6 +16,7 @@ public class FaweLimit {
|
||||
public int INVENTORY_MODE = Integer.MAX_VALUE;
|
||||
public int SPEED_REDUCTION = Integer.MAX_VALUE;
|
||||
public boolean FAST_PLACEMENT = false;
|
||||
public boolean CONFIRM_LARGE = true;
|
||||
|
||||
|
||||
public static FaweLimit MAX;
|
||||
@ -58,6 +59,7 @@ public class FaweLimit {
|
||||
MAX.MAX_HISTORY = Integer.MAX_VALUE;
|
||||
MAX.MAX_EXPRESSION_MS = 50;
|
||||
MAX.FAST_PLACEMENT = true;
|
||||
MAX.CONFIRM_LARGE = true;
|
||||
}
|
||||
|
||||
public boolean MAX_CHANGES() {
|
||||
@ -109,6 +111,7 @@ public class FaweLimit {
|
||||
INVENTORY_MODE = limit.INVENTORY_MODE;
|
||||
SPEED_REDUCTION = limit.SPEED_REDUCTION;
|
||||
FAST_PLACEMENT = limit.FAST_PLACEMENT;
|
||||
CONFIRM_LARGE = limit.CONFIRM_LARGE;
|
||||
}
|
||||
|
||||
public FaweLimit copy() {
|
||||
@ -124,6 +127,7 @@ public class FaweLimit {
|
||||
limit.MAX_ITERATIONS = MAX_ITERATIONS;
|
||||
limit.MAX_HISTORY = MAX_HISTORY;
|
||||
limit.FAST_PLACEMENT = FAST_PLACEMENT;
|
||||
limit.CONFIRM_LARGE = CONFIRM_LARGE;
|
||||
return limit;
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,12 @@ import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
@ -64,6 +67,9 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
if (obj == null) {
|
||||
return FakePlayer.getConsole().toFawePlayer();
|
||||
}
|
||||
if (obj instanceof FawePlayer) {
|
||||
return (FawePlayer<V>) obj;
|
||||
}
|
||||
if (obj instanceof FakePlayer) {
|
||||
return ((FakePlayer) obj).toFawePlayer();
|
||||
}
|
||||
@ -120,6 +126,39 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkConfirmation(String command) throws RegionOperationException {
|
||||
if (getMeta("cmdConfirmRunning", false)) {
|
||||
return;
|
||||
}
|
||||
Region sel = getSelection();
|
||||
if (sel != null) {
|
||||
Vector min = sel.getMinimumPoint();
|
||||
Vector max = sel.getMaximumPoint();
|
||||
int area = (int) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
|
||||
if (area > 2 << 22) {
|
||||
setMeta("cmdConfirm", command);
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean confirm() {
|
||||
String confirm = deleteMeta("cmdConfirm");
|
||||
if (confirm == null) {
|
||||
return false;
|
||||
}
|
||||
queueAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setMeta("cmdConfirmRunning", true);
|
||||
CommandEvent event = new CommandEvent(getPlayer(), confirm);
|
||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
setMeta("cmdConfirmRunning", false);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean toggle(String perm) {
|
||||
if (this.hasPermission(perm)) {
|
||||
this.setPermission(perm, false);
|
||||
|
@ -54,7 +54,7 @@ public class Metadatable {
|
||||
* - deleting other plugin's metadata may cause issues
|
||||
* @param key
|
||||
*/
|
||||
public Object deleteMeta(String key) {
|
||||
return this.meta == null ? null : this.meta.remove(key);
|
||||
public <V> V deleteMeta(String key) {
|
||||
return this.meta == null ? null : (V) this.meta.remove(key);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
|
||||
return false;
|
||||
}
|
||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
player.print(BBC.getPrefix() + BBC.SETTING_DISABLE.f("history.use-database"));
|
||||
player.print(BBC.getPrefix() + BBC.SETTING_DISABLE.f("history.use-database (Import with /frb #import )"));
|
||||
return false;
|
||||
}
|
||||
WorldVector target = getTarget(player, rightClick);
|
||||
|
@ -19,7 +19,7 @@ public class SurfaceSphereBrush implements Brush {
|
||||
SurfaceMask surface = new SurfaceMask(editSession);
|
||||
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
||||
final RadiusMask radius = new RadiusMask(0, (int) size);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(vector -> radius.test(vector) && surface.test(vector), vector -> editSession.setBlock(vector, pattern));
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(vector -> surface.test(vector) && radius.test(vector), vector -> editSession.setBlock(vector, pattern));
|
||||
visitor.visit(position);
|
||||
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||
Operations.completeBlindly(visitor);
|
||||
|
@ -182,6 +182,21 @@ public class LocalBlockVectorSet implements Set<Vector> {
|
||||
return array;
|
||||
}
|
||||
|
||||
public boolean canAdd(int x, int y, int z) {
|
||||
if (offsetX == Integer.MAX_VALUE) {
|
||||
return false;
|
||||
}
|
||||
int relX = x - offsetX;
|
||||
int relZ = z - offsetZ;
|
||||
if (relX > 1023 || relX < -1024 || relZ > 1023 || relZ < -1024) {
|
||||
return false;
|
||||
}
|
||||
if (y < 0 || y > 256) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(int x, int y, int z) {
|
||||
if (offsetX == Integer.MAX_VALUE) {
|
||||
offsetX = x;
|
||||
|
@ -14,6 +14,10 @@ public class AbstractDelegateMask extends AbstractMask {
|
||||
this.mask = parent;
|
||||
}
|
||||
|
||||
public final Mask getMask() {
|
||||
return mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
return mask.test(vector);
|
||||
|
@ -10,15 +10,12 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
*/
|
||||
public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
|
||||
|
||||
private final Mask mask;
|
||||
private final CachedMask mask;
|
||||
private transient MutableBlockVector mutable = new MutableBlockVector();
|
||||
|
||||
public AdjacentAnyMask(Mask mask) {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
public Mask getMask() {
|
||||
return mask;
|
||||
this.mask = CachedMask.cache(mask);
|
||||
mutable = new MutableBlockVector();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,26 +23,21 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
|
||||
mutable = new MutableBlockVector();
|
||||
}
|
||||
|
||||
public CachedMask getParentMask() {
|
||||
return mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector v) {
|
||||
int x = v.getBlockX();
|
||||
int y = v.getBlockY();
|
||||
int z = v.getBlockZ();
|
||||
v.mutY(y + 1);
|
||||
if (mask.test(v)) { v.mutY(y); return true; }
|
||||
v.mutY(y - 1);
|
||||
if (mask.test(v)) { v.mutY(y); return true; }
|
||||
v.mutY(y);
|
||||
v.mutX(x + 1);
|
||||
if (mask.test(v)) { v.mutX(x); return true; }
|
||||
v.mutX(x - 1);
|
||||
if (mask.test(v)) { v.mutX(x); return true; }
|
||||
v.mutX(x);
|
||||
v.mutZ(z + 1);
|
||||
if (mask.test(v)) { v.mutZ(z); return true; }
|
||||
v.mutZ(z - 1);
|
||||
if (mask.test(v)) { v.mutZ(z); return true; }
|
||||
v.mutZ(z);
|
||||
if (mask.test(x, y + 1, z)) { return true; }
|
||||
if (mask.test(x + 1, y, z)) { return true; }
|
||||
if (mask.test(x - 1, y, z)) { return true; }
|
||||
if (mask.test(x, y, z + 1)) { return true; }
|
||||
if (mask.test(x, y, z - 1)) { return true; }
|
||||
if (mask.test(x, y - 1, z)) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -53,21 +45,12 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
|
||||
int x = v.getBlockX();
|
||||
int y = v.getBlockY();
|
||||
int z = v.getBlockZ();
|
||||
v.mutY(y + 1);
|
||||
if (mask.test(v)) { v.mutY(y); return mutable.setComponents(0, 1, 0); }
|
||||
v.mutY(y - 1);
|
||||
if (mask.test(v)) { v.mutY(y); return mutable.setComponents(0, -1, 0); }
|
||||
v.mutY(y);
|
||||
v.mutX(x + 1);
|
||||
if (mask.test(v)) { v.mutX(x); return mutable.setComponents(1, 0, 0); }
|
||||
v.mutX(x - 1);
|
||||
if (mask.test(v)) { v.mutX(x); return mutable.setComponents(-1, 0, 0); }
|
||||
v.mutX(x);
|
||||
v.mutZ(z + 1);
|
||||
if (mask.test(v)) { v.mutZ(z); return mutable.setComponents(0, 0, 1); }
|
||||
v.mutZ(z - 1);
|
||||
if (mask.test(v)) { v.mutZ(z); return mutable.setComponents(0, 0, - 1); }
|
||||
v.mutZ(z);
|
||||
if (mask.test(x, y + 1, z)) { return mutable.setComponents(0, 1, 0); }
|
||||
if (mask.test(x + 1, y, z)) { return mutable.setComponents(1, 0, 0); }
|
||||
if (mask.test(x - 1, y, z)) { return mutable.setComponents(-1, 0, 0); }
|
||||
if (mask.test(x, y, z + 1)) { return mutable.setComponents(0, 0, 1); }
|
||||
if (mask.test(x, y, z - 1)) { return mutable.setComponents(0, 0, - 1); }
|
||||
if (mask.test(x, y - 1, z)) { return mutable.setComponents(0, -1, 0); }
|
||||
return null;
|
||||
}
|
||||
}
|
@ -33,6 +33,8 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
||||
mutable = new MutableBlockVector();
|
||||
cacheBotX = Integer.MIN_VALUE;
|
||||
cacheBotZ = Integer.MIN_VALUE;
|
||||
lastX = Integer.MIN_VALUE;
|
||||
lastX = Integer.MIN_VALUE;
|
||||
if (cacheHeights != null) {
|
||||
Arrays.fill(cacheHeights, (byte) 0);
|
||||
}
|
||||
@ -43,8 +45,12 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
||||
private transient int cacheBotX = Integer.MIN_VALUE;
|
||||
private transient int cacheBotZ = Integer.MIN_VALUE;
|
||||
private transient int cacheCenterZ;
|
||||
private transient byte[] cacheHeights = null;
|
||||
private transient int lastY = 0;
|
||||
private transient byte[] cacheHeights;
|
||||
private transient int lastY;
|
||||
private transient int lastX = Integer.MIN_VALUE;
|
||||
private transient int lastZ = Integer.MIN_VALUE;
|
||||
private transient boolean foundY;
|
||||
private transient boolean lastValue;
|
||||
|
||||
public int getHeight(int x, int y, int z) {
|
||||
try {
|
||||
@ -74,6 +80,22 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean testSlope(int x, int y, int z) {
|
||||
double slope;
|
||||
boolean aboveMin;
|
||||
if ((lastX == (lastX = x) & lastZ == (lastZ = z))) {
|
||||
return lastValue;
|
||||
}
|
||||
slope = Math.abs(getHeight(x + 1, y, z) - getHeight(x - 1, y, z)) * ADJACENT_MOD;
|
||||
if (slope >= min && max >= Math.max(maxY - y, y)) {
|
||||
return lastValue = true;
|
||||
}
|
||||
slope = Math.max(slope, Math.abs(getHeight(x, y, z + 1) - getHeight(x, y, z - 1)) * ADJACENT_MOD);
|
||||
slope = Math.max(slope, Math.abs(getHeight(x + 1, y, z + 1) - getHeight(x - 1, y, z - 1)) * DIAGONAL_MOD);
|
||||
slope = Math.max(slope, Math.abs(getHeight(x - 1, y, z + 1) - getHeight(x + 1, y, z - 1)) * DIAGONAL_MOD);
|
||||
return lastValue = (slope >= min && slope <= max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
int x = vector.getBlockX();
|
||||
@ -83,20 +105,11 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
||||
if (!test(block.getId(), block.getData())) {
|
||||
return false;
|
||||
}
|
||||
if (overlay) {
|
||||
block = getExtent().getLazyBlock(x, y + 1, z);
|
||||
if (overlay && test(block.getId(), block.getData())) {
|
||||
return false;
|
||||
if (test(block.getId(), block.getData())) return lastValue = false;
|
||||
}
|
||||
double slope;
|
||||
boolean aboveMin;
|
||||
slope = Math.abs(getHeight(x + 1, y, z) - getHeight(x - 1, y, z)) * ADJACENT_MOD;
|
||||
if (slope >= min && max >= Math.max(maxY - y, y)) {
|
||||
return true;
|
||||
}
|
||||
slope = Math.max(slope, Math.abs(getHeight(x, y, z + 1) - getHeight(x, y, z - 1)) * ADJACENT_MOD);
|
||||
slope = Math.max(slope, Math.abs(getHeight(x + 1, y, z + 1) - getHeight(x - 1, y, z - 1)) * DIAGONAL_MOD);
|
||||
slope = Math.max(slope, Math.abs(getHeight(x - 1, y, z + 1) - getHeight(x + 1, y, z - 1)) * DIAGONAL_MOD);
|
||||
return (slope >= min && slope <= max);
|
||||
return testSlope(x, y, z);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -0,0 +1,65 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||
import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
|
||||
public class CachedMask extends AbstractDelegateMask implements ResettableMask {
|
||||
|
||||
private transient MutableBlockVector mutable = new MutableBlockVector();
|
||||
private transient LocalBlockVectorSet cache_checked = new LocalBlockVectorSet();
|
||||
private transient LocalBlockVectorSet cache_results = new LocalBlockVectorSet();
|
||||
|
||||
public CachedMask(Mask mask) {
|
||||
super(mask);
|
||||
cache_checked.setOffset(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
cache_results.setOffset(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
public static CachedMask cache(Mask mask) {
|
||||
if (mask instanceof CachedMask) {
|
||||
return (CachedMask) mask;
|
||||
}
|
||||
return new CachedMask(mask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
mutable = new MutableBlockVector();
|
||||
cache_checked = new LocalBlockVectorSet();
|
||||
cache_results = new LocalBlockVectorSet();
|
||||
resetCache();
|
||||
}
|
||||
|
||||
private void resetCache() {
|
||||
cache_checked.clear();
|
||||
cache_results.clear();
|
||||
cache_checked.setOffset(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
cache_results.setOffset(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
return test(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
}
|
||||
|
||||
public boolean test(int x, int y, int z) {
|
||||
if (cache_checked.contains(x, y, z)) {
|
||||
return cache_results.contains(x, y, z);
|
||||
}
|
||||
boolean result = getMask().test(mutable.setComponents(x, y, z));
|
||||
try {
|
||||
cache_checked.add(x, y, z);
|
||||
if (result) cache_results.add(x, y, z);
|
||||
} catch (UnsupportedOperationException ignore) {
|
||||
resetCache();
|
||||
cache_checked.setOffset(x, z);
|
||||
cache_results.setOffset(x, z);
|
||||
cache_checked.add(x, y, z);
|
||||
if (result) cache_results.add(x, y, z);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ public class SurfaceMask extends AdjacentAnyMask {
|
||||
|
||||
public SurfaceMask(Extent extent) {
|
||||
super(new BlockMask(extent, new BaseBlock(0)));
|
||||
BlockMask mask = (BlockMask) getMask();
|
||||
BlockMask mask = (BlockMask) getParentMask().getMask();
|
||||
for (int id = 0; id < 256; id++) {
|
||||
if (FaweCache.canPassThrough(id, 0)) {
|
||||
mask.add(new BaseBlock(id, -1));
|
||||
@ -22,6 +22,6 @@ public class SurfaceMask extends AdjacentAnyMask {
|
||||
|
||||
@Override
|
||||
public boolean test(Vector v) {
|
||||
return !getMask().test(v) && super.test(v);
|
||||
return !getParentMask().test(v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(v);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,88 @@
|
||||
package com.boydti.fawe.regions.general.plot;
|
||||
|
||||
import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAQueue;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAWriter;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.io.File;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "moveto512",
|
||||
permission = "plots.moveto512",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
description = "Move plots to a 512 sized region",
|
||||
usage = "/plots moveto512 [world]"
|
||||
)
|
||||
public class MoveTo512 extends Command {
|
||||
public MoveTo512() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||
check(area, C.COMMAND_SYNTAX, getUsage());
|
||||
|
||||
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(area.worldname, true, false);
|
||||
MCAQueue queueFrom = new MCAQueue(area.worldname, defaultQueue.getSaveFolder(), defaultQueue.hasSky());
|
||||
|
||||
File folder = null; // TODO
|
||||
|
||||
int minRoad = 5;
|
||||
PlotId nextId = new PlotId(0, 0);
|
||||
for (Plot plot : area.getPlots()) {
|
||||
Location bot = plot.getBottomAbs();
|
||||
Location top = plot.getTopAbs();
|
||||
|
||||
int pLen = Math.max(top.getX() - bot.getX(), 512 - minRoad);
|
||||
int roadWidth = pLen - 512;
|
||||
int roadPosLower;
|
||||
if ((roadWidth & 1) == 0) {
|
||||
roadPosLower = (short) (Math.floor(roadWidth / 2) - 1);
|
||||
} else {
|
||||
roadPosLower = (short) Math.floor(roadWidth / 2);
|
||||
}
|
||||
int roadPosUpper = 512 - roadWidth + roadPosLower;
|
||||
MCAWriter writer = new MCAWriter(512, 512, folder) {
|
||||
|
||||
@Override
|
||||
public boolean shouldWrite(int chunkX, int chunkZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAChunk write(MCAChunk input, int bx, int tx, int bz, int tz) {
|
||||
// int obx = bx - oX;
|
||||
// int obz = bz - oZ;
|
||||
// int otx = tx - oX;
|
||||
// int otz = tz - oZ;
|
||||
// int otherBCX = (obx) >> 4;
|
||||
// int otherBCZ = (obz) >> 4;
|
||||
// int otherTCX = (otx) >> 4;
|
||||
// int otherTCZ = (otz) >> 4;
|
||||
return input;
|
||||
}
|
||||
};
|
||||
writer.setMCAOffset(nextId.x, nextId.y);
|
||||
nextId = nextId.getNextId(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -74,14 +74,16 @@ public class HistoryCommands {
|
||||
@Command(
|
||||
aliases = { "/frb", "frb", "fawerollback", "/fawerollback", "/rollback" },
|
||||
usage = "<user=Empire92> <radius=5> <time=3d4h>",
|
||||
desc = "Undo a specific edit. The time uses s, m, h, d, y.",
|
||||
desc = "Undo a specific edit. " +
|
||||
" - The time uses s, m, h, d, y.\n" +
|
||||
" - Import from disk: /frb #import",
|
||||
min = 1,
|
||||
max = 3
|
||||
)
|
||||
@CommandPermissions("worldedit.history.rollback")
|
||||
public void faweRollback(final Player player, LocalSession session, final String user, @Optional("0") int radius, @Optional("0") String time) throws WorldEditException {
|
||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
BBC.SETTING_DISABLE.send(player, "history.use-database");
|
||||
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
|
||||
return;
|
||||
}
|
||||
switch (user.charAt(0)) {
|
||||
@ -115,7 +117,7 @@ public class HistoryCommands {
|
||||
continue;
|
||||
}
|
||||
RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(world, uuid, Integer.parseInt(name.substring(0, name.length() - 3)));
|
||||
DiskStorageHistory.DiskStorageSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), true);
|
||||
DiskStorageHistory.DiskStorageSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), false);
|
||||
if (summary != null) {
|
||||
rollback.setDimensions(new Vector(summary.minX, 0, summary.minZ), new Vector(summary.maxX, 255, summary.maxZ));
|
||||
rollback.setTime(historyFile.lastModified());
|
||||
@ -125,6 +127,7 @@ public class HistoryCommands {
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -135,7 +138,7 @@ public class HistoryCommands {
|
||||
}
|
||||
String toParse = user.substring(1);
|
||||
if (!MathMan.isInteger(toParse)) {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb <user> <radius> <time>");
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb #<index>");
|
||||
return;
|
||||
}
|
||||
int index = Integer.parseInt(toParse);
|
||||
|
@ -27,7 +27,7 @@ public class MethodCommands {
|
||||
|
||||
@Deprecated
|
||||
public MethodCommands() {
|
||||
this.worldEdit = WorldEdit.getInstance();
|
||||
this(WorldEdit.getInstance());
|
||||
}
|
||||
|
||||
public void register(Method method, CommandCallable callable, Dispatcher dispatcher) {
|
||||
|
@ -94,7 +94,7 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
* Commands that operate on regions.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Commands that operate on regions: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Region_operations)")
|
||||
public class RegionCommands {
|
||||
public class RegionCommands extends MethodCommands{
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
@ -104,6 +104,7 @@ public class RegionCommands {
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public RegionCommands(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
@ -306,13 +307,14 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.replace")
|
||||
@Logging(REGION)
|
||||
public void replace(Player player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to) throws WorldEditException {
|
||||
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to, CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmation(getArguments(context));
|
||||
if (from == null) {
|
||||
from = new ExistingBlockMask(editSession);
|
||||
}
|
||||
int affected = editSession.replaceBlocks(region, from, to);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE).send(player);
|
||||
if (!player.hasPermission("fawe.tips")) BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE).send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -324,7 +326,8 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.set")
|
||||
@Logging(REGION)
|
||||
public void set(Player player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to) throws WorldEditException {
|
||||
public void set(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to, CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmation(getArguments(context));
|
||||
int affected;
|
||||
if (to instanceof BlockPattern) {
|
||||
affected = editSession.setBlocks(selection, ((BlockPattern) to).getBlock());
|
||||
@ -333,7 +336,7 @@ public class RegionCommands {
|
||||
}
|
||||
if (affected != 0) {
|
||||
BBC.OPERATION.send(player, affected);
|
||||
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(player);
|
||||
if (!player.hasPermission("fawe.tips")) BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,6 +516,16 @@ public class UtilityCommands extends MethodCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/confirm" },
|
||||
desc = "Confirm a command"
|
||||
)
|
||||
public void confirm(FawePlayer fp) throws WorldEditException {
|
||||
if (!fp.confirm()) {
|
||||
BBC.NOTHING_CONFIRMED.send(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/help" },
|
||||
usage = "[<command>]",
|
||||
@ -523,7 +533,6 @@ public class UtilityCommands extends MethodCommands {
|
||||
min = 0,
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions("worldedit.help")
|
||||
public void help(Actor actor, CommandContext args) throws WorldEditException {
|
||||
help(args, worldEdit, actor);
|
||||
}
|
||||
@ -852,6 +861,7 @@ public class UtilityCommands extends MethodCommands {
|
||||
aliases = new ArrayList<CommandMapping>(dispatcher.getCommands());
|
||||
} else {
|
||||
aliases = new ArrayList<>(mappings);
|
||||
visited.add(cat);
|
||||
}
|
||||
page = Math.max(0, page);
|
||||
} else if (grouped.size() > 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user