From 1a624a83843fb52ea587b4b3b2322a3b421a4ee0 Mon Sep 17 00:00:00 2001 From: 17jiong <17jiong@gmail.com> Date: Mon, 29 Jan 2018 00:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=94=B6=E8=B4=AD=E5=95=86?= =?UTF-8?q?=E5=BA=97=E4=B8=8D=E8=A7=A6=E5=8F=91ShopPurchaseEvent=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=B9=B6=E4=B8=94=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E7=9A=84=E6=97=B6=E6=9C=BA=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=B2=A1=E9=92=B1=E8=B4=AD=E4=B9=B0=E4=B9=9F=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E8=BF=99=E4=B8=AA=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/maxgamer/QuickShop/Shop/ShopManager.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/maxgamer/QuickShop/Shop/ShopManager.java b/src/main/java/org/maxgamer/QuickShop/Shop/ShopManager.java index 62f2e94..85fb954 100644 --- a/src/main/java/org/maxgamer/QuickShop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/QuickShop/Shop/ShopManager.java @@ -334,6 +334,11 @@ public class ShopManager { p.sendMessage(MsgUtil.p("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(shop.getOwner())))); return; } + final ShopPurchaseEvent e = new ShopPurchaseEvent(shop, p, amount); + Bukkit.getPluginManager().callEvent(e); + if (e.isCancelled()) { + return; // Cancelled + } // Check for plugins faking econ.has(amount) if (!plugin.getEcon().withdraw(shop.getOwner(), total)) { p.sendMessage(MsgUtil.p("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(shop.getOwner())))); @@ -464,10 +469,6 @@ public class ShopManager { p.sendMessage(MsgUtil.p("not-enough-space", "" + pSpace)); return; } - final ShopPurchaseEvent e = new ShopPurchaseEvent(shop, p, amount); - Bukkit.getPluginManager().callEvent(e); - if (e.isCancelled()) { return; // Cancelled - } // Money handling if (!p.getName().equals(shop.getOwner())) { // Check their balance. Works with *most* economy @@ -476,6 +477,11 @@ public class ShopManager { p.sendMessage(MsgUtil.p("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getName())))); return; } + final ShopPurchaseEvent e = new ShopPurchaseEvent(shop, p, amount); + Bukkit.getPluginManager().callEvent(e); + if (e.isCancelled()) { + return; // Cancelled + } // Don't tax them if they're purchasing from // themselves. // Do charge an amount of tax though.