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) {
|
public static void addItems(Player player, Material type, int amount) {
|
||||||
HashMap<Integer, ItemStack> invOverflow = getInventory(player, InventoryID.INVENTORY).addItem(new ItemStack(type, amount));
|
if (amount <= 0) return;
|
||||||
HashMap<Integer, ItemStack> echestOverflow = getInventory(player, InventoryID.ENDER_CHEST).addItem(new ItemStack(type, invOverflow.values()
|
|
||||||
|
HashMap<Integer, ItemStack> invOverflow =
|
||||||
|
getInventory(player, InventoryID.INVENTORY)
|
||||||
|
.addItem(new ItemStack(type, amount));
|
||||||
|
|
||||||
|
int overflowAmount = invOverflow.values()
|
||||||
.stream()
|
.stream()
|
||||||
.mapToInt(ItemStack::getAmount)
|
.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()) {
|
for (ItemStack overflow : echestOverflow.values()) {
|
||||||
player.getWorld().dropItemNaturally(player.getLocation(), overflow);
|
player.getWorld().dropItemNaturally(player.getLocation(), overflow);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
name: ItemEconomy
|
name: ItemEconomy
|
||||||
main: io.github.adrianvic.itemeconomy.Main
|
main: io.github.adrianvic.itemeconomy.Main
|
||||||
version: 1.2
|
version: 1.2.1
|
||||||
depend: [Vault]
|
depend: [Vault]
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
commands:
|
commands:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue