From 04803de8b14a0f79fc8fed64454b79fa4788d6e3 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Wed, 2 Nov 2011 22:49:56 -0700 Subject: [PATCH] Fixed some NPE's for block types not in BlockType. --- .../java/com/sk89q/worldedit/commands/SelectionCommands.java | 3 ++- src/main/java/com/sk89q/worldedit/tools/QueryTool.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java b/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java index 2b49c127e..06423ae09 100644 --- a/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java @@ -563,10 +563,11 @@ public class SelectionCommands { } for (Countable c : distribution) { + BlockType block = BlockType.fromID(c.getID()); String str = String.format("%-7s (%.3f%%) %s #%d", String.valueOf(c.getAmount()), c.getAmount() / (double)size * 100, - BlockType.fromID(c.getID()).getName(), c.getID()); + block == null ? "Unknown" : block.getName(), c.getID()); player.print(str); if (args.hasFlag('c')) { diff --git a/src/main/java/com/sk89q/worldedit/tools/QueryTool.java b/src/main/java/com/sk89q/worldedit/tools/QueryTool.java index fbd57651a..2355ef2c4 100644 --- a/src/main/java/com/sk89q/worldedit/tools/QueryTool.java +++ b/src/main/java/com/sk89q/worldedit/tools/QueryTool.java @@ -38,10 +38,11 @@ public class QueryTool implements BlockTool { LocalWorld world = clicked.getWorld(); BaseBlock block = (new EditSession(world, 0)).rawGetBlock(clicked); + BlockType type = BlockType.fromID(block.getType()); player.print("\u00A79@" + clicked + ": " + "\u00A7e" + "#" + block.getType() + "\u00A77" + " (" - + BlockType.fromID(block.getType()).getName() + ") " + + (type == null ? "Unknown" : type.getName()) + ") " + "\u00A7f" + "[" + block.getData() + "]" + " (" + world.getBlockLightLevel(clicked) + "/" + world.getBlockLightLevel(clicked.add(0, 1, 0)) + ")");