Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
pull changes from boy0001/FastAsyncWorldEdit
Dieser Commit ist enthalten in:
Ursprung
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,7 +151,6 @@ 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 {
|
||||
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));
|
||||
@ -159,11 +158,13 @@ public class ClipboardCommands extends MethodCommands {
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
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,7 +242,6 @@ 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 {
|
||||
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));
|
||||
@ -252,9 +252,11 @@ public class ClipboardCommands extends MethodCommands {
|
||||
if (volume >= limit.MAX_CHANGES) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
}
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
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,7 +364,6 @@ public class GenerationCommands extends MethodCommands {
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter,
|
||||
CommandContext context) throws WorldEditException, ParameterException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
@ -394,6 +391,7 @@ public class GenerationCommands extends MethodCommands {
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
||||
player.findFreePosition();
|
||||
@ -434,7 +432,6 @@ public class GenerationCommands extends MethodCommands {
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter,
|
||||
CommandContext context) throws WorldEditException, ParameterException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
@ -461,7 +458,7 @@ public class GenerationCommands extends MethodCommands {
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
|
||||
player.findFreePosition();
|
||||
|
@ -465,7 +465,6 @@ 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));
|
||||
@ -474,14 +473,15 @@ public class RegionCommands extends MethodCommands {
|
||||
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);
|
||||
}
|
||||
}, getArguments(context), region);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -653,7 +653,6 @@ public class RegionCommands extends MethodCommands {
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
CommandContext context) throws WorldEditException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
@ -674,7 +673,7 @@ public class RegionCommands extends MethodCommands {
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
}
|
||||
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
final int affected = editSession.deformRegion(region, zero, unit, expression);
|
||||
player.findFreePosition();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren