Added negative id check to Material.getMaterial(int). Fixes BUKKIT-3414

Negative id values would try to access the array out of bounds and throw an java.lang.ArrayIndexOutOfBoundsException.

By: MikeMatrix <m.braun92@gmail.com>
This commit is contained in:
Bukkit/Spigot committed 2013-01-11 02:07:38 +01:00
1 parent de7c26870b
commit 08fa8ed053
2 files changed
+2 -1

No files matched your search

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