fix: Don't charge for auto merge if there is no auto merge

This commit is contained in:
dordsor21 2022-12-18 11:00:47 +00:00
parent 35dd4899b9
commit c15e1c066d
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -294,11 +294,12 @@ public class Auto extends SubCommand {
if (this.econHandler != null && plotarea.useEconomy()) { if (this.econHandler != null && plotarea.useEconomy()) {
PlotExpression costExp = plotarea.getPrices().get("claim"); PlotExpression costExp = plotarea.getPrices().get("claim");
PlotExpression mergeCostExp = plotarea.getPrices().get("merge"); PlotExpression mergeCostExp = plotarea.getPrices().get("merge");
double mergeCost = mergeCostExp == null ? 0d : mergeCostExp.evaluate(sizeX * sizeZ); int size = sizeX * sizeZ;
double mergeCost = size > 1 && mergeCostExp == null ? 0d : mergeCostExp.evaluate(size);
double cost = costExp.evaluate(Settings.Limit.GLOBAL ? double cost = costExp.evaluate(Settings.Limit.GLOBAL ?
player.getPlotCount() : player.getPlotCount() :
player.getPlotCount(plotarea.getWorldName())); player.getPlotCount(plotarea.getWorldName()));
cost = (sizeX * sizeZ) * cost + mergeCost; cost = size * cost + mergeCost;
if (cost > 0d) { if (cost > 0d) {
if (!this.econHandler.isSupported()) { if (!this.econHandler.isSupported()) {
player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null")); player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null"));