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
|
||||
public ItemStack getItem(int i) {
|
||||
if (content.length < i) {
|
||||
if (content.length > i) {
|
||||
return content[i];
|
||||
}
|
||||
return null;
|
||||
|
@ -156,10 +156,12 @@ public class AdminInventory implements Inventory {
|
|||
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
||||
|
||||
ItemStack clone = itemStack.clone();
|
||||
clone.setAmount(Integer.MAX_VALUE);
|
||||
if (itemStack != null) {
|
||||
ItemStack clone = itemStack.clone();
|
||||
clone.setAmount(Integer.MAX_VALUE);
|
||||
|
||||
items.put(1, clone);
|
||||
items.put(1, clone);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue