diff --git a/modules/Plugin/src/main/java/xyz/mackan/Slabbo/GUI/ShopUserGUI.java b/modules/Plugin/src/main/java/xyz/mackan/Slabbo/GUI/ShopUserGUI.java index a728931..7b36041 100644 --- a/modules/Plugin/src/main/java/xyz/mackan/Slabbo/GUI/ShopUserGUI.java +++ b/modules/Plugin/src/main/java/xyz/mackan/Slabbo/GUI/ShopUserGUI.java @@ -128,27 +128,29 @@ public void handleBuy (HumanEntity humanEntity) { } else { int maxStackSize = slabboAPI.getMaxStack(shopItemClone); - int totalItems = itemCount; + int stacks = (int)Math.floor(itemCount / maxStackSize); + int lastStack = itemCount % maxStackSize; - int totalStacks = (totalItems / maxStackSize + (totalItems % maxStackSize)); + //int totalStacks = (totalItems / maxStackSize + (totalItems % maxStackSize)); - for (int i = 0;i 0) { + ItemStack clonedStack = shop.item.clone(); + clonedStack.setAmount(lastStack); + stacksToAdd.add(clonedStack); } } - HashMap leftovers = pInv.addItem((ItemStack[]) stacksToAdd.toArray()); + ItemStack[] stackArray = stacksToAdd.toArray(new ItemStack[stacksToAdd.size()]); + HashMap leftovers = pInv.addItem(stackArray); // TODO: Make this do a dry run to see if the player can acutally get all the items int leftoverCount = leftovers