fix: Add blocked blocks to the correct set (#1975)

* fix: Add blocked blocks to the correct set

* Address comment
This commit is contained in:
Jordan 2022-10-13 18:21:25 +01:00 committed by GitHub
parent 8971d7064c
commit 2082df4141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -391,8 +391,8 @@ public class Settings extends Config {
public boolean UNIVERSAL_DISALLOWED_BLOCKS = true; public boolean UNIVERSAL_DISALLOWED_BLOCKS = true;
@Comment({ @Comment({
"List of blocks to deny use of. Can be either an entire block type or a block with a specific property value.", "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", "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 occurence of a property like waterlogged, see", "of a waterlogged fence). For blocking/remapping of all occurrences of a property like waterlogged, see",
"remap-properties below.", "remap-properties below.",
"Example block property blocking:", "Example block property blocking:",
" - \"minecraft:conduit[waterlogged=true]\"", " - \"minecraft:conduit[waterlogged=true]\"",

View File

@ -18,6 +18,7 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import com.sk89q.worldedit.world.block.FuzzyBlockState; import com.sk89q.worldedit.world.block.FuzzyBlockState;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -26,12 +27,8 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.sk89q.worldedit.world.block.BlockTypesCache.states;
public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IBatchProcessor { public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IBatchProcessor {
private static final BlockState RESERVED = BlockTypes.__RESERVED__.getDefaultState(); private static final BlockState RESERVED = BlockTypes.__RESERVED__.getDefaultState();
@ -56,7 +53,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
this.blockedBlocks = new HashSet<>(); this.blockedBlocks = new HashSet<>();
for (String block : blockedBlocks) { for (String block : blockedBlocks) {
if (block.indexOf('[') == -1 || block.indexOf(']') == -1) { if (block.indexOf('[') == -1 || block.indexOf(']') == -1) {
blockedBlocks.add(block); this.blockedBlocks.add(block);
continue; continue;
} }
String[] properties = block.substring(block.indexOf('[') + 1, block.indexOf(']')).split(","); String[] properties = block.substring(block.indexOf('[') + 1, block.indexOf(']')).split(",");
@ -138,7 +135,10 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
it: it:
for (int i = 0; i < blocks.length; i++) { for (int i = 0; i < blocks.length; i++) {
char block = blocks[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 != null) {
if (blockedBlocks.contains(state.getBlockType().getId())) { if (blockedBlocks.contains(state.getBlockType().getId())) {
blocks[i] = 0; blocks[i] = 0;

View File

@ -605,7 +605,7 @@ public final class EditSessionBuilder {
} }
if (this.limit != null && !this.limit.isUnlimited()) { if (this.limit != null && !this.limit.isUnlimited()) {
Set<String> limitBlocks = new HashSet<>(); Set<String> 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); limitBlocks.addAll(WorldEdit.getInstance().getConfiguration().disallowedBlocks);
} }
if (this.limit.DISALLOWED_BLOCKS != null && !this.limit.DISALLOWED_BLOCKS.isEmpty()) { if (this.limit.DISALLOWED_BLOCKS != null && !this.limit.DISALLOWED_BLOCKS.isEmpty()) {