feat: allow bypass of econ costs (#4126)

This commit is contained in:
Jordan 2023-08-02 12:48:07 +01:00 committed by GitHub
parent 49e13384cf
commit 0d63c2bdb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 12 deletions

View File

@ -294,7 +294,7 @@ public class Auto extends SubCommand {
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 mergeCostExp = plotarea.getPrices().get("merge");
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");
double cost = costExr.evaluate(currentPlots);
if (cost > 0d) {

View File

@ -183,7 +183,7 @@ public class MainCommand extends Command {
if (cmd.hasConfirmation(player)) {
CmdConfirm.addPending(player, cmd.getUsage(), () -> {
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());
double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
@ -201,7 +201,7 @@ public class MainCommand extends Command {
return;
}
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());
double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d && econHandler.getMoney(player) < price) {

View File

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

View File

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

View File

@ -201,7 +201,8 @@ public enum Permission implements ComponentLike {
PERMISSION_RATE("plots.rate"),
PERMISSION_ADMIN_FLIGHT("plots.admin.flight"),
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>
private final String text;