diff --git a/src/main/java/com/alttd/playershops/shop/PlayerShop.java b/src/main/java/com/alttd/playershops/shop/PlayerShop.java index 495fc3e..79aa5b9 100644 --- a/src/main/java/com/alttd/playershops/shop/PlayerShop.java +++ b/src/main/java/com/alttd/playershops/shop/PlayerShop.java @@ -2,10 +2,7 @@ package com.alttd.playershops.shop; import com.alttd.playershops.PlayerShops; import com.alttd.playershops.events.*; -import com.alttd.playershops.utils.EconomyUtils; -import com.alttd.playershops.utils.InventoryUtils; -import com.alttd.playershops.utils.ShopUtil; -import com.alttd.playershops.utils.Util; +import com.alttd.playershops.utils.*; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.minimessage.MiniMessage; @@ -88,12 +85,26 @@ public class PlayerShop { * @return total amount of purchases left until the shop can't sell/buy anymore */ public int getRemainingStock() { - int totalItems = InventoryUtils.countItems(getInventory(), getItemStack()); - if (totalItems == 0) - return 0; - if (getAmount() == 0) - return 0; - return totalItems / getAmount(); + switch (type) { + case SELL -> { + int totalItems = InventoryUtils.countItems(getInventory(), getItemStack()); + if (totalItems == 0 || getAmount() == 0) + return 0; + return totalItems / getAmount(); + } + case BUY -> { + if (balance == 0 || getAmount() == 0) + return 0; + return (int) (balance / getPrice()); + } + case GAMBLE -> { + Logger.warn("Tried to call getRemainingStock on unimplemented GAMBLE type"); + return 0; //not implemented since gamble shops don't exist yet + } + default -> { + return 0; + } + } } public int getRemainingSpace() {