diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java index 2c5d9c9d0..947dd22fd 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java @@ -356,8 +356,8 @@ import java.util.Set; } if (PaperLib.getMinecraftVersion() == 13) { block.setType(Material.valueOf("WALL_SIGN"), false); - } else { - block.setType(Material.valueOf("OAK_WALL_SIGN"), false); + } else if (PaperLib.getMinecraftVersion() == 14) { + block.setType(Material.OAK_WALL_SIGN, false); } final Directional sign = (Directional) block.getBlockData(); sign.setFacing(facing); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Unlink.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Unlink.java index 9ce6bd5fb..4805c75e7 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Unlink.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Unlink.java @@ -5,7 +5,11 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; -import com.github.intellectualsites.plotsquared.plot.util.*; +import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm; +import com.github.intellectualsites.plotsquared.plot.util.MainUtil; +import com.github.intellectualsites.plotsquared.plot.util.Permissions; +import com.github.intellectualsites.plotsquared.plot.util.StringMan; +import com.github.intellectualsites.plotsquared.plot.util.TaskManager; @CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"}, description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", @@ -14,8 +18,8 @@ public class Unlink extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { - Location loc = player.getLocation(); - final Plot plot = loc.getPlotAbs(); + Location location = player.getLocation(); + final Plot plot = location.getPlotAbs(); if (plot == null) { return !sendMessage(player, Captions.NOT_IN_PLOT); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Direction.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Direction.java index 0c7de4905..e39dfba0e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Direction.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Direction.java @@ -1,9 +1,9 @@ package com.github.intellectualsites.plotsquared.plot.object; public enum Direction { - NORTH(0, "north"), EAST(1, "east"), SOUTH(2, "south"), WEST(3, "west"), NORTHEAST(4, - "northeast"), SOUTHEAST(5, "southeast"), SOUTHWEST(6, "southwest"), NORTHWEST(7, - "northwest"), + ALL(-1, "all"), NORTH(0, "north"), EAST(1, "east"), SOUTH(2, "south"), WEST(3, + "west"), NORTHEAST(4, "northeast"), SOUTHEAST(5, "southeast"), SOUTHWEST(6, + "southwest"), NORTHWEST(7, "northwest"), ; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index 513a74ec0..a03ac6dd5 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -790,7 +790,7 @@ public class Plot { /** * Sets the plot owner (and update the database) * - * @param owner uuid to set as owner + * @param owner uuid to set as owner * @param initiator player initiating set owner * @return boolean */ @@ -1003,7 +1003,7 @@ public class Plot { } PlotManager manager = this.area.getPlotManager(); if (this.area.ALLOW_SIGNS) { - Location loc = manager.getSignLoc(this); + Location location = manager.getSignLoc(this); String id = this.id.x + ";" + this.id.y; String[] lines = new String[] {Captions.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id), @@ -1013,7 +1013,9 @@ public class Plot { "%plr%", name), Captions.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll( "%plr%", name)}; - WorldUtil.IMP.setSign(this.getWorldName(), loc.getX(), loc.getY(), loc.getZ(), lines); + WorldUtil.IMP + .setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(), + lines); } } @@ -2054,6 +2056,44 @@ public class Plot { } } + /** + * Sets the raw merge data
+ * - Updates DB
+ * - Does not modify terrain
+ * ----------
+ * 0 = north
+ * 1 = east
+ * 2 = south
+ * 3 = west
+ * ----------
+ * + * @param direction + * @param value + */ + public void setMerged(Direction direction, boolean value) { + if (this.getSettings().setMerged(direction.getIndex(), value)) { + if (value) { + Plot other = this.getRelative(direction).getBasePlot(false); + if (!other.equals(this.getBasePlot(false))) { + Plot base = other.id.y < this.id.y + || other.id.y == this.id.y && other.id.x < this.id.x ? other : this.origin; + this.origin.origin = base; + other.origin = base; + this.origin = base; + connected_cache = null; + } + } else { + if (this.origin != null) { + this.origin.origin = null; + this.origin = null; + } + connected_cache = null; + } + DBFunc.setMerged(this, this.getSettings().getMerged()); + regions_cache = null; + } + } + /** * Gets the merged array. * @@ -2219,7 +2259,7 @@ public class Plot { * 3 = west
* @param max The max number of merges to do * @param uuid The UUID it is allowed to merge with - * @param removeRoads Whether to remove roads + * @param removeRoads whether to remove roads * @return true if a merge takes place */ public boolean autoMerge(int dir, int max, UUID uuid, boolean removeRoads) { @@ -2852,7 +2892,7 @@ public class Plot { } /** - * Merges 2 plots Removes the road in-between
- Assumes plots are directly next to each other
- saves to DB + * Merges two plots.
- Assumes plots are directly next to each other
- saves to DB * * @param lesserPlot * @param removeRoads @@ -2868,10 +2908,11 @@ public class Plot { if (!lesserPlot.getMerged(Direction.SOUTH)) { lesserPlot.clearRatings(); greaterPlot.clearRatings(); - lesserPlot.setMerged(2, true); - greaterPlot.setMerged(0, true); + lesserPlot.setMerged(Direction.SOUTH, true); + greaterPlot.setMerged(Direction.NORTH, true); lesserPlot.mergeData(greaterPlot); if (removeRoads) { + lesserPlot.removeSign(); lesserPlot.removeRoadSouth(); Plot diagonal = greaterPlot.getRelative(Direction.EAST); if (diagonal.getMerged(Direction.NORTHWEST)) { @@ -2892,10 +2933,11 @@ public class Plot { if (!lesserPlot.getMerged(Direction.EAST)) { lesserPlot.clearRatings(); greaterPlot.clearRatings(); - lesserPlot.setMerged(1, true); - greaterPlot.setMerged(3, true); + lesserPlot.setMerged(Direction.EAST, true); + greaterPlot.setMerged(Direction.WEST, true); lesserPlot.mergeData(greaterPlot); if (removeRoads) { + lesserPlot.removeSign(); Plot diagonal = greaterPlot.getRelative(Direction.SOUTH); if (diagonal.getMerged(Direction.NORTHWEST)) { lesserPlot.removeRoadSouthEast(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotSettings.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotSettings.java index 829e42dbd..ce51fea33 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotSettings.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotSettings.java @@ -5,7 +5,12 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; import com.google.common.collect.ImmutableList; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; /** * Generic settings class. @@ -80,6 +85,17 @@ public class PlotSettings { return false; } + public boolean setMerged(Direction direction, boolean merged) { + if (Direction.ALL == direction) { + throw new IllegalArgumentException("You cannot use Direction.ALL in this method!"); + } + if (this.merged[direction.getIndex()] != merged) { + this.merged[direction.getIndex()] = merged; + return true; + } + return false; + } + public BlockLoc getPosition() { if (this.position == null) { return new BlockLoc(0, 0, 0);