diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/Material.java | 2 | ||||
-rw-r--r-- | src/test/java/org/bukkit/MaterialTest.java | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java index 1a726104..7d26f61e 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -528,7 +528,7 @@ public enum Material { * @return Material if found, or null */ public static Material getMaterial(final int id) { - if (byId.length > id) { + if (byId.length > id && id >= 0) { return byId[id]; } else { return null; diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java index c1051caf..e74e2f28 100644 --- a/src/test/java/org/bukkit/MaterialTest.java +++ b/src/test/java/org/bukkit/MaterialTest.java @@ -33,6 +33,7 @@ public class MaterialTest { @Test public void getByOutOfRangeId() { assertThat(Material.getMaterial(Integer.MAX_VALUE), is(nullValue())); + assertThat(Material.getMaterial(Integer.MIN_VALUE), is(nullValue())); } @Test |