diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java index 8681d4dff..174f25dae 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -76,19 +76,18 @@ public class Auto extends SubCommand { } else { currentPlots = player.getPlotCount(plotarea.getWorldName()); } - int diff = currentPlots - allowedPlots; - if (diff + sizeX * sizeZ > 0) { - if (diff < 0) { - MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM, -diff + ""); - return false; - } else if (player.hasPersistentMeta("grantedPlots")) { + int diff = allowedPlots - currentPlots; + if (diff - sizeX * sizeZ < 0) { + if (player.hasPersistentMeta("grantedPlots")) { int grantedPlots = Ints.fromByteArray(player.getPersistentMeta("grantedPlots")); - if (grantedPlots - diff < sizeX * sizeZ) { - player.removePersistentMeta("grantedPlots"); + if (diff < 0 && grantedPlots < sizeX * sizeZ) { + MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS); + return false; + } else if (diff >= 0 && grantedPlots + diff < sizeX * sizeZ) { MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS); return false; } else { - int left = grantedPlots - diff - sizeX * sizeZ; + int left = grantedPlots + diff < 0 ? 0 : diff - sizeX * sizeZ; if (left == 0) { player.removePersistentMeta("grantedPlots"); } else { @@ -134,24 +133,10 @@ public class Auto extends SubCommand { */ public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start, final String schematic) { - autoClaimSafe(player, area, start, schematic, null); - } - - /** - * Claim a new plot for a player - * - * @param player - * @param area - * @param start - * @param schematic - */ - public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start, - final String schematic, @Nullable final Integer allowedPlots) { player.setMeta(Auto.class.getName(), true); autoClaimFromDatabase(player, area, start, new RunnableVal() { @Override public void run(final Plot plot) { - TaskManager.IMP - .sync(new AutoClaimFinishTask(player, plot, area, allowedPlots, schematic)); + TaskManager.IMP.sync(new AutoClaimFinishTask(player, plot, area, schematic)); } }); } @@ -282,7 +267,7 @@ public class Auto extends SubCommand { } // TODO handle type 2 (partial) the same as normal worlds! if (size_x == 1 && size_z == 1) { - autoClaimSafe(player, plotarea, null, schematic, allowed_plots); + autoClaimSafe(player, plotarea, null, schematic); return true; } else { if (plotarea.getType() == PlotAreaType.PARTIAL) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java index 668142ce5..2f4ee7781 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -122,7 +122,7 @@ public class Claim extends SubCommand { } else { player.setPersistentMeta("grantedPlots", Ints.toByteArray(grants - 1)); } - sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); + sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", (grants - 1)); } int border = area.getBorder(); if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) { diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Captions.java b/Core/src/main/java/com/plotsquared/core/configuration/Captions.java index 0daa72732..bbba53f6f 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Captions.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Captions.java @@ -322,7 +322,7 @@ public enum Captions implements Caption { CANNOT_AFFORD_MERGE("$2You cannot afford to merge the plots. It costs $1%s","Economy"), ADDED_BALANCE("$1%s $2has been added to your balance", "Economy"), REMOVED_BALANCE("$1%s $2has been taken from your balance", "Economy"), - REMOVED_GRANTED_PLOT("$2You used %s plot grant(s), you've got $1%s $2left", "Economy"), + REMOVED_GRANTED_PLOT("$2You used %s0 plot grant(s), you've got $1%s1 $2left", "Economy"), // // SETUP_INIT("$1Usage: $2/plot setup ", "Setup"), diff --git a/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java b/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java index 81d2d2199..164e12ae3 100644 --- a/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java +++ b/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java @@ -45,7 +45,6 @@ public final class AutoClaimFinishTask extends RunnableVal { private final PlotPlayer player; private final Plot plot; private final PlotArea area; - private final int allowedPlots; private final String schematic; @Override public void run(Object value) { @@ -54,21 +53,15 @@ public final class AutoClaimFinishTask extends RunnableVal { sendMessage(player, Captions.NO_FREE_PLOTS); return; } - - if (Auto.checkAllowedPlots(player, area, allowedPlots, 1, 1)) { - plot.claim(player, true, schematic, false); - if (area.isAutoMerge()) { - PlotMergeEvent event = PlotSquared.get().getEventDispatcher() - .callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); - if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Auto merge"); - } else { - plot.autoMerge(event.getDir(), event.getMax(), player.getUUID(), true); - } + plot.claim(player, true, schematic, false); + if (area.isAutoMerge()) { + PlotMergeEvent event = PlotSquared.get().getEventDispatcher() + .callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); + if (event.getEventResult() == Result.DENY) { + sendMessage(player, Captions.EVENT_DENIED, "Auto merge"); + } else { + plot.autoMerge(event.getDir(), event.getMax(), player.getUUID(), true); } - } else { - DBFunc.delete(plot); } } - }