mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-01-27 08:51:19 +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;
|
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());
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user