From 4c022dd9dce5c05fe33b7c71d93ecaacb63d8ece Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 27 May 2016 15:00:39 +0200 Subject: [PATCH] On admin and infinite shops, the player must have enough items --- src/de/epiceric/shopchest/event/InteractShop.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/de/epiceric/shopchest/event/InteractShop.java b/src/de/epiceric/shopchest/event/InteractShop.java index 91a5d76..0c80add 100644 --- a/src/de/epiceric/shopchest/event/InteractShop.java +++ b/src/de/epiceric/shopchest/event/InteractShop.java @@ -205,12 +205,20 @@ public class InteractShop implements Listener{ if (perm.has(p, "shopchest.sell")) { if (shop.getShopType() == ShopType.INFINITE) { if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) { - sell(p, shop); + if (Utils.getAmount(p.getInventory(), shop.getProduct().getType(), shop.getProduct().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) { + sell(p, shop); + } else { + p.sendMessage(Config.not_enough_items()); + } } else { e.setCancelled(false); } } else if (shop.getShopType() == ShopType.ADMIN) { - sell(p, shop); + if (Utils.getAmount(p.getInventory(), shop.getProduct().getType(), shop.getProduct().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) { + sell(p, shop); + } else { + p.sendMessage(Config.not_enough_items()); + } } else { if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) { if (Utils.getAmount(p.getInventory(), shop.getProduct().getType(), shop.getProduct().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) {