3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 02:20:07 +01:00

pull changes from boy0001/FastAsyncWorldEdit

Dieser Commit ist enthalten in:
Jesse Boyd 2018-09-08 01:31:30 +10:00
Ursprung 6ae0d3f64e
Commit 39a85d54ea
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
4 geänderte Dateien mit 123 neuen und 132 gelöschten Zeilen

Datei anzeigen

@ -219,6 +219,22 @@ public abstract class FawePlayer<T> extends Metadatable {
if (task != null) task.run(); 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) { public void checkAllowedRegion(Region wrappedSelection) {
Region[] allowed = WEManager.IMP.getMask(this, FaweMaskManager.MaskType.OWNER); Region[] allowed = WEManager.IMP.getMask(this, FaweMaskManager.MaskType.OWNER);
HashSet<Region> allowedSet = new HashSet<>(Arrays.asList(allowed)); 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) { public boolean toggle(String perm) {
if (this.hasPermission(perm)) { if (this.hasPermission(perm)) {
this.setPermission(perm, false); this.setPermission(perm, false);

Datei anzeigen

@ -151,7 +151,6 @@ public class ClipboardCommands extends MethodCommands {
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
@Selection Region region, @Switch('e') boolean skipEntities, @Selection Region region, @Switch('e') boolean skipEntities,
@Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException { @Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException {
fp.checkConfirmationRegion(() -> {
Vector min = region.getMinimumPoint(); Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint(); 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)); 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) { if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
} }
Vector pos = session.getPlacementPosition(player);
fp.checkConfirmationRegion(() -> {
session.setClipboard(null); session.setClipboard(null);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
session.setClipboard(new ClipboardHolder(clipboard)); session.setClipboard(new ClipboardHolder(clipboard));
clipboard.setOrigin(session.getPlacementPosition(player)); clipboard.setOrigin(pos);
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setCopyingEntities(!skipEntities); copy.setCopyingEntities(!skipEntities);
copy.setCopyBiomes(copyBiomes); copy.setCopyBiomes(copyBiomes);
@ -241,7 +242,6 @@ public class ClipboardCommands extends MethodCommands {
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean skipEntities, @Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean skipEntities,
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException { @Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException {
fp.checkConfirmationRegion(() -> {
Vector min = region.getMinimumPoint(); Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint(); 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)); 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) { if (volume >= limit.MAX_CHANGES) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES); throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
} }
Vector pos = session.getPlacementPosition(player);
fp.checkConfirmationRegion(() -> {
session.setClipboard(null); session.setClipboard(null);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
clipboard.setOrigin(session.getPlacementPosition(player)); clipboard.setOrigin(pos);
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setSourceFunction(new BlockReplace(editSession, leavePattern)); copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
copy.setCopyingEntities(!skipEntities); copy.setCopyingEntities(!skipEntities);

Datei anzeigen

@ -269,8 +269,6 @@ public class GenerationCommands extends MethodCommands {
player.findFreePosition(); player.findFreePosition();
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
}, getArguments(context), (int) max); }, getArguments(context), (int) max);
} }
@Command( @Command(
@ -366,7 +364,6 @@ public class GenerationCommands extends MethodCommands {
@Switch('o') boolean offset, @Switch('o') boolean offset,
@Switch('c') boolean offsetCenter, @Switch('c') boolean offsetCenter,
CommandContext context) throws WorldEditException, ParameterException { CommandContext context) throws WorldEditException, ParameterException {
fp.checkConfirmationRegion(() -> {
final Vector zero; final Vector zero;
Vector unit; Vector unit;
@ -394,6 +391,7 @@ public class GenerationCommands extends MethodCommands {
if (unit.getZ() == 0) unit.mutZ(1); if (unit.getZ() == 0) unit.mutZ(1);
} }
fp.checkConfirmationRegion(() -> {
try { try {
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow); final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
player.findFreePosition(); player.findFreePosition();
@ -434,7 +432,6 @@ public class GenerationCommands extends MethodCommands {
@Switch('o') boolean offset, @Switch('o') boolean offset,
@Switch('c') boolean offsetCenter, @Switch('c') boolean offsetCenter,
CommandContext context) throws WorldEditException, ParameterException { CommandContext context) throws WorldEditException, ParameterException {
fp.checkConfirmationRegion(() -> {
final Vector zero; final Vector zero;
Vector unit; Vector unit;
@ -461,7 +458,7 @@ public class GenerationCommands extends MethodCommands {
if (unit.getY() == 0) unit.mutY(1); if (unit.getY() == 0) unit.mutY(1);
if (unit.getZ() == 0) unit.mutZ(1); if (unit.getZ() == 0) unit.mutZ(1);
} }
fp.checkConfirmationRegion(() -> {
try { try {
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow); final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
player.findFreePosition(); player.findFreePosition();

Datei anzeigen

@ -465,7 +465,6 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.smoothsnow") @CommandPermissions("worldedit.region.smoothsnow")
@Logging(REGION) @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 { 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 min = region.getMinimumPoint();
Vector max = region.getMaximumPoint(); 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)); 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); throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
} }
player.checkConfirmationRegion(() -> { player.checkConfirmationRegion(() -> {
try {
HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow); HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow);
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1)); HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
int affected = heightMap.applyFilter(filter, iterations); int affected = heightMap.applyFilter(filter, iterations);
BBC.VISITOR_BLOCK.send(player, affected); BBC.VISITOR_BLOCK.send(player, affected);
}, getArguments(context), region);
} catch (Throwable e) { } catch (Throwable e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}, getArguments(context), region);
} }
@Command( @Command(
@ -653,7 +653,6 @@ public class RegionCommands extends MethodCommands {
@Switch('r') boolean useRawCoords, @Switch('r') boolean useRawCoords,
@Switch('o') boolean offset, @Switch('o') boolean offset,
CommandContext context) throws WorldEditException { CommandContext context) throws WorldEditException {
fp.checkConfirmationRegion(() -> {
final Vector zero; final Vector zero;
Vector unit; Vector unit;
@ -674,7 +673,7 @@ public class RegionCommands extends MethodCommands {
if (unit.getY() == 0) unit.mutY(1); if (unit.getY() == 0) unit.mutY(1);
if (unit.getZ() == 0) unit.mutZ(1); if (unit.getZ() == 0) unit.mutZ(1);
} }
fp.checkConfirmationRegion(() -> {
try { try {
final int affected = editSession.deformRegion(region, zero, unit, expression); final int affected = editSession.deformRegion(region, zero, unit, expression);
player.findFreePosition(); player.findFreePosition();