From 2f2d3f8045c06ba3b15ee57c82acb6c0b274421d Mon Sep 17 00:00:00 2001 From: zml2008 Date: Sat, 4 Feb 2012 21:04:20 -0800 Subject: [PATCH] Lookup by id if the string passed to Block/ItemType.lookup() is an integer --- src/main/java/com/sk89q/worldedit/blocks/BlockType.java | 6 +++++- src/main/java/com/sk89q/worldedit/blocks/ItemType.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index 997bb6e61..7667b6a0f 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -234,7 +234,11 @@ public enum BlockType { * @return */ public static BlockType lookup(String name, boolean fuzzy) { - return StringUtil.lookup(lookup, name, fuzzy); + try { + return fromID(Integer.parseInt(name)); + } catch (NumberFormatException e) { + return StringUtil.lookup(lookup, name, fuzzy); + } } /** diff --git a/src/main/java/com/sk89q/worldedit/blocks/ItemType.java b/src/main/java/com/sk89q/worldedit/blocks/ItemType.java index 89ed8cf7e..c5295d365 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/ItemType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/ItemType.java @@ -412,7 +412,11 @@ public enum ItemType { * @return */ public static ItemType lookup(String name, boolean fuzzy) { - return StringUtil.lookup(lookup, name, fuzzy); + try { + return fromID(Integer.parseInt(name)); + } catch (NumberFormatException e) { + return StringUtil.lookup(lookup, name, fuzzy); + } } /**