Fix potential out of bounds and NPE

This commit is contained in:
Phoenix616 2023-03-01 18:01:33 +01:00
parent 7ee8d07242
commit 4de1f1e8c5
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 6 additions and 4 deletions

View File

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