From 0301fb01243ef2bd57da98a0e562721fc3c0f4e9 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 28 Jul 2024 18:36:04 +0100 Subject: [PATCH] Revert "feat: improve fawe limits (#2773)" This reverts commit 6052fc3128410ec5dc9c2703b497082b8647d22c. --- .../fastasyncworldedit/core/FaweCache.java | 11 +- .../platform/binding/EditSessionHolder.java | 7 - .../platform/binding/ProvideBindings.java | 34 +-- .../core/extent/LimitExtent.java | 208 ++++++++---------- .../extent/filter/block/CharFilterBlock.java | 5 +- .../core/function/mask/ABlockMask.java | 2 +- .../core/function/mask/DataMask.java | 4 +- .../core/function/mask/IdMask.java | 4 +- .../function/mask/SingleBlockStateMask.java | 2 +- .../core/function/mask/SplatterBrushMask.java | 2 +- .../core/limit/ConcurrentFaweLimit.java | 201 ----------------- .../core/limit/FaweLimit.java | 65 ++---- .../core/limit/ProcessorFaweLimit.java | 135 ------------ .../core/queue/IBatchProcessor.java | 2 +- .../java/com/sk89q/worldedit/EditSession.java | 11 +- .../sk89q/worldedit/EditSessionBuilder.java | 16 +- .../com/sk89q/worldedit/LocalSession.java | 17 +- .../worldedit/command/BiomeCommands.java | 2 - .../worldedit/command/BrushCommands.java | 6 +- .../worldedit/command/ClipboardCommands.java | 3 - .../worldedit/command/GenerationCommands.java | 19 +- .../worldedit/command/HistoryCommands.java | 3 - .../worldedit/command/RegionCommands.java | 18 -- .../command/SnapshotUtilCommands.java | 2 - .../worldedit/command/UtilityCommands.java | 62 ++++-- .../worldedit/command/tool/AreaPickaxe.java | 2 +- .../command/tool/BlockDataCyler.java | 2 +- .../worldedit/command/tool/BlockReplacer.java | 2 +- .../worldedit/command/tool/BrushTool.java | 2 +- .../command/tool/FloatingTreeRemover.java | 2 +- .../worldedit/command/tool/FloodFillTool.java | 2 +- .../command/tool/LongRangeBuildTool.java | 4 +- .../command/tool/RecursivePickaxe.java | 2 +- .../worldedit/command/tool/SinglePickaxe.java | 2 +- .../worldedit/command/tool/StackTool.java | 2 +- .../worldedit/command/tool/TreePlanter.java | 2 +- .../worldedit/command/tool/brush/Brush.java | 11 - .../util/annotation/ConfirmHandler.java | 2 +- .../util/annotation/PreloadHandler.java | 2 +- .../SynchronousSettingExpected.java | 22 -- .../command/util/annotation/package-info.java | 1 - .../platform/PlatformCommandManager.java | 23 +- .../worldedit/function/mask/BiomeMask.java | 2 +- .../function/mask/BlockCategoryMask.java | 2 +- .../worldedit/function/mask/BlockMask.java | 2 +- .../function/mask/BlockStateMask.java | 2 +- .../function/mask/BlockTypeMask.java | 2 +- .../function/mask/ExistingBlockMask.java | 2 +- .../mask/InverseSingleBlockStateMask.java | 2 +- .../src/main/resources/lang/strings.json | 2 - 50 files changed, 236 insertions(+), 706 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/EditSessionHolder.java delete mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/ConcurrentFaweLimit.java delete mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/ProcessorFaweLimit.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/SynchronousSettingExpected.java diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java index 3ed494298..526570296 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java @@ -192,22 +192,17 @@ public enum FaweCache implements Trimable { Type.OUTSIDE_REGION ); public static final FaweException MAX_CHECKS = new FaweException( - Caption.of("fawe.cancel.reason.max.checks"), - Type.MAX_CHECKS, - true - ); - public static final FaweException MAX_FAILS = new FaweException( - Caption.of("fawe.cancel.reason.max.fails"), + Caption.of("fawe.cancel.reason.max" + ".checks"), Type.MAX_CHECKS, true ); public static final FaweException MAX_CHANGES = new FaweException( - Caption.of("fawe.cancel.reason.max.changes"), + Caption.of("fawe.cancel.reason.max" + ".changes"), Type.MAX_CHANGES, false ); public static final FaweException LOW_MEMORY = new FaweException( - Caption.of("fawe.cancel.reason.low.memory"), + Caption.of("fawe.cancel.reason.low" + ".memory"), Type.LOW_MEMORY, false ); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/EditSessionHolder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/EditSessionHolder.java deleted file mode 100644 index 1fd588ec4..000000000 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/EditSessionHolder.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fastasyncworldedit.core.extension.platform.binding; - -import com.sk89q.worldedit.EditSession; - -public record EditSessionHolder(EditSession session) { - -} diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java index 3e38b1724..bc1e2bfbf 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java @@ -3,11 +3,7 @@ package com.fastasyncworldedit.core.extension.platform.binding; import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.database.DBHandler; import com.fastasyncworldedit.core.database.RollbackDatabase; -import com.fastasyncworldedit.core.extent.LimitExtent; -import com.fastasyncworldedit.core.extent.processor.ExtentBatchProcessorHolder; -import com.fastasyncworldedit.core.internal.exception.FaweException; import com.fastasyncworldedit.core.regions.FaweMaskManager; -import com.fastasyncworldedit.core.util.ExtentTraverser; import com.fastasyncworldedit.core.util.TextureUtil; import com.fastasyncworldedit.core.util.image.ImageUtil; import com.sk89q.worldedit.EditSession; @@ -15,7 +11,6 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.argument.Arguments; import com.sk89q.worldedit.command.util.annotation.AllowedRegion; -import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.platform.Actor; @@ -30,7 +25,6 @@ import org.enginehub.piston.inject.Key; import org.enginehub.piston.util.ValueProvider; import java.awt.image.BufferedImage; -import java.lang.reflect.Method; import java.net.URI; import java.util.Optional; @@ -58,33 +52,11 @@ public class ProvideBindings extends Bindings { @Binding public EditSession editSession(LocalSession localSession, Actor actor, InjectedValueAccess context) { - Method commandMethod = - context.injectedValue(Key.of(InjectedValueStore.class)).get().injectedValue(Key.of(Method.class)).get(); - Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null); String command = arguments == null ? null : arguments.get(); - boolean synchronousSetting = commandMethod.getAnnotation(SynchronousSettingExpected.class) != null; - EditSessionHolder holder = context.injectedValue(Key.of(EditSessionHolder.class)).orElse(null); - EditSession editSession = holder != null ? holder.session() : null; - if (editSession == null) { - editSession = localSession.createEditSession(actor, command, synchronousSetting); - editSession.enableStandardMode(); - } else { - LimitExtent limitExtent = new ExtentTraverser<>(editSession).findAndGet(LimitExtent.class); - if (limitExtent != null) { - limitExtent.setProcessing(!synchronousSetting); - if (!synchronousSetting) { - ExtentBatchProcessorHolder processorHolder = new ExtentTraverser<>(editSession).findAndGet( - ExtentBatchProcessorHolder.class); - if (processorHolder != null) { - processorHolder.addProcessor(limitExtent); - } else { - throw new FaweException(Caption.of("fawe.error.no-process-non-synchronous-edit")); - } - } - } - Request.request().setEditSession(editSession); - } + EditSession editSession = localSession.createEditSession(actor, command); + editSession.enableStandardMode(); + Request.request().setEditSession(editSession); return editSession; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/LimitExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/LimitExtent.java index 33f19bfaa..d02ff9320 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/LimitExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/LimitExtent.java @@ -1,17 +1,11 @@ package com.fastasyncworldedit.core.extent; import com.fastasyncworldedit.core.extent.filter.block.ExtentFilterBlock; -import com.fastasyncworldedit.core.extent.processor.ProcessorScope; +import com.fastasyncworldedit.core.function.generator.GenBase; +import com.fastasyncworldedit.core.function.generator.Resource; import com.fastasyncworldedit.core.internal.exception.FaweException; -import com.fastasyncworldedit.core.limit.ConcurrentFaweLimit; import com.fastasyncworldedit.core.limit.FaweLimit; -import com.fastasyncworldedit.core.limit.ProcessorFaweLimit; import com.fastasyncworldedit.core.queue.Filter; -import com.fastasyncworldedit.core.queue.IBatchProcessor; -import com.fastasyncworldedit.core.queue.IChunk; -import com.fastasyncworldedit.core.queue.IChunkGet; -import com.fastasyncworldedit.core.queue.IChunkSet; -import com.fastasyncworldedit.core.util.ExtentTraverser; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; @@ -23,6 +17,7 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.Component; @@ -42,22 +37,18 @@ import java.util.Set; import java.util.UUID; import java.util.function.Consumer; -public class LimitExtent extends AbstractDelegateExtent implements IBatchProcessor { +public class LimitExtent extends AbstractDelegateExtent { private final FaweLimit limit; private final boolean[] faweExceptionReasonsUsed = new boolean[FaweException.Type.values().length]; private final Consumer onErrorMessage; - private final int chunk_size; - private boolean processing; /** * Create a new instance. * * @param extent the extent * @param limit the limit - * @deprecated Use {@link LimitExtent#LimitExtent(Extent, FaweLimit, Consumer, boolean, boolean)} */ - @Deprecated(forRemoval = true, since = "TODO") public LimitExtent(Extent extent, FaweLimit limit) { this(extent, limit, c -> { }); @@ -69,41 +60,11 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess * @param extent the extent * @param limit the limit * @param onErrorMessage consumer to handle a component generated by exceptions - * @deprecated Use {@link LimitExtent#LimitExtent(Extent, FaweLimit, Consumer, boolean, boolean)} */ - @Deprecated(forRemoval = true, since = "TODO") public LimitExtent(Extent extent, FaweLimit limit, Consumer onErrorMessage) { - this(extent, limit, onErrorMessage, false, false); - } - - /** - * Create a new instance. - * - * @param extent the extent - * @param limit the limit - * @param onErrorMessage consumer to handle a component generated by exceptions - * @param processing if this limit extent is expected to be processing - * @param expectSynchronousSetting if synchronous block setting is expected - * @since TODO - */ - public LimitExtent( - Extent extent, - FaweLimit limit, - Consumer onErrorMessage, - boolean processing, - boolean expectSynchronousSetting - ) { super(extent); - if (!expectSynchronousSetting) { - this.limit = new ConcurrentFaweLimit(limit); - } else if (processing) { - this.limit = new ProcessorFaweLimit(limit); - } else { - this.limit = limit; - } + this.limit = limit; this.onErrorMessage = onErrorMessage; - this.chunk_size = 16 * 16 * (extent.getMaxY() - extent.getMinY()); - this.processing = !expectSynchronousSetting; } private void handleException(FaweException e) { @@ -120,7 +81,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public List getEntities(Region region) { limit.THROW_MAX_CHECKS(region.getVolume()); try { - return extent.getEntities(region); + return super.getEntities(region); } catch (FaweException e) { handleException(e); return Collections.emptyList(); @@ -131,7 +92,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public List getEntities() { limit.THROW_MAX_CHECKS(); try { - return extent.getEntities(); + return super.getEntities(); } catch (FaweException e) { handleException(e); return Collections.emptyList(); @@ -144,7 +105,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess limit.THROW_MAX_CHANGES(); limit.THROW_MAX_ENTITIES(); try { - return extent.createEntity(location, entity); + return super.createEntity(location, entity); } catch (FaweException e) { handleException(e); return null; @@ -157,7 +118,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess limit.THROW_MAX_CHANGES(); limit.THROW_MAX_ENTITIES(); try { - return extent.createEntity(location, entity, uuid); + return super.createEntity(location, entity, uuid); } catch (FaweException e) { handleException(e); return null; @@ -169,7 +130,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess limit.THROW_MAX_CHANGES(); limit.THROW_MAX_ENTITIES(); try { - extent.removeEntity(x, y, z, uuid); + super.removeEntity(x, y, z, uuid); } catch (FaweException e) { handleException(e); } @@ -177,9 +138,9 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess @Override public boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed) { - limit.THROW_MAX_CHANGES(chunk_size); + limit.THROW_MAX_CHANGES(Character.MAX_VALUE); try { - return extent.regenerateChunk(x, z, type, seed); + return super.regenerateChunk(x, z, type, seed); } catch (FaweException e) { handleException(e); return false; @@ -190,7 +151,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { limit.THROW_MAX_CHECKS(maxY - minY + 1); try { - return extent.getHighestTerrainBlock(x, z, minY, maxY); + return super.getHighestTerrainBlock(x, z, minY, maxY); } catch (FaweException e) { handleException(e); return minY; @@ -201,7 +162,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { limit.THROW_MAX_CHECKS(maxY - minY + 1); try { - return extent.getHighestTerrainBlock(x, z, minY, maxY, filter); + return super.getHighestTerrainBlock(x, z, minY, maxY, filter); } catch (FaweException e) { handleException(e); return minY; @@ -212,7 +173,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) { limit.THROW_MAX_CHECKS(maxY - minY + 1); try { - return extent.getNearestSurfaceLayer(x, z, y, minY, maxY); + return super.getNearestSurfaceLayer(x, z, y, minY, maxY); } catch (FaweException e) { handleException(e); return minY; @@ -223,7 +184,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) { limit.THROW_MAX_CHECKS(maxY - minY + 1); try { - return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir); + return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir); } catch (FaweException e) { handleException(e); return minY; @@ -234,7 +195,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) { limit.THROW_MAX_CHECKS(maxY - minY + 1); try { - return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY); + return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY); } catch (FaweException e) { handleException(e); return minY; @@ -245,7 +206,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) { limit.THROW_MAX_CHECKS(maxY - minY + 1); try { - return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax); + return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax); } catch (FaweException e) { handleException(e); return minY; @@ -256,7 +217,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) { limit.THROW_MAX_CHECKS(maxY - minY + 1); try { - return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask); + return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask); } catch (FaweException e) { handleException(e); return minY; @@ -276,47 +237,91 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess ) { limit.THROW_MAX_CHECKS(maxY - minY + 1); try { - return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir); + return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir); } catch (FaweException e) { handleException(e); return minY; } } + @Override + public void addCaves(Region region) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); + super.addCaves(region); + } + + @Override + public void generate(Region region, GenBase gen) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); + super.generate(region, gen); + } + + @Override + public void addSchems(Region region, Mask mask, List clipboards, int rarity, boolean rotate) throws + WorldEditException { + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); + super.addSchems(region, mask, clipboards, rarity, rotate); + } + + @Override + public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); + super.spawnResource(region, gen, rarity, frequency); + } + + @Override + public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws + WorldEditException { + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); + super.addOre(region, mask, material, size, frequency, rarity, minY, maxY); + } + + @Override + public void addOres(Region region, Mask mask) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); + super.addOres(region, mask); + } + @Override public List> getBlockDistribution(Region region) { limit.THROW_MAX_CHECKS(region.getVolume()); - return extent.getBlockDistribution(region); + return super.getBlockDistribution(region); } @Override public List> getBlockDistributionWithData(Region region) { limit.THROW_MAX_CHECKS(region.getVolume()); - return extent.getBlockDistributionWithData(region); + return super.getBlockDistributionWithData(region); } @Override public int countBlocks(Region region, Set searchBlocks) { limit.THROW_MAX_CHECKS(region.getVolume()); - return extent.countBlocks(region, searchBlocks); + return super.countBlocks(region, searchBlocks); } @Override public int countBlocks(Region region, Mask searchMask) { limit.THROW_MAX_CHECKS(region.getVolume()); - return extent.countBlocks(region, searchMask); + return super.countBlocks(region, searchMask); } @Override public > int setBlocks(Region region, B block) throws MaxChangedBlocksException { limit.THROW_MAX_CHANGES(region.getVolume()); - return extent.setBlocks(region, block); + return super.setBlocks(region, block); } @Override public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException { limit.THROW_MAX_CHANGES(region.getVolume()); - return extent.setBlocks(region, pattern); + return super.setBlocks(region, pattern); } @Override @@ -324,34 +329,41 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess MaxChangedBlocksException { limit.THROW_MAX_CHECKS(region.getVolume()); limit.THROW_MAX_CHANGES(region.getVolume()); - return extent.replaceBlocks(region, filter, replacement); + return super.replaceBlocks(region, filter, replacement); } @Override public int replaceBlocks(Region region, Set filter, Pattern pattern) throws MaxChangedBlocksException { limit.THROW_MAX_CHECKS(region.getVolume()); limit.THROW_MAX_CHANGES(region.getVolume()); - return extent.replaceBlocks(region, filter, pattern); + return super.replaceBlocks(region, filter, pattern); } @Override public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException { limit.THROW_MAX_CHECKS(region.getVolume()); limit.THROW_MAX_CHANGES(region.getVolume()); - return extent.replaceBlocks(region, mask, pattern); + return super.replaceBlocks(region, mask, pattern); + } + + @Override + public int center(Region region, Pattern pattern) throws MaxChangedBlocksException { + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); + return super.center(region, pattern); } @Override public int setBlocks(Set vset, Pattern pattern) { limit.THROW_MAX_CHANGES(vset.size()); - return extent.setBlocks(vset, pattern); + return super.setBlocks(vset, pattern); } @Override public T apply(Region region, T filter, boolean full) { limit.THROW_MAX_CHECKS(region.getVolume()); limit.THROW_MAX_CHANGES(region.getVolume()); - return extent.apply(region, filter, full); + return super.apply(region, filter, full); } @Override @@ -381,14 +393,14 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess } limit.THROW_MAX_CHECKS(size); limit.THROW_MAX_CHANGES(size); - return extent.apply(positions, filter); + return super.apply(positions, filter); } @Override public BlockState getBlock(BlockVector3 position) { limit.THROW_MAX_CHECKS(); try { - return extent.getBlock(position); + return super.getBlock(position); } catch (FaweException e) { handleException(e); return BlockTypes.AIR.getDefaultState(); @@ -399,7 +411,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public BlockState getBlock(int x, int y, int z) { limit.THROW_MAX_CHECKS(); try { - return extent.getBlock(x, y, z); + return super.getBlock(x, y, z); } catch (FaweException e) { handleException(e); return BlockTypes.AIR.getDefaultState(); @@ -410,7 +422,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public BaseBlock getFullBlock(BlockVector3 position) { limit.THROW_MAX_CHECKS(); try { - return extent.getFullBlock(position); + return super.getFullBlock(position); } catch (FaweException e) { handleException(e); return BlockTypes.AIR.getDefaultState().toBaseBlock(); @@ -421,7 +433,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public BaseBlock getFullBlock(int x, int y, int z) { limit.THROW_MAX_CHECKS(); try { - return extent.getFullBlock(x, y, z); + return super.getFullBlock(x, y, z); } catch (FaweException e) { handleException(e); return BlockTypes.AIR.getDefaultState().toBaseBlock(); @@ -432,7 +444,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public BiomeType getBiome(BlockVector3 position) { limit.THROW_MAX_CHECKS(); try { - return extent.getBiome(position); + return super.getBiome(position); } catch (FaweException e) { handleException(e); return BiomeTypes.FOREST; @@ -443,7 +455,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public BiomeType getBiomeType(int x, int y, int z) { limit.THROW_MAX_CHECKS(); try { - return extent.getBiomeType(x, y, z); + return super.getBiomeType(x, y, z); } catch (FaweException e) { handleException(e); return BiomeTypes.FOREST; @@ -458,7 +470,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess limit.THROW_MAX_BLOCKSTATES(); } try { - return extent.setBlock(position, block); + return super.setBlock(position, block); } catch (FaweException e) { handleException(e); return false; @@ -472,7 +484,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess limit.THROW_MAX_BLOCKSTATES(); } try { - return extent.setBlock(x, y, z, block); + return super.setBlock(x, y, z, block); } catch (FaweException e) { handleException(e); return false; @@ -482,9 +494,9 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess @Override public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { limit.THROW_MAX_CHANGES(); - limit.THROW_MAX_BLOCKSTATES(); + limit.MAX_BLOCKSTATES(); try { - return extent.setTile(x, y, z, tile); + return super.setTile(x, y, z, tile); } catch (FaweException e) { handleException(e); return false; @@ -495,7 +507,7 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public boolean setBiome(BlockVector3 position, BiomeType biome) { limit.THROW_MAX_CHANGES(); try { - return extent.setBiome(position, biome); + return super.setBiome(position, biome); } catch (FaweException e) { handleException(e); return false; @@ -506,41 +518,11 @@ public class LimitExtent extends AbstractDelegateExtent implements IBatchProcess public boolean setBiome(int x, int y, int z, BiomeType biome) { limit.THROW_MAX_CHANGES(); try { - return extent.setBiome(x, y, z, biome); + return super.setBiome(x, y, z, biome); } catch (FaweException e) { handleException(e); return false; } } - public void setProcessing(boolean processing) { - this.processing = processing; - } - - @Override - public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) { - if (!processing) { - return set; - } - int tiles = set.getTiles().size(); - int ents = set.getEntities().size() + set.getEntityRemoves().size(); - limit.THROW_MAX_CHANGES(tiles + ents); - limit.THROW_MAX_BLOCKSTATES(tiles); - limit.THROW_MAX_ENTITIES(ents); - return set; - } - - @Override - public Extent construct(final Extent child) { - if (extent != child) { - new ExtentTraverser(this).setNext(child); - } - return this; - } - - @Override - public ProcessorScope getScope() { - return ProcessorScope.READING_SET_BLOCKS; - } - } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java index f569ff0bb..579f04a9a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java @@ -170,13 +170,10 @@ public class CharFilterBlock extends ChunkFilterBlock { @Override public synchronized final void filter(Filter filter) { - initSet(); for (y = 0, index = 0; y < 16; y++) { for (z = 0; z < 16; z++) { for (x = 0; x < 16; x++, index++) { - if (setArr[index] != BlockTypesCache.ReservedIDs.__RESERVED__) { - filter.applyBlock(this); - } + filter.applyBlock(this); } } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ABlockMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ABlockMask.java index ed5b028dd..7fdebdded 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ABlockMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ABlockMask.java @@ -26,7 +26,7 @@ public abstract class ABlockMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { - return test(vector.getBlock(getExtent())); + return test(getExtent().getBlock(vector)); } public abstract boolean test(BlockState state); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/DataMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/DataMask.java index 84b8f77ad..2b3ad7edb 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/DataMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/DataMask.java @@ -16,9 +16,9 @@ public class DataMask extends AbstractExtentMask implements ResettableMask { @Override public boolean test(BlockVector3 vector) { if (data != -1) { - return vector.getBlock(getExtent()).getInternalPropertiesId() == data; + return getExtent().getBlock(vector).getInternalPropertiesId() == data; } else { - data = vector.getBlock(getExtent()).getInternalPropertiesId(); + data = getExtent().getBlock(vector).getInternalPropertiesId(); return true; } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/IdMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/IdMask.java index b0ba4fb59..49c90183a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/IdMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/IdMask.java @@ -24,9 +24,7 @@ public class IdMask extends AbstractExtentMask implements ResettableMask { @Override public boolean test(BlockVector3 vector) { - int blockID = vector.getBlock(getExtent()).getInternalBlockTypeId(); - int testId = id.compareAndExchange(-1, blockID); - return blockID == testId || testId == -1; + return test(getExtent(), vector); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SingleBlockStateMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SingleBlockStateMask.java index 400f32163..32d853bda 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SingleBlockStateMask.java @@ -30,7 +30,7 @@ public class SingleBlockStateMask extends ABlockMask { @Override public boolean test(BlockVector3 vector) { - int test = vector.getBlock(getExtent()).getOrdinal(); + int test = getExtent().getBlock(vector).getOrdinal(); return ordinal == test || isAir && test == 0; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SplatterBrushMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SplatterBrushMask.java index d80399be4..250969616 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SplatterBrushMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SplatterBrushMask.java @@ -40,7 +40,7 @@ public class SplatterBrushMask extends AbstractExtentMask { double dist = vector.distanceSq(position); synchronized (placed) { if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2 && surface.test(vector)) { - placed.add(vector.toImmutable()); + placed.add(vector); return true; } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/ConcurrentFaweLimit.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/ConcurrentFaweLimit.java deleted file mode 100644 index 91ec1621d..000000000 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/ConcurrentFaweLimit.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.fastasyncworldedit.core.limit; - -import com.fastasyncworldedit.core.FaweCache; - -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - -/** - * Allows concurrent limit calculations - * - * @since TODO - */ -public class ConcurrentFaweLimit extends FaweLimit { - - public AtomicLong ATOMIC_MAX_CHANGES = new AtomicLong(); - public AtomicInteger ATOMIC_MAX_FAILS = new AtomicInteger(); - public AtomicLong ATOMIC_MAX_CHECKS = new AtomicLong(); - public AtomicInteger ATOMIC_MAX_ITERATIONS = new AtomicInteger(); - public AtomicInteger ATOMIC_MAX_BLOCKSTATES = new AtomicInteger(); - public AtomicInteger ATOMIC_MAX_ENTITIES = new AtomicInteger(); - - public ConcurrentFaweLimit(FaweLimit other) { - set(other); - } - - @Override - public boolean MAX_CHANGES() { - return ATOMIC_MAX_CHANGES.decrementAndGet() < 0; - } - - @Override - public boolean MAX_FAILS() { - return ATOMIC_MAX_FAILS.decrementAndGet() < 0; - } - - @Override - public boolean MAX_CHECKS() { - return ATOMIC_MAX_CHECKS.decrementAndGet() < 0; - } - - @Override - public boolean MAX_ITERATIONS() { - return ATOMIC_MAX_ITERATIONS.decrementAndGet() < 0; - } - - @Override - public boolean MAX_BLOCKSTATES() { - return ATOMIC_MAX_BLOCKSTATES.decrementAndGet() < 0; - } - - @Override - public boolean MAX_ENTITIES() { - return ATOMIC_MAX_ENTITIES.decrementAndGet() < 0; - } - - @Override - public void THROW_MAX_CHANGES() { - if (ATOMIC_MAX_CHANGES.decrementAndGet() < 0) { - throw FaweCache.MAX_CHANGES; - } - } - - @Override - public void THROW_MAX_FAILS() { - if (ATOMIC_MAX_FAILS.decrementAndGet() < 0) { - throw FaweCache.MAX_FAILS; - } - } - - @Override - public void THROW_MAX_CHECKS() { - if (ATOMIC_MAX_CHECKS.decrementAndGet() < 0) { - throw FaweCache.MAX_CHECKS; - } - } - - @Override - public void THROW_MAX_ITERATIONS() { - if (ATOMIC_MAX_ITERATIONS.decrementAndGet() < 0) { - throw FaweCache.MAX_ITERATIONS; - } - } - - @Override - public void THROW_MAX_BLOCKSTATES() { - if (ATOMIC_MAX_BLOCKSTATES.decrementAndGet() < 0) { - throw FaweCache.MAX_TILES; - } - } - - @Override - public void THROW_MAX_ENTITIES() { - if (ATOMIC_MAX_ENTITIES.decrementAndGet() < 0) { - throw FaweCache.MAX_ENTITIES; - } - } - - @Override - public void THROW_MAX_CHANGES(int amt) { - if (amt == 0) { - return; - } - if (ATOMIC_MAX_CHANGES.addAndGet(-amt) < 0) { - throw FaweCache.MAX_CHANGES; - } - } - - @Override - public void THROW_MAX_CHANGES(long amt) { - if (amt == 0) { - return; - } - if (ATOMIC_MAX_CHANGES.addAndGet(-amt) < 0) { - throw FaweCache.MAX_CHANGES; - } - } - - @Override - public void THROW_MAX_FAILS(int amt) { - if (amt == 0) { - return; - } - if (ATOMIC_MAX_FAILS.addAndGet(-amt) < 0) { - throw FaweCache.MAX_FAILS; - } - } - - @Override - public void THROW_MAX_CHECKS(int amt) { - if (amt == 0) { - return; - } - if (ATOMIC_MAX_CHECKS.addAndGet(-amt) < 0) { - throw FaweCache.MAX_CHECKS; - } - } - - @Override - public void THROW_MAX_CHECKS(long amt) { - if (amt == 0) { - return; - } - if (ATOMIC_MAX_CHECKS.addAndGet(-amt) < 0) { - throw FaweCache.MAX_CHECKS; - } - } - - @Override - public void THROW_MAX_ITERATIONS(int amt) { - if (amt == 0) { - return; - } - if (ATOMIC_MAX_ITERATIONS.addAndGet(-amt) < 0) { - throw FaweCache.MAX_ITERATIONS; - } - } - - @Override - public void THROW_MAX_BLOCKSTATES(int amt) { - if (amt == 0) { - return; - } - if (ATOMIC_MAX_BLOCKSTATES.addAndGet(-amt) < 0) { - throw FaweCache.MAX_TILES; - } - } - - @Override - public void THROW_MAX_ENTITIES(int amt) { - if (amt == 0) { - return; - } - if (ATOMIC_MAX_ENTITIES.addAndGet(-amt) < 0) { - throw FaweCache.MAX_ENTITIES; - } - } - - @Override - public void set(FaweLimit other) { - super.set(other); - ATOMIC_MAX_CHANGES.set(other.MAX_CHANGES); - ATOMIC_MAX_FAILS.set(other.MAX_FAILS); - ATOMIC_MAX_CHECKS.set(other.MAX_CHECKS); - ATOMIC_MAX_ITERATIONS.set(other.MAX_ITERATIONS); - ATOMIC_MAX_BLOCKSTATES.set(other.MAX_BLOCKSTATES); - ATOMIC_MAX_ENTITIES.set(other.MAX_ENTITIES); - } - - @Override - public FaweLimit getLimitUsed(FaweLimit originalLimit) { - FaweLimit newLimit = new FaweLimit(); - newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - this.ATOMIC_MAX_CHANGES.get(); - newLimit.MAX_FAILS = originalLimit.MAX_FAILS - this.ATOMIC_MAX_FAILS.get(); - newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - this.ATOMIC_MAX_CHECKS.get(); - newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - this.ATOMIC_MAX_ITERATIONS.get(); - newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - this.ATOMIC_MAX_BLOCKSTATES.get(); - newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - this.ATOMIC_MAX_ENTITIES.get(); - return newLimit; - } - -} diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java index f7a99dd35..d17787f03 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java @@ -1,7 +1,6 @@ package com.fastasyncworldedit.core.limit; import com.fastasyncworldedit.core.FaweCache; -import com.fastasyncworldedit.core.internal.exception.FaweException; import com.fastasyncworldedit.core.configuration.Settings; import java.util.Collections; @@ -10,12 +9,12 @@ import java.util.Set; public class FaweLimit { public int MAX_ACTIONS = 0; - public volatile long MAX_CHANGES = 0; - public volatile int MAX_FAILS = 0; - public volatile long MAX_CHECKS = 0; - public volatile int MAX_ITERATIONS = 0; - public volatile int MAX_BLOCKSTATES = 0; - public volatile int MAX_ENTITIES = 0; + public long MAX_CHANGES = 0; + public int MAX_FAILS = 0; + public long MAX_CHECKS = 0; + public int MAX_ITERATIONS = 0; + public int MAX_BLOCKSTATES = 0; + public int MAX_ENTITIES = 0; public int MAX_HISTORY = 0; public int SCHEM_FILE_SIZE_LIMIT = 0; public int SCHEM_FILE_NUM_LIMIT = 0; @@ -162,85 +161,85 @@ public class FaweLimit { return MAX_ENTITIES-- > 0; } - public void THROW_MAX_CHANGES() throws FaweException { + public void THROW_MAX_CHANGES() { if (MAX_CHANGES-- <= 0) { throw FaweCache.MAX_CHANGES; } } - public void THROW_MAX_FAILS() throws FaweException { + public void THROW_MAX_FAILS() { if (MAX_FAILS-- <= 0) { - throw FaweCache.MAX_FAILS; + throw FaweCache.MAX_CHECKS; } } - public void THROW_MAX_CHECKS() throws FaweException { + public void THROW_MAX_CHECKS() { if (MAX_CHECKS-- <= 0) { throw FaweCache.MAX_CHECKS; } } - public void THROW_MAX_ITERATIONS() throws FaweException { + public void THROW_MAX_ITERATIONS() { if (MAX_ITERATIONS-- <= 0) { throw FaweCache.MAX_ITERATIONS; } } - public void THROW_MAX_BLOCKSTATES() throws FaweException { + public void THROW_MAX_BLOCKSTATES() { if (MAX_BLOCKSTATES-- <= 0) { throw FaweCache.MAX_TILES; } } - public void THROW_MAX_ENTITIES() throws FaweException { + public void THROW_MAX_ENTITIES() { if (MAX_ENTITIES-- <= 0) { throw FaweCache.MAX_ENTITIES; } } - public void THROW_MAX_CHANGES(int amt) throws FaweException { + public void THROW_MAX_CHANGES(int amt) { if ((MAX_CHANGES -= amt) <= 0) { throw FaweCache.MAX_CHANGES; } } - public void THROW_MAX_CHANGES(long amt) throws FaweException { + public void THROW_MAX_CHANGES(long amt) { if ((MAX_CHANGES -= amt) <= 0) { throw FaweCache.MAX_CHANGES; } } - public void THROW_MAX_FAILS(int amt) throws FaweException { + public void THROW_MAX_FAILS(int amt) { if ((MAX_FAILS -= amt) <= 0) { - throw FaweCache.MAX_FAILS; + throw FaweCache.MAX_CHECKS; } } - public void THROW_MAX_CHECKS(int amt) throws FaweException { + public void THROW_MAX_CHECKS(int amt) { if ((MAX_CHECKS -= amt) <= 0) { throw FaweCache.MAX_CHECKS; } } - public void THROW_MAX_CHECKS(long amt) throws FaweException { + public void THROW_MAX_CHECKS(long amt) { if ((MAX_CHECKS -= amt) <= 0) { throw FaweCache.MAX_CHECKS; } } - public void THROW_MAX_ITERATIONS(int amt) throws FaweException { + public void THROW_MAX_ITERATIONS(int amt) { if ((MAX_ITERATIONS -= amt) <= 0) { throw FaweCache.MAX_ITERATIONS; } } - public void THROW_MAX_BLOCKSTATES(int amt) throws FaweException { + public void THROW_MAX_BLOCKSTATES(int amt) { if ((MAX_BLOCKSTATES -= amt) <= 0) { throw FaweCache.MAX_TILES; } } - public void THROW_MAX_ENTITIES(int amt) throws FaweException { + public void THROW_MAX_ENTITIES(int amt) { if ((MAX_ENTITIES -= amt) <= 0) { throw FaweCache.MAX_ENTITIES; } @@ -271,22 +270,6 @@ public class FaweLimit { && MAX_BUTCHER_RADIUS == Integer.MAX_VALUE; } - /** - * Get an {@link FaweLimit} representing the amount of a limit used from a given "original" limit - * - * @since TODO - */ - public FaweLimit getLimitUsed(FaweLimit originalLimit) { - FaweLimit newLimit = new FaweLimit(); - newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - this.MAX_CHANGES; - newLimit.MAX_FAILS = originalLimit.MAX_FAILS - this.MAX_FAILS; - newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - this.MAX_CHECKS; - newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - this.MAX_ITERATIONS; - newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - this.MAX_BLOCKSTATES; - newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - this.MAX_ENTITIES; - return newLimit; - } - public void set(FaweLimit limit) { MAX_ACTIONS = limit.MAX_ACTIONS; MAX_CHANGES = limit.MAX_CHANGES; @@ -348,8 +331,4 @@ public class FaweLimit { return MAX_CHANGES + ""; } - public ProcessorFaweLimit toConcurrent() { - return new ProcessorFaweLimit(this); - } - } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/ProcessorFaweLimit.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/ProcessorFaweLimit.java deleted file mode 100644 index 47c97a78b..000000000 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/ProcessorFaweLimit.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.fastasyncworldedit.core.limit; - -import com.fastasyncworldedit.core.FaweCache; - -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - -/** - * Allows concurrent limit calculations for THROW_MAX_XXX(amount) methods. Other methods use the default implementations in - * {@link FaweLimit} - * - * @since TODO - */ -public class ProcessorFaweLimit extends FaweLimit { - - public AtomicLong ATOMIC_MAX_CHANGES = new AtomicLong(); - public AtomicInteger ATOMIC_MAX_FAILS = new AtomicInteger(); - public AtomicLong ATOMIC_MAX_CHECKS = new AtomicLong(); - public AtomicInteger ATOMIC_MAX_ITERATIONS = new AtomicInteger(); - public AtomicInteger ATOMIC_MAX_BLOCKSTATES = new AtomicInteger(); - public AtomicInteger ATOMIC_MAX_ENTITIES = new AtomicInteger(); - - public ProcessorFaweLimit(FaweLimit other) { - set(other); - } - - @Override - public void THROW_MAX_CHANGES(int amt) { - if (amt == 0) { - return; - } - final long changes = MAX_CHANGES; - if (ATOMIC_MAX_CHANGES.updateAndGet(i -> (MAX_CHANGES = Math.min(i, changes) - amt)) < 0) { - throw FaweCache.MAX_CHANGES; - } - } - - @Override - public void THROW_MAX_CHANGES(long amt) { - if (amt == 0) { - return; - } - final long changes = MAX_CHANGES; - if (ATOMIC_MAX_CHANGES.updateAndGet(i -> (MAX_CHANGES = Math.min(i, changes) - amt))< 0) { - throw FaweCache.MAX_CHANGES; - } - } - - @Override - public void THROW_MAX_FAILS(int amt) { - if (amt == 0) { - return; - } - final int fails = MAX_FAILS; - if (ATOMIC_MAX_FAILS.updateAndGet(i -> (MAX_FAILS = Math.min(i, fails) - amt)) < 0) { - throw FaweCache.MAX_FAILS; - } - } - - @Override - public void THROW_MAX_CHECKS(int amt) { - final long checks = MAX_CHECKS; - if (ATOMIC_MAX_CHECKS.updateAndGet(i -> (MAX_CHECKS = Math.min(i, checks) - amt)) < 0) { - throw FaweCache.MAX_CHECKS; - } - } - - @Override - public void THROW_MAX_CHECKS(long amt) { - if (amt == 0) { - return; - } - final long checks = MAX_CHECKS; - if (ATOMIC_MAX_CHECKS.updateAndGet(i -> (MAX_CHECKS = Math.min(i, checks) - amt)) < 0) { - throw FaweCache.MAX_CHECKS; - } - } - - @Override - public void THROW_MAX_ITERATIONS(int amt) { - if (amt == 0) { - return; - } - final int iterations = MAX_ITERATIONS; - if (ATOMIC_MAX_ITERATIONS.updateAndGet(i -> (MAX_ITERATIONS = Math.min(i, iterations) - amt)) < 0) { - throw FaweCache.MAX_ITERATIONS; - } - } - - @Override - public void THROW_MAX_BLOCKSTATES(int amt) { - if (amt == 0) { - return; - } - final int states = MAX_BLOCKSTATES; - if (ATOMIC_MAX_BLOCKSTATES.updateAndGet(i -> (MAX_BLOCKSTATES = Math.min(i, states) - amt)) < 0) { - throw FaweCache.MAX_TILES; - } - } - - @Override - public void THROW_MAX_ENTITIES(int amt) { - if (amt == 0) { - return; - } - final int entities = MAX_ENTITIES; - if (ATOMIC_MAX_ENTITIES.updateAndGet(i -> (MAX_ENTITIES = Math.min(i, entities) - amt)) < 0) { - throw FaweCache.MAX_ENTITIES; - } - } - - @Override - public void set(FaweLimit other) { - super.set(other); - ATOMIC_MAX_CHANGES.set(other.MAX_CHANGES); - ATOMIC_MAX_FAILS.set(other.MAX_FAILS); - ATOMIC_MAX_CHECKS.set(other.MAX_CHECKS); - ATOMIC_MAX_ITERATIONS.set(other.MAX_ITERATIONS); - ATOMIC_MAX_BLOCKSTATES.set(other.MAX_BLOCKSTATES); - ATOMIC_MAX_ENTITIES.set(other.MAX_ENTITIES); - } - - @Override - public FaweLimit getLimitUsed(FaweLimit originalLimit) { - FaweLimit newLimit = new FaweLimit(); - newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - Math.min(this.ATOMIC_MAX_CHANGES.get(), MAX_CHANGES); - newLimit.MAX_FAILS = originalLimit.MAX_FAILS - Math.min(this.ATOMIC_MAX_FAILS.get(), MAX_FAILS); - newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - Math.min(this.ATOMIC_MAX_CHECKS.get(), MAX_CHECKS); - newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - Math.min(this.ATOMIC_MAX_ITERATIONS.get(), MAX_ITERATIONS); - newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - Math.min(this.ATOMIC_MAX_BLOCKSTATES.get(), MAX_BLOCKSTATES); - newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - Math.min(this.ATOMIC_MAX_ENTITIES.get(), MAX_ENTITIES); - return newLimit; - } - -} diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java index 6a5473979..4ba91a4f3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java @@ -50,7 +50,7 @@ public interface IBatchProcessor { } /** - * Convert this processor into an Extent based processor instead of a queue batch based one. + * Convert this processor into an Extent based processor instead of a queue batch based on. */ @Nullable Extent construct(Extent child); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 7bc243134..926265bfb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -308,7 +308,16 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * @return Limit remaining */ public FaweLimit getLimitUsed() { - return originalLimit.getLimitUsed(limit); + FaweLimit newLimit = new FaweLimit(); + newLimit.MAX_ACTIONS = originalLimit.MAX_ACTIONS - limit.MAX_ACTIONS; + newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - limit.MAX_CHANGES; + newLimit.MAX_FAILS = originalLimit.MAX_FAILS - limit.MAX_FAILS; + newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - limit.MAX_CHECKS; + newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - limit.MAX_ITERATIONS; + newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - limit.MAX_BLOCKSTATES; + newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - limit.MAX_ENTITIES; + newLimit.MAX_HISTORY = limit.MAX_HISTORY; + return newLimit; } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java index 5cf0cf745..ca6f3b6a5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java @@ -104,7 +104,6 @@ public final class EditSessionBuilder { private Extent extent; private boolean compiled; private boolean wrapped; - private boolean expectSynchronousSetting = false; private @Nullable World world; @@ -416,15 +415,6 @@ public final class EditSessionBuilder { return setDirty(); } - public EditSessionBuilder expectSynchronousSetting(boolean expectSynchronousSetting) { - this.expectSynchronousSetting = expectSynchronousSetting; - return setDirty(); - } - - public boolean isExpectingSynchronousSetting() { - return this.expectSynchronousSetting; - } - /** * Compile the builder to the settings given. Prepares history, limits, lighting, etc. */ @@ -645,11 +635,7 @@ public final class EditSessionBuilder { }; } if (limit != null && !limit.isUnlimited()) { - this.extent = new LimitExtent(this.extent, limit, onErrorMessage, placeChunks && combineStages, expectSynchronousSetting); - // Only process if we're not necessarily going to catch tiles via Extent#setBlock, e.g. because using PQE methods - if (placeChunks && combineStages && !expectSynchronousSetting) { - queue.addProcessor((LimitExtent) this.extent); - } + this.extent = new LimitExtent(this.extent, limit, onErrorMessage); } this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 3dd5f5638..d82bcd463 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -1725,25 +1725,10 @@ public class LocalSession implements TextureHolder { * @return an edit session */ public EditSession createEditSession(Actor actor) { - //FAWE start return createEditSession(actor, null); } public EditSession createEditSession(Actor actor, String command) { - return createEditSession(actor, command, false); - } - - /** - * Construct a new edit session. - * - * @param actor the actor - * @param command the command executed resulting in the creation of the edit session - * @param expectSynchronousSetting if it is expected that blocks will only be set synchronously, i.e. from one thread (at a - * time) - * @return an edit session - * @since TODO - */ - public EditSession createEditSession(Actor actor, String command, boolean expectSynchronousSetting) { checkNotNull(actor); World world = null; @@ -1754,6 +1739,7 @@ public class LocalSession implements TextureHolder { } // Create an edit session + //FAWE start - we don't use the edit session builder yet EditSession editSession; EditSessionBuilder builder = WorldEdit.getInstance().newEditSessionBuilder().world(world); if (actor.isPlayer() && actor instanceof Player) { @@ -1763,7 +1749,6 @@ public class LocalSession implements TextureHolder { } builder.command(command); builder.fastMode(!this.sideEffectSet.doesApplyAny()); - builder.expectSynchronousSetting(expectSynchronousSetting); editSession = builder.build(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java index 1f551aefa..a60968da1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java @@ -30,7 +30,6 @@ import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.command.util.annotation.Preload; -import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; @@ -180,7 +179,6 @@ public class BiomeCommands { ) @Logging(REGION) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected // TODO improve using filter/chunk-based-placement @Confirm(Confirm.Processor.REGION) @CommandPermissions("worldedit.biome.set") public void setBiome( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 8f1733fbb..664e656c4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -992,15 +992,15 @@ public class BrushCommands { Expression radius, @Arg(desc = "Command to run") List input, - @Switch(name = 'h', desc = "Hide any printed output") - boolean hide + @Switch(name = 'p', desc = "Show any printed output") + boolean print ) throws WorldEditException { worldEdit.checkMaxBrushRadius( radius, context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) ); String cmd = StringMan.join(input, " "); - set(context, new CommandBrush(cmd, !hide), "worldedit.brush.command").setSize(radius); + set(context, new CommandBrush(cmd, print), "worldedit.brush.command").setSize(radius); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index a8fa5076e..378449755 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -47,7 +47,6 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.command.util.annotation.Preload; -import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; @@ -439,7 +438,6 @@ public class ClipboardCommands { desc = "Place the clipboard's contents without applying transformations (e.g. rotate)" ) @CommandPermissions("worldedit.clipboard.place") - @SynchronousSettingExpected @Logging(PLACEMENT) public void place( Actor actor, World world, LocalSession session, final EditSession editSession, @@ -504,7 +502,6 @@ public class ClipboardCommands { desc = "Paste the clipboard's contents" ) @CommandPermissions("worldedit.clipboard.paste") - @SynchronousSettingExpected @Logging(PLACEMENT) public void paste( Actor actor, World world, LocalSession session, EditSession editSession, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index f2a3c80ed..4b2f98e0c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -38,7 +38,6 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.command.util.annotation.Preload; -import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.function.mask.Mask; @@ -105,7 +104,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.cylinder") @Logging(PLACEMENT) - @SynchronousSettingExpected public int hcyl( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The pattern of blocks to generate") @@ -154,7 +152,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.cylinder") @Logging(PLACEMENT) - @SynchronousSettingExpected public int cyl( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The pattern of blocks to generate") @@ -200,7 +197,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.cone") @Logging(PLACEMENT) - @SynchronousSettingExpected public int cone(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The pattern of blocks to generate") Pattern pattern, @@ -247,7 +243,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.sphere") @Logging(PLACEMENT) - @SynchronousSettingExpected public int hsphere( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The pattern of blocks to generate") @@ -267,7 +262,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.sphere") @Logging(PLACEMENT) - @SynchronousSettingExpected public int sphere( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The pattern of blocks to generate") @@ -319,7 +313,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.forest") @Logging(POSITION) - @SynchronousSettingExpected public int forestGen( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The size of the forest, in blocks", def = "10") @@ -344,7 +337,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.pumpkins") @Logging(POSITION) - @SynchronousSettingExpected public int pumpkins( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The size of the patch", def = "10") @@ -365,7 +357,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.pyramid") @Logging(PLACEMENT) - @SynchronousSettingExpected public int hollowPyramid( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The pattern of blocks to set") @@ -382,7 +373,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.pyramid") @Logging(PLACEMENT) - @SynchronousSettingExpected public int pyramid( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The pattern of blocks to set") @@ -410,7 +400,6 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.shape") @Logging(ALL) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public int generate( Actor actor, LocalSession session, EditSession editSession, @@ -497,7 +486,6 @@ public class GenerationCommands { @CommandPermissions("worldedit.generation.shape.biome") @Logging(ALL) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public int generateBiome( Actor actor, LocalSession session, EditSession editSession, @@ -576,7 +564,6 @@ public class GenerationCommands { @CommandPermissions("worldedit.generation.caves") @Logging(PLACEMENT) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public void caves( Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @@ -615,7 +602,6 @@ public class GenerationCommands { @CommandPermissions("worldedit.generation.ore") @Logging(PLACEMENT) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public void ores( Actor actor, @@ -635,7 +621,6 @@ public class GenerationCommands { desc = "Generate an image" ) @CommandPermissions("worldedit.generation.image") - @SynchronousSettingExpected @Logging(PLACEMENT) public void image( Actor actor, @@ -700,7 +685,6 @@ public class GenerationCommands { @CommandPermissions("worldedit.generation.ore") @Logging(PLACEMENT) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public void ore( Actor actor, @@ -735,9 +719,8 @@ public class GenerationCommands { desc = "Creates a distorted sphere" ) @Logging(PLACEMENT) - @SynchronousSettingExpected @CommandPermissions("worldedit.generation.blob") - public int blob( + public int blobBrush( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "Pattern") Pattern pattern, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java index ba736e45e..d1a647587 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java @@ -27,7 +27,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.annotation.Confirm; -import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.inventory.BlockBag; @@ -62,7 +61,6 @@ public class HistoryCommands { desc = "Undoes the last action (from history)" ) @CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"}) - @SynchronousSettingExpected public void undo( Actor actor, LocalSession session, @Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1") @@ -110,7 +108,6 @@ public class HistoryCommands { desc = "Redoes the last action (from history)" ) @CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"}) - @SynchronousSettingExpected public void redo( Actor actor, LocalSession session, @Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1") diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index ac3490cca..6a121aa02 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -35,7 +35,6 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.command.util.annotation.Preload; -import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.function.GroundFunction; @@ -226,7 +225,6 @@ public class RegionCommands { ) @CommandPermissions("worldedit.region.line") @Logging(REGION) - @SynchronousSettingExpected public int line( Actor actor, EditSession editSession, @Selection Region region, @@ -259,7 +257,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.curve") @Logging(REGION) @Confirm(Confirm.Processor.REGION) - @SynchronousSettingExpected public int curve( Actor actor, EditSession editSession, @Selection Region region, @@ -318,7 +315,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.overlay") @Logging(REGION) @Confirm(Confirm.Processor.REGION) - @SynchronousSettingExpected // TODO improve using filter/chunk-based-placement public int overlay( Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The pattern of blocks to overlay") @@ -337,7 +333,6 @@ public class RegionCommands { @Logging(REGION) @Preload(Preload.PreloadCheck.PRELOAD) @Confirm(Confirm.Processor.REGION) - @SynchronousSettingExpected // TODO improve using filter/chunk-based-placement public void lay( Actor actor, EditSession editSession, @@ -374,7 +369,6 @@ public class RegionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.region.center") - @SynchronousSettingExpected public int center( Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The pattern of blocks to set") @@ -392,8 +386,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.naturalize") @Logging(REGION) @Confirm(Confirm.Processor.REGION) - @SynchronousSettingExpected // TODO improve using filter/chunk-based-placement - @Preload(Preload.PreloadCheck.PRELOAD) public int naturalize(Actor actor, EditSession editSession, @Selection Region region) throws WorldEditException { int affected = editSession.naturalizeCuboidBlocks(region); actor.print(Caption.of("worldedit.naturalize.naturalized", TextComponent.of(affected))); @@ -445,7 +437,6 @@ public class RegionCommands { @Logging(REGION) @Preload(Preload.PreloadCheck.PRELOAD) @Confirm(Confirm.Processor.REGION) - @SynchronousSettingExpected public int smooth( Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "# of iterations to perform", def = "1") @@ -519,7 +510,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.snowsmooth") @Logging(REGION) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public int snowSmooth( Actor actor, EditSession editSession, @Selection Region region, @@ -546,7 +536,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.move") @Logging(ORIENTATION_REGION) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public int move( Actor actor, World world, EditSession editSession, LocalSession session, @@ -610,7 +599,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.fall") @Logging(ORIENTATION_REGION) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public void fall( Actor actor, EditSession editSession, @@ -630,7 +618,6 @@ public class RegionCommands { ) @CommandPermissions("worldedit.region.stack") @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Logging(ORIENTATION_REGION) public int stack( Actor actor, World world, EditSession editSession, LocalSession session, @@ -696,7 +683,6 @@ public class RegionCommands { ) @CommandPermissions("worldedit.regen") @Logging(REGION) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) void regenerate( Actor actor, World world, LocalSession session, EditSession editSession, @@ -751,7 +737,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.deform") @Logging(ALL) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public int deform( Actor actor, LocalSession session, EditSession editSession, @@ -829,7 +814,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.hollow") @Logging(REGION) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public int hollow( Actor actor, EditSession editSession, @@ -864,7 +848,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.forest") @Logging(REGION) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public int forest( Actor actor, EditSession editSession, @Selection Region region, @@ -886,7 +869,6 @@ public class RegionCommands { @CommandPermissions("worldedit.region.flora") @Logging(REGION) @Preload(Preload.PreloadCheck.PRELOAD) - @SynchronousSettingExpected @Confirm(Confirm.Processor.REGION) public int flora( Actor actor, EditSession editSession, @Selection Region region, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java index 074711521..b98785631 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java @@ -28,7 +28,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; -import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.formatting.text.TextComponent; @@ -67,7 +66,6 @@ public class SnapshotUtilCommands { ) @Logging(REGION) @CommandPermissions("worldedit.snapshots.restore") - @SynchronousSettingExpected public void restore( Actor actor, World world, LocalSession session, EditSession editSession, @Arg(name = "snapshot", desc = "The snapshot to restore", def = "") diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index c7c6ab9a1..c81db21d8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -44,7 +44,6 @@ import com.sk89q.worldedit.command.util.EntityRemover; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.PrintCommandHelp; import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; -import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; @@ -221,7 +220,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.fill") @Logging(PLACEMENT) - @SynchronousSettingExpected public int fill( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The blocks to fill with") @@ -313,7 +311,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.fill.recursive") @Logging(PLACEMENT) - @SynchronousSettingExpected public int fillr( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The blocks to fill with") @@ -346,7 +343,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.drain") @Logging(PLACEMENT) - @SynchronousSettingExpected public int drain( Actor actor, LocalSession session, EditSession editSession, //FAWE start - we take an expression over a double @@ -377,7 +373,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.fixlava") @Logging(PLACEMENT) - @SynchronousSettingExpected public int fixLava( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius to fix in") @@ -399,7 +394,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.fixwater") @Logging(PLACEMENT) - @SynchronousSettingExpected public int fixWater( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius to fix in") @@ -421,7 +415,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.removeabove") @Logging(PLACEMENT) - @SynchronousSettingExpected public int removeAbove( Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "The apothem of the square to remove from", def = "1") @@ -447,7 +440,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.removebelow") @Logging(PLACEMENT) - @SynchronousSettingExpected public int removeBelow( Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "The apothem of the square to remove from", def = "1") @@ -473,7 +465,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.removenear") @Logging(PLACEMENT) - @SynchronousSettingExpected public int removeNear( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The mask of blocks to remove") @@ -536,7 +527,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.snow") @Logging(PLACEMENT) - @SynchronousSettingExpected public int snow( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the cylinder to snow in", def = "10") @@ -576,7 +566,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.thaw") @Logging(PLACEMENT) - @SynchronousSettingExpected public int thaw( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the cylinder to thaw in", def = "10") @@ -606,7 +595,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.green") @Logging(PLACEMENT) - @SynchronousSettingExpected public int green( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the cylinder to convert in", def = "10") @@ -641,7 +629,6 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.extinguish") @Logging(PLACEMENT) - @SynchronousSettingExpected public int extinguish( Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the square to remove in", def = "") @@ -856,6 +843,55 @@ public class UtilityCommands { } } +// @Command( +// name = "/hollowr", +// desc = "Hollow out a space recursively with a pattern" +// ) +// @CommandPermissions("worldedit.hollowr") +// @Logging(PLACEMENT) +// public int hollowr( +// Actor actor, +// LocalSession session, +// EditSession editSession, +// @Arg(desc = "The radius to hollow out") Expression radiusExp, +// @ArgFlag(name = 'p', desc = "The blocks to fill with") Pattern pattern, +// @ArgFlag(name = 'm', desc = "The blocks remove", def = "") Mask mask +// ) throws WorldEditException { +// //FAWE start +// double radius = radiusExp.evaluate(); +// //FAWE end +// radius = Math.max(1, radius); +// we.checkMaxRadius(radius); +// if (mask == null) { +// Mask mask = new MaskIntersection( +// new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), +// new BoundedHeightMask( +// Math.max(lowerBound, minY), +// Math.min(maxY, origin.getBlockY()) +// ), +// Masks.negate(new ExistingBlockMask(this)) +// ); +// } +// +// // Want to replace blocks +// BlockReplace replace = new BlockReplace(this, pattern); +// +// // Pick how we're going to visit blocks +// RecursiveVisitor visitor; +// //FAWE start - provide extent for preloading, min/max y +// if (recursive) { +// visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), minY, maxY, this); +// } else { +// visitor = new DownwardVisitor(mask, replace, origin.getBlockY(), (int) (radius * 2 + 1), minY, maxY, this); +// } +// //FAWE end +// +// BlockVector3 pos = session.getPlacementPosition(actor); +// int affected = editSession.res(pos, pattern, radius, depth, true); +// actor.print(Caption.of("worldedit.fillr.created", TextComponent.of(affected))); +// return affected; +// } + public static List> filesToEntry(final File root, final List files, final UUID uuid) { return files.stream() .map(input -> { // Keep this functional, as transform is evaluated lazily diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java index e1996520a..299908d99 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java @@ -64,7 +64,7 @@ public class AreaPickaxe implements BlockTool { return false; } - try (EditSession editSession = session.createEditSession(player, "AreaPickaxe", true)) { + try (EditSession editSession = session.createEditSession(player, "AreaPickaxe")) { editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); int maxY = editSession.getMaxY(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java index 304fb9e77..2d35b2226 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java @@ -89,7 +89,7 @@ public class BlockDataCyler implements DoubleActionBlockTool { Property objProp = (Property) currentProperty; BaseBlock newBlock = block.with(objProp, currentProperty.getValues().get(index)); - try (EditSession editSession = session.createEditSession(player, null, true)) { + try (EditSession editSession = session.createEditSession(player)) { try { editSession.setBlock(blockPoint, newBlock); player.print(Caption.of( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java index 957ed3d83..75ef200c6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java @@ -63,7 +63,7 @@ public class BlockReplacer implements DoubleActionBlockTool { ) { BlockBag bag = session.getBlockBag(player); - try (EditSession editSession = session.createEditSession(player, null, true)) { + try (EditSession editSession = session.createEditSession(player)) { try { BlockVector3 position = clicked.toVector().toBlockPoint(); editSession.setBlock(position, pattern); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 74b06b1f5..6021102a2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -440,7 +440,7 @@ public class BrushTool Caption.of("fawe.error.no-perm", StringMan.join(current.getPermissions(), ","))); return false; } - try (EditSession editSession = session.createEditSession(player, current.toString(), brush.setsSynchronously())) { + try (EditSession editSession = session.createEditSession(player, current.toString())) { Location target = player.getBlockTrace(getRange(), true, traceMask); if (target == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java index 81d755b8c..385fcd2f3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java @@ -86,7 +86,7 @@ public class FloatingTreeRemover implements BlockTool { return true; } - try (EditSession editSession = session.createEditSession(player, "FloatingTreeRemover", true)) { + try (EditSession editSession = session.createEditSession(player, "FloatingTreeRemover")) { try { final Set blockSet = bfs(world, clicked.toVector().toBlockPoint()); if (blockSet == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java index 6381e9356..3d8d63f7d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java @@ -82,7 +82,7 @@ public class FloodFillTool implements BlockTool { return true; } - try (EditSession editSession = session.createEditSession(player, "FloodFillTool", true)) { + try (EditSession editSession = session.createEditSession(player, "FloodFillTool")) { try { //FAWE start - Respect masks Mask mask = initialType.toMask(editSession); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java index b1686ccd5..9e60fdcf3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java @@ -61,7 +61,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo } BlockBag bag = session.getBlockBag(player); - try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool", true)) { + try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) { try { BlockVector3 blockPoint = pos.toVector().toBlockPoint(); BaseBlock applied = secondary.applyBlock(blockPoint); @@ -90,7 +90,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo } BlockBag bag = session.getBlockBag(player); - try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool", true)) { + try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) { try { BlockVector3 blockPoint = pos.toVector().toBlockPoint(); BaseBlock applied = primary.applyBlock(blockPoint); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java index a8b666ff6..9fad39f9d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java @@ -79,7 +79,7 @@ public class RecursivePickaxe implements BlockTool { return false; } - try (EditSession editSession = session.createEditSession(player, "RecursivePickaxe", true)) { + try (EditSession editSession = session.createEditSession(player, "RecursivePickaxe")) { editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); //FAWE start diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java index 152f7016a..b35865fb3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java @@ -62,7 +62,7 @@ public class SinglePickaxe implements BlockTool { return false; } - try (EditSession editSession = session.createEditSession(player, null, true)) { + try (EditSession editSession = session.createEditSession(player)) { try { editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop); editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/StackTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/StackTool.java index 8aa5761f5..614bbcf32 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/StackTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/StackTool.java @@ -59,7 +59,7 @@ public class StackTool implements BlockTool { } BlockBag bag = session.getBlockBag(player); - try (EditSession editSession = session.createEditSession(player, null, true)) { + try (EditSession editSession = session.createEditSession(player)) { BlockStateHolder block = editSession.getFullBlock(clicked.toVector().toBlockPoint()); try { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java index b2f6ae7cf..1f52ff103 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java @@ -60,7 +60,7 @@ public class TreePlanter implements BlockTool { @Nullable Direction face ) { - try (EditSession editSession = session.createEditSession(player, null, true)) { + try (EditSession editSession = session.createEditSession(player)) { try { boolean successful = false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java index e38ae0d99..8efe2ab77 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java @@ -40,15 +40,4 @@ public interface Brush { */ void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException; - //FAWE start - /** - * If this brush is expected to set blocks synchronously, i.e. from one thread (at a time) - * - * @since TODO - */ - default boolean setsSynchronously() { - return true; - } - //FAWE end - } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/ConfirmHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/ConfirmHandler.java index 5d6b66483..067f9cfeb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/ConfirmHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/ConfirmHandler.java @@ -12,7 +12,7 @@ import java.lang.reflect.Method; import java.util.Optional; /** - * Handles commands indicated as requiring confirmation. + * Logs called commands to a logger. */ public class ConfirmHandler implements CommandCallListener { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/PreloadHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/PreloadHandler.java index 037c94e5b..9e1dc106f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/PreloadHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/PreloadHandler.java @@ -11,7 +11,7 @@ import java.lang.reflect.Method; import java.util.Optional; /** - * Initialises preloading of chunks. + * Logs called commands to a logger. */ public class PreloadHandler implements CommandCallListener { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/SynchronousSettingExpected.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/SynchronousSettingExpected.java deleted file mode 100644 index 3cc936fda..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/SynchronousSettingExpected.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.sk89q.worldedit.command.util.annotation; - -import org.enginehub.piston.inject.InjectAnnotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates it is expected that blocks will only be set synchronously, i.e. from one thread (at a time) - * - * @since TODO - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ - ElementType.METHOD -}) -@InjectAnnotation -public @interface SynchronousSettingExpected { - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/package-info.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/package-info.java index f7f293277..006432a73 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/package-info.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/package-info.java @@ -8,7 +8,6 @@ * {@link com.sk89q.worldedit.command.util.annotation.PatternList}, * {@link com.sk89q.worldedit.command.util.annotation.Preload}, * {@link com.sk89q.worldedit.command.util.annotation.PreloadHandler}, - * {@link com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected}, * {@link com.sk89q.worldedit.command.util.annotation.Step}, * {@link com.sk89q.worldedit.command.util.annotation.Time} */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 65fc7c196..b03e4ce54 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -24,7 +24,6 @@ import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.extension.platform.binding.Bindings; import com.fastasyncworldedit.core.extension.platform.binding.ConsumeBindings; -import com.fastasyncworldedit.core.extension.platform.binding.EditSessionHolder; import com.fastasyncworldedit.core.extension.platform.binding.PrimitiveBindings; import com.fastasyncworldedit.core.extension.platform.binding.ProvideBindings; import com.fastasyncworldedit.core.internal.command.MethodInjector; @@ -155,6 +154,7 @@ import org.enginehub.piston.inject.MemoizingValueAccess; import org.enginehub.piston.inject.MergedValueAccess; import org.enginehub.piston.part.SubCommandPart; import org.enginehub.piston.suggestion.Suggestion; +import org.enginehub.piston.util.HelpGenerator; import org.enginehub.piston.util.ValueProvider; import javax.annotation.Nonnull; @@ -227,6 +227,7 @@ public final class PlatformCommandManager { new ConfirmHandler(), new PreloadHandler() //FAWE end + )); // setup separate from main constructor // ensures that everything is definitely assigned @@ -311,6 +312,20 @@ public final class PlatformCommandManager { } ); //FAWE start + /* + globalInjectedValues.injectValue(Key.of(EditSession.class), + context -> { + LocalSession localSession = context.injectedValue(Key.of(LocalSession.class)) + .orElseThrow(() -> new IllegalStateException("No LocalSession")); + return context.injectedValue(Key.of(Actor.class)) + .map(actor -> { + EditSession editSession = localSession.createEditSession(actor); + editSession.enableStandardMode(); + Request.request().setEditSession(editSession); + return editSession; + }); + }); + */ // TODO: Ping @MattBDev to reimplement 2020-02-04 // globalInjectedValues.injectValue(Key.of(CFICommands.CFISettings.class), // context -> context.injectedValue(Key.of(Actor.class)) @@ -851,10 +866,10 @@ public final class PlatformCommandManager { store.injectValue(Key.of(InjectedValueStore.class), ValueProvider.constant(store)); store.injectValue(Key.of(Event.class), ValueProvider.constant(event)); //FAWE start - allow giving editsessions - if (event instanceof CommandEvent commandEvent) { - EditSession session = commandEvent.getSession(); + if (event instanceof CommandEvent) { + EditSession session = ((CommandEvent) event).getSession(); if (session != null) { - store.injectValue(Key.of(EditSessionHolder.class), context -> Optional.of(new EditSessionHolder(session))); + store.injectValue(Key.of(EditSession.class), context -> Optional.of(session)); } } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask.java index ab919b35f..cd3ef56d5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask.java @@ -94,7 +94,7 @@ public class BiomeMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { - BiomeType biome = vector.getBiome(getExtent()); + BiomeType biome = getExtent().getBiome(vector); return biomes.contains(biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java index a1b869efb..bad9781ea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java @@ -46,7 +46,7 @@ public class BlockCategoryMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { - return category.contains(vector.getBlock(getExtent())); + return category.contains(getExtent().getBlock(vector)); } //FAWE start diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index c7d3473f3..9f191a4cc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -204,7 +204,7 @@ public class BlockMask extends ABlockMask { @Override public boolean test(BlockVector3 vector) { - int test = vector.getBlock(getExtent()).getOrdinal(); + int test = getExtent().getBlock(vector).getOrdinal(); return ordinals[test] || replacesAir() && test == 0; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java index 0c563cdf7..ac558520c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java @@ -56,7 +56,7 @@ public class BlockStateMask extends AbstractExtentMask { //FAWE start @Override public boolean test(BlockVector3 vector) { - return test(vector.getBlock(getExtent())); + return test(getExtent().getBlock(vector)); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java index c3567b6d5..17f1419e5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java @@ -124,7 +124,7 @@ public class BlockTypeMask extends AbstractExtentMask { //FAWE start @Override public boolean test(BlockVector3 vector) { - return test(vector.getBlock(getExtent()).getBlockType()); + return test(getExtent().getBlock(vector).getBlockType()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java index be62c2eae..b75a4cd1e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java @@ -41,7 +41,7 @@ public class ExistingBlockMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { - return !vector.getBlock(getExtent()).getBlockType().getMaterial().isAir(); + return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java index 6bb39b958..e8b14b95a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java @@ -29,7 +29,7 @@ public class InverseSingleBlockStateMask extends ABlockMask { @Override public boolean test(BlockVector3 vector) { - int test = vector.getBlock(getExtent()).getOrdinal(); + int test = getExtent().getBlock(vector).getOrdinal(); if (isAir && test == 0) { return false; } diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index fea3e7dd5..a56d98695 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -141,7 +141,6 @@ "fawe.error.limit.max-brush-radius": "Maximum brush radius in limit: {0}", "fawe.error.limit.max-radius": "Maximum radius in limit: {0}", "fawe.error.no-valid-on-hotbar": "No valid block types on hotbar", - "fawe.error.no-process-non-synchronous-edit": "No processor holder was found but edit is non-synchronous", "fawe.cancel.count": "Cancelled {0} edits.", "fawe.cancel.reason.confirm": "Use //confirm to execute {0}", "fawe.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}", @@ -152,7 +151,6 @@ "fawe.cancel.reason.low.memory": "Low memory", "fawe.cancel.reason.max.changes": "Too many blocks changed", "fawe.cancel.reason.max.checks": "Too many block checks", - "fawe.cancel.reason.max.fails": "Too many fails", "fawe.cancel.reason.max.tiles": "Too many block entities", "fawe.cancel.reason.max.entities": "Too many entities", "fawe.cancel.reason.max.iterations": "Max iterations",