Replaced economy supported (Vault) check within cost condition with a pre-eliminating if-guard (#3014)

This commit is contained in:
Patrick "IPat" Hein 2021-05-12 19:00:14 +02:00 committed by GitHub
parent ca7ac71e76
commit 68eb5cd74f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -312,15 +312,16 @@ public class Auto extends SubCommand {
player.getPlotCount(plotarea.getWorldName()));
cost = (size_x * size_z) * cost;
if (cost > 0d) {
if (!force && this.econHandler.getMoney(player) < cost && this.econHandler.isSupported()) {
if (!this.econHandler.isSupported()) {
player.sendMessage(TranslatableCaption.of("economy.vault_not_found"));
return false;
}
if (!force && this.econHandler.getMoney(player) < cost) {
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_plot"),
Template.of("money", this.econHandler.format(cost)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player)))
);
} else {
player.sendMessage(TranslatableCaption.of("economy.vault_not_found"));
return false;
}
this.econHandler.withdrawMoney(player, cost);
player.sendMessage(

View File

@ -151,15 +151,16 @@ public class Claim extends SubCommand {
PlotExpression costExr = area.getPrices().get("claim");
double cost = costExr.evaluate(currentPlots);
if (cost > 0d) {
if (this.econHandler.getMoney(player) < cost && this.econHandler.isSupported()) {
if (!this.econHandler.isSupported()) {
player.sendMessage(TranslatableCaption.of("economy.vault_not_found"));
return false;
}
if (this.econHandler.getMoney(player) < cost) {
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_plot"),
Template.of("money", this.econHandler.format(cost)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player)))
);
} else {
player.sendMessage(TranslatableCaption.of("economy.vault_not_found"));
return false;
}
this.econHandler.withdrawMoney(player, cost);
player.sendMessage(