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.
This commit is contained in:
Wizjany 2013-01-11 22:39:13 -05:00
parent c634ad6d08
commit 090052df5a
2 changed files with 7 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}