mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-28 06:27:38 +02:00
Cleanup: 0-sized arrays, NPE, Math.min usage
This commit is contained in:
parent
fbfe789bfa
commit
ada8cf3ae8
@ -211,10 +211,10 @@ public class PartialTransactionModule implements Listener {
|
||||
int amount = InventoryUtil.getAmount(item, inventory);
|
||||
|
||||
Collections.addAll(toReturn, getCountedItemStack(new ItemStack[]{item},
|
||||
amount > item.getAmount() ? item.getAmount() : amount));
|
||||
Math.min(amount, item.getAmount())));
|
||||
}
|
||||
|
||||
return toReturn.toArray(new ItemStack[toReturn.size()]);
|
||||
return toReturn.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
private static ItemStack[] getCountedItemStack(ItemStack[] stock, int numberOfItems) {
|
||||
@ -263,7 +263,7 @@ public class PartialTransactionModule implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
return stacks.toArray(new ItemStack[stacks.size()]);
|
||||
return stacks.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,9 +283,11 @@ public class PartialTransactionModule implements Listener {
|
||||
int free = 0;
|
||||
for (ItemStack itemInInventory : inventory.getContents()) {
|
||||
if (MaterialUtil.equals(item, itemInInventory)) {
|
||||
if (itemInInventory != null) {
|
||||
free += (maxStackSize - itemInInventory.getAmount()) % maxStackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (free == 0 && emptySlots == 0) {
|
||||
continue;
|
||||
@ -307,6 +309,6 @@ public class PartialTransactionModule implements Listener {
|
||||
Collections.addAll(resultStock, InventoryUtil.getItemsStacked(item));
|
||||
}
|
||||
|
||||
return resultStock.toArray(new ItemStack[resultStock.size()]);
|
||||
return resultStock.toArray(new ItemStack[0]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user