From 090052df5a57a385572d953ce339690a6d708ccf Mon Sep 17 00:00:00 2001 From: Wizjany Date: Fri, 11 Jan 2013 22:39:13 -0500 Subject: [PATCH] Fail silently if correct NMS version is not found. This will fix errors when trying to set blocks when using the wrong minecraft version. However, if users want support for schematics or copy/pasting blocks with advanced data (eg things not yet supported by Bukkit like mob spawner potentials or blocks from mods), they will have to use the WorldEdit version corresponding to their Minecraft version. --- src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java | 6 ++---- src/main/java/com/sk89q/worldedit/bukkit/NmsBlock.java | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 28a605d9f..b4b73bf6c 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -886,10 +886,8 @@ public class BukkitWorld extends LocalWorld { public boolean isValidBlockType(int type) { if (!skipNmsValidBlockCheck) { try { - return type == 0 || (type >= 1 && type < net.minecraft.server.Block.byId.length - && net.minecraft.server.Block.byId[type] != null); - } catch (Exception e) { - logger.log(Level.SEVERE, "Error checking NMS valid block type", e); + return NmsBlock.isValidBlockType(type); + } catch (Throwable e) { skipNmsValidBlockCheck = true; } } diff --git a/src/main/java/com/sk89q/worldedit/bukkit/NmsBlock.java b/src/main/java/com/sk89q/worldedit/bukkit/NmsBlock.java index f5827ab0a..1bec84d96 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/NmsBlock.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/NmsBlock.java @@ -434,4 +434,9 @@ class NmsBlock extends BaseBlock implements TileEntityBlock { + foreign.getClass().getCanonicalName()); } } + + public static boolean isValidBlockType(int type) throws NoClassDefFoundError { + return type == 0 || (type >= 1 && type < net.minecraft.server.Block.byId.length + && net.minecraft.server.Block.byId[type] != null); + } }