Fix the issue with Admin Shops

This commit is contained in:
Acrobot 2013-07-21 16:51:36 +02:00
parent ff4cfb0c7c
commit 968296f1bb
2 changed files with 26 additions and 0 deletions

View File

@ -25,6 +25,10 @@ public class VaultListener implements Listener {
this.provider = provider; this.provider = provider;
} }
public boolean transactionCanFail() {
return provider.getName().equals("Gringotts") || provider.getName().equals("GoldIsMoney") || provider.getName().equals("MultiCurrency");
}
/** /**
* Creates a new VaultListener and returns it (if possible) * Creates a new VaultListener and returns it (if possible)
* *
@ -133,10 +137,20 @@ public class VaultListener implements Listener {
@EventHandler @EventHandler
public void onCurrencyHoldCheck(CurrencyHoldEvent event) { public void onCurrencyHoldCheck(CurrencyHoldEvent event) {
if (event.getAccount().isEmpty() || !transactionCanFail()) {
return;
}
if (!provider.hasAccount(event.getAccount(), event.getWorld().getName())) {
event.canHold(false);
return;
}
EconomyResponse response = provider.depositPlayer(event.getAccount(), event.getWorld().getName(), event.getDoubleAmount()); EconomyResponse response = provider.depositPlayer(event.getAccount(), event.getWorld().getName(), event.getDoubleAmount());
if (!response.transactionSuccess()) { if (!response.transactionSuccess()) {
event.canHold(false); event.canHold(false);
return;
} }
provider.withdrawPlayer(event.getAccount(), event.getWorld().getName(), event.getDoubleAmount()); provider.withdrawPlayer(event.getAccount(), event.getWorld().getName(), event.getDoubleAmount());

View File

@ -78,6 +78,18 @@ public class ServerAccountCorrector implements Listener {
event.hasEnough(currencyCheckEvent.hasEnough()); event.hasEnough(currencyCheckEvent.hasEnough());
} }
@EventHandler(priority = EventPriority.LOWEST)
public static void onCurrencyHoldCheck(CurrencyHoldEvent event) {
String target = event.getAccount();
if (!ChestShopSign.isAdminShop(target)) {
return;
}
event.canHold(true);
event.setAccount("");
}
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public static void onBalanceCheck(CurrencyAmountEvent event) { public static void onBalanceCheck(CurrencyAmountEvent event) {
String target = event.getAccount(); String target = event.getAccount();