1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

修复收购商店不触发ShopPurchaseEvent的问题,并且调整触发的时机,避免没钱购买也触发这个事件

This commit is contained in:
17jiong 2018-01-29 00:31:59 +08:00
parent 1b519fe90f
commit 1a624a8384

View File

@ -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())))); p.sendMessage(MsgUtil.p("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(shop.getOwner()))));
return; 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) // Check for plugins faking econ.has(amount)
if (!plugin.getEcon().withdraw(shop.getOwner(), total)) { 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())))); 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)); p.sendMessage(MsgUtil.p("not-enough-space", "" + pSpace));
return; return;
} }
final ShopPurchaseEvent e = new ShopPurchaseEvent(shop, p, amount);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled()) { return; // Cancelled
}
// Money handling // Money handling
if (!p.getName().equals(shop.getOwner())) { if (!p.getName().equals(shop.getOwner())) {
// Check their balance. Works with *most* economy // 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())))); p.sendMessage(MsgUtil.p("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getName()))));
return; 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 // Don't tax them if they're purchasing from
// themselves. // themselves.
// Do charge an amount of tax though. // Do charge an amount of tax though.