Compare commits

...

3 Commits

Author SHA1 Message Date
Matthew e0cc1fd47b
Merge e5913faa94 into c57d784df7 2024-04-23 02:10:54 +00:00
renovate[bot] c57d784df7 Update dependency xyz.jpenilla.run-paper to v2.2.4 2024-04-23 02:10:41 +00:00
Matthew e5913faa94 make autoMerge way more readable 2023-05-03 11:01:31 +02:00
2 changed files with 20 additions and 64 deletions

View File

@ -553,6 +553,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.
*
@ -587,71 +589,25 @@ 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);
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);
}
for (final Direction direction : DIRECTIONS) {
if (max <= 0) {
break;
}
}
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 ((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);
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 (removeRoads) {
ArrayList<PlotId> ids = new ArrayList<>();
ids.add(current.getId());
ids.add(other.getId());
this.plot.getManager().finishPlotMerge(ids, queue);
}
}
}
}

View File

@ -37,7 +37,7 @@ shadow = "8.1.1"
grgit = "4.1.1"
spotless = "6.25.0"
nexus = "2.0.0"
runPaper = "2.2.3"
runPaper = "2.2.4"
[libraries]
# Platform expectations