feat: allow bypass of econ costs

This commit is contained in:
dordsor21 2023-07-30 16:08:32 +01:00
parent 638f0bd078
commit dfcc21c7ac
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
6 changed files with 13 additions and 12 deletions

View File

@ -294,7 +294,7 @@ public class Auto extends SubCommand {
return true; return true;
} }
} }
if (this.econHandler != null && plotarea.useEconomy()) { if (this.econHandler != null && plotarea.useEconomy() && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON)) {
PlotExpression costExp = plotarea.getPrices().get("claim"); PlotExpression costExp = plotarea.getPrices().get("claim");
PlotExpression mergeCostExp = plotarea.getPrices().get("merge"); PlotExpression mergeCostExp = plotarea.getPrices().get("merge");
int size = sizeX * sizeZ; int size = sizeX * sizeZ;

View File

@ -141,7 +141,7 @@ public class Claim extends SubCommand {
} }
} }
} }
if (this.econHandler.isEnabled(area) && !force) { if (this.econHandler.isEnabled(area) && !force && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON)) {
PlotExpression costExr = area.getPrices().get("claim"); PlotExpression costExr = area.getPrices().get("claim");
double cost = costExr.evaluate(currentPlots); double cost = costExr.evaluate(currentPlots);
if (cost > 0d) { if (cost > 0d) {

View File

@ -183,7 +183,7 @@ public class MainCommand extends Command {
if (cmd.hasConfirmation(player)) { if (cmd.hasConfirmation(player)) {
CmdConfirm.addPending(player, cmd.getUsage(), () -> { CmdConfirm.addPending(player, cmd.getUsage(), () -> {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null && econHandler.isEnabled(area)) { if (area != null && econHandler.isEnabled(area) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON)) {
PlotExpression priceEval = PlotExpression priceEval =
area.getPrices().get(cmd.getFullId()); area.getPrices().get(cmd.getFullId());
double price = priceEval != null ? priceEval.evaluate(0d) : 0d; double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
@ -201,7 +201,7 @@ public class MainCommand extends Command {
return; return;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null && econHandler.isEnabled(area)) { if (area != null && econHandler.isEnabled(area) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON)) {
PlotExpression priceEval = area.getPrices().get(cmd.getFullId()); PlotExpression priceEval = area.getPrices().get(cmd.getFullId());
double price = priceEval != null ? priceEval.evaluate(0d) : 0d; double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d && econHandler.getMoney(player) < price) { if (price != 0d && econHandler.getMoney(player) < price) {

View File

@ -178,7 +178,7 @@ public class Merge extends SubCommand {
return true; return true;
} }
if (plot.getPlotModificationManager().autoMerge(Direction.ALL, maxSize, uuid, player, terrain)) { if (plot.getPlotModificationManager().autoMerge(Direction.ALL, maxSize, uuid, player, terrain)) {
if (this.econHandler.isEnabled(plotArea) && price > 0d) { if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
this.econHandler.withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.of("economy.removed_balance"),
@ -196,8 +196,8 @@ public class Merge extends SubCommand {
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
return false; return false;
} }
if (!force && this.econHandler.isEnabled(plotArea) && price > 0d if (!force && this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d && this.econHandler.getMoney(
&& this.econHandler.getMoney(player) < price) { player) < price) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_merge"), TranslatableCaption.of("economy.cannot_afford_merge"),
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price)))) TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price))))
@ -218,7 +218,7 @@ public class Merge extends SubCommand {
return true; return true;
} }
if (plot.getPlotModificationManager().autoMerge(direction, maxSize - size, uuid, player, terrain)) { if (plot.getPlotModificationManager().autoMerge(direction, maxSize - size, uuid, player, terrain)) {
if (this.econHandler.isEnabled(plotArea) && price > 0d) { if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
this.econHandler.withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.of("economy.removed_balance"),
@ -259,7 +259,7 @@ public class Merge extends SubCommand {
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid")); accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid"));
return; return;
} }
if (this.econHandler.isEnabled(plotArea) && price > 0d) { if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
if (!force && this.econHandler.getMoney(player) < price) { if (!force && this.econHandler.getMoney(player) < price) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_merge"), TranslatableCaption.of("economy.cannot_afford_merge"),
@ -303,7 +303,7 @@ public class Merge extends SubCommand {
player, player,
terrain terrain
)) { )) {
if (this.econHandler.isEnabled(plotArea) && price > 0d) { if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
if (!force && this.econHandler.getMoney(player) < price) { if (!force && this.econHandler.getMoney(player) < price) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_merge"), TranslatableCaption.of("economy.cannot_afford_merge"),

View File

@ -206,7 +206,7 @@ public class ComponentPresetManager {
return false; return false;
} }
if (componentPreset.cost() > 0.0D) { if (componentPreset.cost() > 0.0D && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON)) {
if (!econHandler.isEnabled(plot.getArea())) { if (!econHandler.isEnabled(plot.getArea())) {
getPlayer().sendMessage( getPlayer().sendMessage(
TranslatableCaption.of("preset.economy_disabled"), TranslatableCaption.of("preset.economy_disabled"),

View File

@ -200,7 +200,8 @@ public enum Permission implements ComponentLike {
PERMISSION_RATE("plots.rate"), PERMISSION_RATE("plots.rate"),
PERMISSION_ADMIN_FLIGHT("plots.admin.flight"), PERMISSION_ADMIN_FLIGHT("plots.admin.flight"),
PERMISSION_ADMIN_COMPONENTS_OTHER("plots.admin.component.other"), PERMISSION_ADMIN_COMPONENTS_OTHER("plots.admin.component.other"),
PERMISSION_ADMIN_BYPASS_BORDER("plots.admin.border.bypass"); PERMISSION_ADMIN_BYPASS_BORDER("plots.admin.border.bypass"),
PERMISSION_ADMIN_BYPASS_ECON("plots.admin.econ.bypass");
//</editor-fold> //</editor-fold>
private final String text; private final String text;