Option to disable hasEnough() money by Chestshop in config and let it handle by installed economy-system.
LinuxSquare opened this issue ยท 2 comments
Is your feature request related to a problem? Please describe.
Partly
I wrote an economy system, that hooks into my bank-plugin. (Both using vault). And inside my economy system I'm checking if the player has enough cash in his pocket. If this statement is false, it checks if there's enough money in the bank account. Etc.
(Might be similar to #270)
public double withdrawPlayer(UUID pUID, double amount) {
double balance = getBalance(pUID);
if(getBalance(pUID) >= amount) {
balance -= amount;
try {
PreparedStatement pstmt = getCon().prepareStatement("UPDATE Accounts SET balance = ? WHERE uuid = ?");
pstmt.setDouble(1, balance);
pstmt.setString(2, pUID.toString());
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} else {
if(novecon2.getConfigModel().getConf().getBoolean("Settings.RealBanksAPI")) {
if (novecon2.getRBAPI().getDatabaseAPIModel().getMoney(pUID) >= amount) {
double rbbal = novecon2.getRBAPI().getDatabaseAPIModel().getMoney(pUID);
double tax = (amount / 100) * novecon2.getConfigModel().getConf().getInt("Settings.TaxRate");
Bukkit.getPlayer(pUID).sendMessage(ChatColor.RED + "Tax: " + tax);
novecon2.getRBAPI().getDatabaseAPIModel().setMoney(pUID, (rbbal - (amount + (amount / 100) * novecon2.getConfigModel().getConf().getInt("Settings.TaxRate"))));
} else {
Bukkit.getPlayer(pUID).sendMessage(ChatColor.RED + "You don't have enough money in your pocket and on your bank account!");
return 0.0;
}
} else {
Bukkit.getPlayer(pUID).sendMessage(ChatColor.RED + "You don't have enough money!");
}
}
return balance;
}
Describe the solution you'd like
I would appreciate, if there was a feature, to disable the money checks of ChestShop and let it handle by the Economy-Plugin (see code above).
Example-Entry in the config.yml might look like this:
...
# If true, when you left-click your own shop sign you won't open chest's inventory, but instead you will start destroying the sign.
ALLOW_LEFT_CLICK_DESTROYING: true
#If true, ChestShop won't check, if the player has enough money. This part will be handeled by the installed economy-system.
DISABLE_CHESTSHOP_MONEY_CHECK: true
...
Describe alternatives you've considered
--
Additional context
--
Hi @Phoenix616
Thank you for your answer.
I tested it and it worked perfectly.
So with this, I will close this issue.
ChestShop already uses the checks which the economy plugin provides (via the Economy#has
method). You just need to return whether or not the player has enough on their combined accounts in your economy plugins in that method.