mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +01:00
make autoMerge way more readable
This commit is contained in:
parent
e914cb210e
commit
e5913faa94
@ -549,6 +549,8 @@ public final class PlotModificationManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final Direction[] DIRECTIONS = {Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
||||
|
||||
/**
|
||||
* Auto merge a plot in a specific direction.
|
||||
*
|
||||
@ -583,8 +585,12 @@ public final class PlotModificationManager {
|
||||
}
|
||||
visited.add(current);
|
||||
Set<Plot> plots;
|
||||
if ((dir == Direction.ALL || dir == Direction.NORTH) && !current.isMerged(Direction.NORTH)) {
|
||||
Plot other = current.getRelative(Direction.NORTH);
|
||||
for (final Direction direction : DIRECTIONS) {
|
||||
if (max <= 0) {
|
||||
break;
|
||||
}
|
||||
if ((dir == Direction.ALL || dir == direction) && !current.isMerged(direction)) {
|
||||
Plot other = current.getRelative(direction);
|
||||
if (other != null && other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||
current.mergePlot(other, removeRoads, queue);
|
||||
@ -600,56 +606,6 @@ public final class PlotModificationManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (max >= 0 && (dir == Direction.ALL || dir == Direction.EAST) && !current.isMerged(Direction.EAST)) {
|
||||
Plot other = current.getRelative(Direction.EAST);
|
||||
if (other != null && other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||
current.mergePlot(other, removeRoads, queue);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
|
||||
if (removeRoads) {
|
||||
ArrayList<PlotId> ids = new ArrayList<>();
|
||||
ids.add(current.getId());
|
||||
ids.add(other.getId());
|
||||
this.plot.getManager().finishPlotMerge(ids, queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (max >= 0 && (dir == Direction.ALL || dir == Direction.SOUTH) && !current.isMerged(Direction.SOUTH)) {
|
||||
Plot other = current.getRelative(Direction.SOUTH);
|
||||
if (other != null && other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||
current.mergePlot(other, removeRoads, queue);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
|
||||
if (removeRoads) {
|
||||
ArrayList<PlotId> ids = new ArrayList<>();
|
||||
ids.add(current.getId());
|
||||
ids.add(other.getId());
|
||||
this.plot.getManager().finishPlotMerge(ids, queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (max >= 0 && (dir == Direction.ALL || dir == Direction.WEST) && !current.isMerged(Direction.WEST)) {
|
||||
Plot other = current.getRelative(Direction.WEST);
|
||||
if (other != null && other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||
current.mergePlot(other, removeRoads, queue);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
|
||||
if (removeRoads) {
|
||||
ArrayList<PlotId> ids = new ArrayList<>();
|
||||
ids.add(current.getId());
|
||||
ids.add(other.getId());
|
||||
this.plot.getManager().finishPlotMerge(ids, queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||
|
Loading…
Reference in New Issue
Block a user