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 7ef47de45e..ff52c93c69 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 @@ -48,13 +48,13 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.internal.util.DeprecationUtil; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -538,13 +538,7 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa //FAWE end } - if (nbt != null) { - BaseBlock result = blockStates.size() > 0 ? state.toBaseBlock(nbt) : new BlanketBaseBlock(state, nbt); - return validate(context, result); - } - - if (blockType == BlockTypes.SIGN || blockType == BlockTypes.WALL_SIGN - || BlockCategories.SIGNS.contains(blockType)) { + if (DeprecationUtil.isSign(blockType)) { // Allow special sign text syntax String[] text = new String[4]; text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : ""; @@ -552,10 +546,11 @@ 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) { + } else if (blockType == BlockTypes.SPAWNER && (blockAndExtraData.length > 1 || nbt != null)) { // Allow setting mob spawn type + String mobName; if (blockAndExtraData.length > 1) { - String mobName = blockAndExtraData[1]; + mobName = blockAndExtraData[1]; EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT)); if (ent == null) { throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName))); @@ -564,14 +559,13 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) { throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName))); } - return validate(context, new MobSpawnerBlock(state, mobName)); } else { - //noinspection ConstantConditions - return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.id())); + mobName = EntityTypes.PIG.id(); } - } else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) { + return validate(context, new MobSpawnerBlock(state, mobName)); + } else if ((blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) && (blockAndExtraData.length > 1 || nbt != null)) { // allow setting type/player/rotation - if (blockAndExtraData.length <= 1) { + if (blockAndExtraData.length == 1) { return validate(context, new SkullBlock(state)); } @@ -580,12 +574,14 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa return validate(context, new SkullBlock(state, type.replace(" ", "_"))); // valid MC usernames } else { //FAWE start - nbt = state.getNbtData(); + if (nbt == null) { + nbt = state.getNbtData(); + } BaseBlock result; if (nbt != null) { - result = blockStates.size() > 0 ? state.toBaseBlock(nbt) : new BlanketBaseBlock(state, nbt); + result = !blockStates.isEmpty() ? state.toBaseBlock(nbt) : new BlanketBaseBlock(state, nbt); } else { - result = blockStates.size() > 0 ? new BaseBlock(state) : state.toBaseBlock(); + result = !blockStates.isEmpty() ? new BaseBlock(state) : state.toBaseBlock(); } return validate(context, result); //FAWE end