mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-01-12 01:50:36 +01:00
Fix the issue with Admin Shops
This commit is contained in:
parent
ff4cfb0c7c
commit
968296f1bb
@ -25,6 +25,10 @@ public class VaultListener implements Listener {
|
||||
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)
|
||||
*
|
||||
@ -133,10 +137,20 @@ public class VaultListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
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());
|
||||
|
||||
if (!response.transactionSuccess()) {
|
||||
event.canHold(false);
|
||||
return;
|
||||
}
|
||||
|
||||
provider.withdrawPlayer(event.getAccount(), event.getWorld().getName(), event.getDoubleAmount());
|
||||
|
@ -78,6 +78,18 @@ public class ServerAccountCorrector implements Listener {
|
||||
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)
|
||||
public static void onBalanceCheck(CurrencyAmountEvent event) {
|
||||
String target = event.getAccount();
|
||||
|
Loading…
Reference in New Issue
Block a user