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.
Dieser Commit ist enthalten in:
Wizjany 2013-01-11 22:39:13 -05:00
Ursprung c634ad6d08
Commit 090052df5a
2 geänderte Dateien mit 7 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -886,10 +886,8 @@ public class BukkitWorld extends LocalWorld {
public boolean isValidBlockType(int type) { public boolean isValidBlockType(int type) {
if (!skipNmsValidBlockCheck) { if (!skipNmsValidBlockCheck) {
try { try {
return type == 0 || (type >= 1 && type < net.minecraft.server.Block.byId.length return NmsBlock.isValidBlockType(type);
&& net.minecraft.server.Block.byId[type] != null); } catch (Throwable e) {
} catch (Exception e) {
logger.log(Level.SEVERE, "Error checking NMS valid block type", e);
skipNmsValidBlockCheck = true; skipNmsValidBlockCheck = true;
} }
} }

Datei anzeigen

@ -434,4 +434,9 @@ class NmsBlock extends BaseBlock implements TileEntityBlock {
+ foreign.getClass().getCanonicalName()); + 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);
}
} }