Fix bug where Main.addItems would try to add 0 items to Ender Chest. Bumped version to 1.2.1.
This commit is contained in:
parent
9b3872c8ac
commit
f65c3ddc97
2 changed files with 16 additions and 4 deletions
|
|
@ -122,12 +122,24 @@ public class Main extends JavaPlugin {
|
|||
}
|
||||
|
||||
public static void addItems(Player player, Material type, int amount) {
|
||||
HashMap<Integer, ItemStack> invOverflow = getInventory(player, InventoryID.INVENTORY).addItem(new ItemStack(type, amount));
|
||||
HashMap<Integer, ItemStack> echestOverflow = getInventory(player, InventoryID.ENDER_CHEST).addItem(new ItemStack(type, invOverflow.values()
|
||||
if (amount <= 0) return;
|
||||
|
||||
HashMap<Integer, ItemStack> invOverflow =
|
||||
getInventory(player, InventoryID.INVENTORY)
|
||||
.addItem(new ItemStack(type, amount));
|
||||
|
||||
int overflowAmount = invOverflow.values()
|
||||
.stream()
|
||||
.mapToInt(ItemStack::getAmount)
|
||||
.sum()));
|
||||
.sum();
|
||||
|
||||
if (overflowAmount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<Integer, ItemStack> echestOverflow =
|
||||
getInventory(player, InventoryID.ENDER_CHEST)
|
||||
.addItem(new ItemStack(type, overflowAmount));
|
||||
|
||||
for (ItemStack overflow : echestOverflow.values()) {
|
||||
player.getWorld().dropItemNaturally(player.getLocation(), overflow);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue