From 7b83f97c351e545f4d08ca6f38b41777871d23a9 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 19 Aug 2018 14:41:09 +1000 Subject: [PATCH] Fixed NotABlockException not getting thrown --- .../main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java | 6 ++++-- .../worldedit/extension/platform/AbstractPlayerActor.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java index faa7e5b57..f7500168a 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java @@ -22,8 +22,10 @@ package com.sk89q.worldedit.bukkit; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Function; +import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extension.input.InputParseException; @@ -360,12 +362,12 @@ public class BukkitAdapter { * @param itemStack The Bukkit ItemStack * @return The WorldEdit BlockState */ - public static BlockState asBlockState(ItemStack itemStack) { + public static BlockState asBlockState(ItemStack itemStack) throws WorldEditException { checkNotNull(itemStack); if (itemStack.getType().isBlock()) { return adapt(itemStack.getType().createBlockData()); } else { - return BlockTypes.AIR.getDefaultState(); + throw new NotABlockException(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 4c3ced012..e738f8004 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.extension.platform; +import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.PlayerDirection; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; @@ -370,7 +371,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (typeId.hasBlockType()) { return typeId.getBlockType().getDefaultState().toBaseBlock(); } else { - return BlockTypes.AIR.getDefaultState().toBaseBlock(); + throw new NotABlockException(); } }