diff --git a/pom.xml b/pom.xml index c6e5e63..d38be2d 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ org.maxgamer QuickShop - 5.1.0.0 + 5.1.2.2 provided diff --git a/src/main/java/studio/potatocraft/quickshoplimited/QuickShopLimited.java b/src/main/java/studio/potatocraft/quickshoplimited/QuickShopLimited.java index a65c205..6680b12 100644 --- a/src/main/java/studio/potatocraft/quickshoplimited/QuickShopLimited.java +++ b/src/main/java/studio/potatocraft/quickshoplimited/QuickShopLimited.java @@ -12,6 +12,7 @@ import org.maxgamer.quickshop.api.command.CommandContainer; import org.maxgamer.quickshop.api.event.CalendarEvent; import org.maxgamer.quickshop.api.event.ShopPurchaseEvent; +import org.maxgamer.quickshop.api.event.PlayerShopClickEvent; import org.maxgamer.quickshop.api.event.ShopSuccessPurchaseEvent; import org.maxgamer.quickshop.api.shop.Shop; import org.maxgamer.quickshop.util.MsgUtil; @@ -62,6 +63,21 @@ public void shopPurchased(ShopSuccessPurchaseEvent event) { ChatColor.AQUA + MsgUtil.fillArgs(getConfig().getString("message.subtitle"), String.valueOf(limit - playerUsedLimit))); } + @EventHandler + public void shopClick(PlayerShopClickEvent event) { + + Shop shop = event.getShop(); + ConfigurationSection storage = shop.getExtra(this); + if (storage.getInt("limit") < 1) { + return; + } + int limit = storage.getInt("limit"); + int playerUsedLimit = storage.getInt("data." + event.getPlayer().getUniqueId(), 0); + + //that the message is under the shop block + Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> event.getPlayer().sendMessage(ChatColor.YELLOW + MsgUtil.fillArgs(getConfig().getString("tell-the-limit"), String.valueOf(limit), String.valueOf(limit - playerUsedLimit))), 1); + } + @EventHandler(ignoreCancelled = true) public void shopPrePurchase(ShopPurchaseEvent event) { Shop shop = event.getShop(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b775053..f809dd5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,4 +1,5 @@ command-description: "Limit the amount per player can purchase" +tell-the-limit: "This shop has an limit of {0} items! You can purchase {1}." reach-the-limit: "You have reached the limit in this shop. You can purchase {0}, but you trying purchase {1}." success-reset: "Reset successfully" success-setup: "Set up!"