diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java index 80df4c1cb1..77982c426b 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java @@ -64,6 +64,16 @@ public Object toRaw() { } public abstract int getTypeCode(); + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } else if (!this.getClass().equals(o.getClass())) { + return false; + } + return linTag.equals(((Tag) o).linTag); + } //FAWE end } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index ff52c93c69..3541de4ede 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -538,7 +538,10 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa //FAWE end } - if (DeprecationUtil.isSign(blockType)) { + //FAWE start - only handle if extra data is actually supplied or if the user has permission for nbt + boolean allowWorkingDefault = context.requireActor().hasPermission("worldedit.anyblock.nbt") && nbt != null; + if (DeprecationUtil.isSign(blockType) && (blockAndExtraData.length > 1 || allowWorkingDefault)) { + //FAWE end // Allow special sign text syntax String[] text = new String[4]; text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : ""; @@ -546,7 +549,9 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : ""; text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : ""; return validate(context, new SignBlock(state, text)); - } else if (blockType == BlockTypes.SPAWNER && (blockAndExtraData.length > 1 || nbt != null)) { + //FAWE start - only handle if extra data is actually supplied or if the user has permission for nbt + } else if (blockType == BlockTypes.SPAWNER && (blockAndExtraData.length > 1 || allowWorkingDefault)) { + //FAWE end // Allow setting mob spawn type String mobName; if (blockAndExtraData.length > 1) { @@ -563,7 +568,9 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa mobName = EntityTypes.PIG.id(); } return validate(context, new MobSpawnerBlock(state, mobName)); - } else if ((blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) && (blockAndExtraData.length > 1 || nbt != null)) { + //FAWE start - only handle if extra data is actually supplied or if the user has permission for nbt + } else if ((blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) && (blockAndExtraData.length > 1 || allowWorkingDefault)) { + //FAWE end // allow setting type/player/rotation if (blockAndExtraData.length == 1) { return validate(context, new SkullBlock(state)); @@ -600,7 +607,17 @@ private T validate(ParserContext context, T holder) } CompoundTag nbt = holder.getNbtData(); if (nbt != null) { - if (!actor.hasPermission("worldedit.anyblock.nbt")) { + if (actor.hasPermission("worldedit.anyblock.nbt")) { + return holder; + } + if (nbt.equals(holder.getBlockType().getDefaultState().getNbtData())) { + if (!actor.hasPermission("worldedit.anyblock.default-nbt")) { + throw new DisallowedUsageException(Caption.of( + "fawe.error.nbt.forbidden", + TextComponent.of("worldedit.anyblock.default-nbt") + )); + } + } else { throw new DisallowedUsageException(Caption.of( "fawe.error.nbt.forbidden", TextComponent.of("worldedit.anyblock.nbt")