Potential fix for #1930

This commit is contained in:
MattBDev 2019-08-13 18:06:10 -04:00
parent 9642777750
commit 265f0c6615
5 changed files with 80 additions and 18 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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"),
;

View File

@ -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<br>
* - Updates DB<br>
* - Does not modify terrain<br>
* ----------<br>
* 0 = north<br>
* 1 = east<br>
* 2 = south<br>
* 3 = west<br>
* ----------<br>
*
* @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<br>
* @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 <br>- Assumes plots are directly next to each other <br> - saves to DB
* Merges two plots. <br>- Assumes plots are directly next to each other <br> - 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();

View File

@ -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);