Fix potential out of bounds and NPE
This commit is contained in:
parent
7ee8d07242
commit
4de1f1e8c5
|
@ -48,7 +48,7 @@ public class AdminInventory implements Inventory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(int i) {
|
public ItemStack getItem(int i) {
|
||||||
if (content.length < i) {
|
if (content.length > i) {
|
||||||
return content[i];
|
return content[i];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -156,10 +156,12 @@ public class AdminInventory implements Inventory {
|
||||||
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
||||||
|
|
||||||
ItemStack clone = itemStack.clone();
|
if (itemStack != null) {
|
||||||
clone.setAmount(Integer.MAX_VALUE);
|
ItemStack clone = itemStack.clone();
|
||||||
|
clone.setAmount(Integer.MAX_VALUE);
|
||||||
|
|
||||||
items.put(1, clone);
|
items.put(1, clone);
|
||||||
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue