From 2082df4141194f436f4c44fba14a97e67935abb9 Mon Sep 17 00:00:00 2001 From: Jordan Date: Thu, 13 Oct 2022 18:21:25 +0100 Subject: [PATCH] fix: Add blocked blocks to the correct set (#1975) * fix: Add blocked blocks to the correct set * Address comment --- .../core/configuration/Settings.java | 4 ++-- .../core/extent/DisallowedBlocksExtent.java | 12 ++++++------ .../java/com/sk89q/worldedit/EditSessionBuilder.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index 976b8b62a..c2cb7704d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -391,8 +391,8 @@ public class Settings extends Config { public boolean UNIVERSAL_DISALLOWED_BLOCKS = true; @Comment({ "List of blocks to deny use of. Can be either an entire block type or a block with a specific property value.", - "Where block properties are specified, any blockstate with the property will be disallowed (i.g. all directions", - "of a waterlogged fence). For blocking/remapping of all occurence of a property like waterlogged, see", + "Where block properties are specified, any blockstate with the property will be disallowed (e.g. all directions", + "of a waterlogged fence). For blocking/remapping of all occurrences of a property like waterlogged, see", "remap-properties below.", "Example block property blocking:", " - \"minecraft:conduit[waterlogged=true]\"", diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/DisallowedBlocksExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/DisallowedBlocksExtent.java index 8f2612b76..db270fa16 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/DisallowedBlocksExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/DisallowedBlocksExtent.java @@ -18,6 +18,7 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.FuzzyBlockState; import javax.annotation.Nullable; @@ -26,12 +27,8 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Future; import java.util.stream.Collectors; -import static com.sk89q.worldedit.world.block.BlockTypesCache.states; - public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IBatchProcessor { private static final BlockState RESERVED = BlockTypes.__RESERVED__.getDefaultState(); @@ -56,7 +53,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB this.blockedBlocks = new HashSet<>(); for (String block : blockedBlocks) { if (block.indexOf('[') == -1 || block.indexOf(']') == -1) { - blockedBlocks.add(block); + this.blockedBlocks.add(block); continue; } String[] properties = block.substring(block.indexOf('[') + 1, block.indexOf(']')).split(","); @@ -138,7 +135,10 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB it: for (int i = 0; i < blocks.length; i++) { char block = blocks[i]; - BlockState state = states[block]; + if (block == BlockTypesCache.ReservedIDs.__RESERVED__) { + continue; + } + BlockState state = BlockTypesCache.states[block]; if (blockedBlocks != null) { if (blockedBlocks.contains(state.getBlockType().getId())) { blocks[i] = 0; 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 493a512d3..03452fea5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java @@ -605,7 +605,7 @@ public final class EditSessionBuilder { } if (this.limit != null && !this.limit.isUnlimited()) { Set limitBlocks = new HashSet<>(); - if ((getActor() == null || getActor().hasPermission("worldedit.anyblock") && this.limit.UNIVERSAL_DISALLOWED_BLOCKS)) { + if ((getActor() == null || getActor().hasPermission("worldedit.anyblock")) && this.limit.UNIVERSAL_DISALLOWED_BLOCKS) { limitBlocks.addAll(WorldEdit.getInstance().getConfiguration().disallowedBlocks); } if (this.limit.DISALLOWED_BLOCKS != null && !this.limit.DISALLOWED_BLOCKS.isEmpty()) {