mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
pull changes from boy0001/FastAsyncWorldEdit
This commit is contained in:
parent
6ae0d3f64e
commit
39a85d54ea
@ -219,6 +219,22 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
if (task != null) task.run();
|
||||
}
|
||||
|
||||
public synchronized boolean confirm() {
|
||||
Runnable confirm = deleteMeta("cmdConfirm");
|
||||
if (!(confirm instanceof Runnable)) {
|
||||
return false;
|
||||
}
|
||||
queueAction(() -> {
|
||||
setMeta("cmdConfirmRunning", true);
|
||||
try {
|
||||
confirm.run();
|
||||
} finally {
|
||||
setMeta("cmdConfirmRunning", false);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkAllowedRegion(Region wrappedSelection) {
|
||||
Region[] allowed = WEManager.IMP.getMask(this, FaweMaskManager.MaskType.OWNER);
|
||||
HashSet<Region> allowedSet = new HashSet<>(Arrays.asList(allowed));
|
||||
@ -229,29 +245,6 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean confirm() {
|
||||
Object confirm = deleteMeta("cmdConfirm");
|
||||
if (confirm == null) {
|
||||
return false;
|
||||
}
|
||||
queueAction(() -> {
|
||||
setMeta("cmdConfirmRunning", true);
|
||||
try {
|
||||
if (confirm instanceof String) {
|
||||
CommandEvent event = new CommandEvent(getPlayer(), (String) confirm);
|
||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
} else if (confirm instanceof Runnable) {
|
||||
((Runnable) confirm).run();
|
||||
} else {
|
||||
throw new RuntimeException("Invalid confirm action: " + confirm);
|
||||
}
|
||||
} finally {
|
||||
setMeta("cmdConfirmRunning", false);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean toggle(String perm) {
|
||||
if (this.hasPermission(perm)) {
|
||||
this.setPermission(perm, false);
|
||||
|
@ -151,19 +151,20 @@ public class ClipboardCommands extends MethodCommands {
|
||||
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region, @Switch('e') boolean skipEntities,
|
||||
@Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException {
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
session.setClipboard(null);
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
|
||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||
clipboard.setOrigin(pos);
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||
copy.setCopyingEntities(!skipEntities);
|
||||
copy.setCopyBiomes(copyBiomes);
|
||||
@ -241,20 +242,21 @@ public class ClipboardCommands extends MethodCommands {
|
||||
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean skipEntities,
|
||||
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException {
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
if (volume >= limit.MAX_CHANGES) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
}
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
if (volume >= limit.MAX_CHANGES) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
}
|
||||
session.setClipboard(null);
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||
clipboard.setOrigin(pos);
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
||||
copy.setCopyingEntities(!skipEntities);
|
||||
|
@ -269,8 +269,6 @@ public class GenerationCommands extends MethodCommands {
|
||||
player.findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
}, getArguments(context), (int) max);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -366,34 +364,34 @@ public class GenerationCommands extends MethodCommands {
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter,
|
||||
CommandContext context) throws WorldEditException, ParameterException {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else if (offsetCenter) {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = Vector.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else if (offsetCenter) {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = Vector.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
|
||||
try {
|
||||
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
||||
player.findFreePosition();
|
||||
@ -434,34 +432,33 @@ public class GenerationCommands extends MethodCommands {
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter,
|
||||
CommandContext context) throws WorldEditException, ParameterException {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else if (offsetCenter) {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = Vector.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else if (offsetCenter) {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = Vector.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
|
||||
try {
|
||||
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
|
||||
player.findFreePosition();
|
||||
|
@ -465,23 +465,23 @@ public class RegionCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.region.smoothsnow")
|
||||
@Logging(REGION)
|
||||
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural, @Switch('s') boolean snow, CommandContext context) throws WorldEditException {
|
||||
try {
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
player.checkConfirmationRegion(() -> {
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
player.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow);
|
||||
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
|
||||
int affected = heightMap.applyFilter(filter, iterations);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
}, getArguments(context), region);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, getArguments(context), region);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -653,28 +653,27 @@ public class RegionCommands extends MethodCommands {
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
CommandContext context) throws WorldEditException {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
|
||||
try {
|
||||
final int affected = editSession.deformRegion(region, zero, unit, expression);
|
||||
player.findFreePosition();
|
||||
|
Loading…
Reference in New Issue
Block a user