feat: add cost for the merge when using plot auto-merge (#3841)

* feat: add cost for the merge when using plot auto-merge
 - Closes #3814

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

---------

Co-authored-by: Alexander Brandes <mc.cache@web.de>
This commit is contained in:
Jordan 2023-05-21 16:57:46 +01:00 committed by GitHub
parent 958c66b28f
commit 02437a8c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

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