mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Fixes #646
This commit is contained in:
parent
c3eb44f51c
commit
b9bb9f5674
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>3.2.3</version>
|
<version>3.2.4</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -4,12 +4,16 @@ import java.io.File;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
|
|
||||||
@ -91,10 +95,35 @@ public class GenerateDocs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getPerms(final String cmd, final List<String> lines) {
|
public static List<String> getPerms(final String cmd, final List<String> lines) {
|
||||||
final ArrayList<String> perms = new ArrayList<String>();
|
final HashSet<String> perms = new HashSet<String>();
|
||||||
final Pattern p = Pattern.compile("\"([^\"]*)\"");
|
final Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||||
|
final Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)");
|
||||||
|
String last = null;
|
||||||
for (final String line : lines) {
|
for (final String line : lines) {
|
||||||
|
|
||||||
|
Matcher m2 = p2.matcher(line);
|
||||||
|
while (m2.find()) {
|
||||||
|
perms.add(C.valueOf("PERMISSION_" + m2.group(1)).s());
|
||||||
|
}
|
||||||
|
|
||||||
if (line.contains("Permissions.hasPermission(")) {
|
if (line.contains("Permissions.hasPermission(")) {
|
||||||
|
String[] split = line.split("Permissions.hasPermission");
|
||||||
|
split = Arrays.copyOfRange(split, 1, split.length);
|
||||||
|
for (String method : split) {
|
||||||
|
String perm = method.split("[,|)]")[1].trim();
|
||||||
|
if (!perm.toLowerCase().equals(perm)) {
|
||||||
|
if (perm.startsWith("C.")) {
|
||||||
|
perm = C.valueOf(perm.split("\\.")[1]).s();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
perm = perm.substring(1, perm.length() - 1);
|
||||||
|
}
|
||||||
|
perms.add(perm);
|
||||||
|
}
|
||||||
final Matcher m = p.matcher(line);
|
final Matcher m = p.matcher(line);
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
String perm = m.group(1);
|
String perm = m.group(1);
|
||||||
@ -102,21 +131,42 @@ public class GenerateDocs {
|
|||||||
perm += "<arg>";
|
perm += "<arg>";
|
||||||
}
|
}
|
||||||
if (perm.startsWith(".")) {
|
if (perm.startsWith(".")) {
|
||||||
perms.set(perms.size() - 1, perms.get(perms.size() - 1) + perm);
|
perms.remove(last);
|
||||||
|
perms.add(last + perm);
|
||||||
} else if (perm.contains(".")) {
|
} else if (perm.contains(".")) {
|
||||||
|
last = perm;
|
||||||
perms.add(perm);
|
perms.add(perm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (line.contains("Permissions.hasPermissionRange")) {
|
||||||
|
String[] split = line.split("Permissions.hasPermissionRange");
|
||||||
|
split = Arrays.copyOfRange(split, 1, split.length);
|
||||||
|
for (String method : split) {
|
||||||
|
String perm = method.split("[,|)]")[1].trim();
|
||||||
|
if (!perm.toLowerCase().equals(perm)) {
|
||||||
|
if (perm.startsWith("C.")) {
|
||||||
|
perm = C.valueOf(perm.split("\\.")[1]).s();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
perm = perm.substring(1, perm.length() - 1);
|
||||||
|
}
|
||||||
|
perms.add(perm + ".<#>");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch (cmd.toLowerCase()) {
|
switch (cmd.toLowerCase()) {
|
||||||
case "auto":
|
case "auto":
|
||||||
case "claim": {
|
case "claim": {
|
||||||
perms.add("plots.plot.#");
|
perms.add("plots.plot.<#>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return perms;
|
return new ArrayList<>(perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getComments(final List<String> lines) {
|
public static String getComments(final List<String> lines) {
|
||||||
|
@ -86,11 +86,16 @@ public class Merge extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final boolean admin = Permissions.hasPermission(plr, "plots.admin.command.merge");
|
UUID uuid = plr.getUUID();
|
||||||
if (!plot.isOwner(plr.getUUID()) && !admin) {
|
if (!plot.isOwner(uuid)) {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.admin.command.merge")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
uuid = plot.owner;
|
||||||
|
}
|
||||||
|
}
|
||||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d && EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
|
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d && EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
|
||||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
|
sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
|
||||||
@ -99,7 +104,7 @@ public class Merge extends SubCommand {
|
|||||||
int direction = -1;
|
int direction = -1;
|
||||||
final int size = plot.getConnectedPlots().size();
|
final int size = plot.getConnectedPlots().size();
|
||||||
final int maxSize = Permissions.hasPermissionRange(plr, "plots.merge", Settings.MAX_PLOTS);
|
final int maxSize = Permissions.hasPermissionRange(plr, "plots.merge", Settings.MAX_PLOTS);
|
||||||
if (size >= maxSize) {
|
if (size - 1> maxSize) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + (size + 1));
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + (size + 1));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -120,7 +125,7 @@ public class Merge extends SubCommand {
|
|||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("auto")) {
|
if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("auto")) {
|
||||||
if (MainUtil.autoMerge(plot, -1, maxSize - size, plr.getUUID(), (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
|
if (MainUtil.autoMerge(plot, -1, maxSize - size, uuid, (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
|
||||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
||||||
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
||||||
@ -144,7 +149,7 @@ public class Merge extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
|
MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (MainUtil.autoMerge(plot, direction, maxSize - size, plot.owner, (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
|
if (MainUtil.autoMerge(plot, direction, maxSize - size, uuid, (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
|
||||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
||||||
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
||||||
@ -153,7 +158,7 @@ public class Merge extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Plot adjacent = MainUtil.getPlotAbs(plot.world, MainUtil.getPlotIdRelative(plot.id, direction));
|
Plot adjacent = MainUtil.getPlotAbs(plot.world, MainUtil.getPlotIdRelative(plot.id, direction));
|
||||||
if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4)) {
|
if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4) || adjacent.isOwner(uuid)) {
|
||||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -163,8 +168,8 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
HashSet<UUID> uuids = adjacent.getOwners();
|
HashSet<UUID> uuids = adjacent.getOwners();
|
||||||
boolean isOnline = false;
|
boolean isOnline = false;
|
||||||
for (final UUID uuid : uuids) {
|
for (final UUID owner : uuids) {
|
||||||
final PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
|
final PlotPlayer accepter = UUIDHandler.getPlayer(owner);
|
||||||
if (accepter == null) {
|
if (accepter == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -174,7 +179,7 @@ public class Merge extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||||
MainUtil.autoMerge(plot, dir, maxSize - size, uuid, true);
|
MainUtil.autoMerge(plot, dir, maxSize - size, owner, true);
|
||||||
final PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID());
|
final PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID());
|
||||||
if (pp == null) {
|
if (pp == null) {
|
||||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||||
|
@ -97,7 +97,7 @@ public class Toggle extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (PS.get().worldedit != null) {
|
if (PS.get() != null && PS.get().worldedit != null) {
|
||||||
toggles.put("worldedit", new Command<PlotPlayer>("worldedit", "/plot toggle worldedit", "Toggle worldedit bypass", C.PERMISSION_WORLDEDIT_BYPASS.s()) {
|
toggles.put("worldedit", new Command<PlotPlayer>("worldedit", "/plot toggle worldedit", "Toggle worldedit bypass", C.PERMISSION_WORLDEDIT_BYPASS.s()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -44,7 +45,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
|||||||
command = "visit",
|
command = "visit",
|
||||||
permission = "plots.visit",
|
permission = "plots.visit",
|
||||||
description = "Visit someones plot",
|
description = "Visit someones plot",
|
||||||
usage = "/plot visit <player|aliases|world|id> [#]",
|
usage = "/plot visit <player|alias|world|id> [#]",
|
||||||
aliases = { "v" },
|
aliases = { "v" },
|
||||||
requiredType = RequiredType.NONE,
|
requiredType = RequiredType.NONE,
|
||||||
category = CommandCategory.TELEPORT)
|
category = CommandCategory.TELEPORT)
|
||||||
@ -94,8 +95,7 @@ public class Visit extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
final Plot plot = MainUtil.getPlotFromString(player, args[0], true);
|
final Plot plot = MainUtil.getPlotFromString(player, args[0], true);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
unsorted = new HashSet<>();
|
unsorted = new HashSet<>(Arrays.asList(plot.getBasePlot(false)));
|
||||||
unsorted.add(plot);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -339,7 +339,7 @@ public enum C {
|
|||||||
MERGE_REQUESTED("$2Successfully sent a merge request", "Merge"),
|
MERGE_REQUESTED("$2Successfully sent a merge request", "Merge"),
|
||||||
MERGE_REQUEST_CONFIRM("merge request from %s", "Permission"),
|
MERGE_REQUEST_CONFIRM("merge request from %s", "Permission"),
|
||||||
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%", "Merge"),
|
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%", "Merge"),
|
||||||
NO_AVAILABLE_AUTOMERGE("$2You do not own any adjacent plots in the specified direction.", "Merge"),
|
NO_AVAILABLE_AUTOMERGE("$2You do not own any adjacent plots in the specified direction or are not allowed to merge to the required size.", "Merge"),
|
||||||
UNLINK_REQUIRED("$2An unlink is required to do this.", "Merge"),
|
UNLINK_REQUIRED("$2An unlink is required to do this.", "Merge"),
|
||||||
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot", "Merge"),
|
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot", "Merge"),
|
||||||
UNLINK_SUCCESS("$2Successfully unlinked plots.", "Merge"),
|
UNLINK_SUCCESS("$2Successfully unlinked plots.", "Merge"),
|
||||||
|
@ -429,25 +429,21 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public Plot getBasePlot(boolean recalculate) {
|
public Plot getBasePlot(boolean recalculate) {
|
||||||
if ((origin != null && !recalculate)) {
|
if ((origin != null && !recalculate)) {
|
||||||
return origin;
|
if (this.equals(origin)) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return origin.getBasePlot(false);
|
||||||
}
|
}
|
||||||
if (!isMerged()) {
|
if (!isMerged()) {
|
||||||
origin = this;
|
origin = this;
|
||||||
return origin;
|
return origin;
|
||||||
}
|
}
|
||||||
int min = Integer.MAX_VALUE;
|
origin = this;
|
||||||
|
PlotId min = id;
|
||||||
for (Plot plot : MainUtil.getConnectedPlots(this)) {
|
for (Plot plot : MainUtil.getConnectedPlots(this)) {
|
||||||
if (plot.temp != -1) {
|
if (plot.id.y < min.y || (plot.id.y == min.y && plot.id.x < min.x)) {
|
||||||
if (plot.temp < min) {
|
|
||||||
min = plot.temp;
|
|
||||||
origin = plot;
|
origin = plot;
|
||||||
}
|
min = plot.id;
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (plot.hashCode() < min) {
|
|
||||||
origin = plot;
|
|
||||||
min = plot.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Plot plot : MainUtil.getConnectedPlots(this)) {
|
for (Plot plot : MainUtil.getConnectedPlots(this)) {
|
||||||
@ -772,6 +768,7 @@ public class Plot {
|
|||||||
* @param alias
|
* @param alias
|
||||||
*/
|
*/
|
||||||
public void setAlias(String alias) {
|
public void setAlias(String alias) {
|
||||||
|
for (Plot current : getConnectedPlots()) {
|
||||||
final String name = getSettings().getAlias();
|
final String name = getSettings().getAlias();
|
||||||
if (alias == null) {
|
if (alias == null) {
|
||||||
alias = "";
|
alias = "";
|
||||||
@ -779,8 +776,9 @@ public class Plot {
|
|||||||
if (name.equals(alias)) {
|
if (name.equals(alias)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getSettings().setAlias(alias);
|
current.getSettings().setAlias(alias);
|
||||||
DBFunc.setAlias(this, alias);
|
DBFunc.setAlias(current, alias);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1120,6 +1118,9 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getAlias() {
|
public String getAlias() {
|
||||||
|
if (settings == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return getSettings().getAlias();
|
return getSettings().getAlias();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1134,8 +1135,11 @@ public class Plot {
|
|||||||
DBFunc.setMerged(this, merged);
|
DBFunc.setMerged(this, merged);
|
||||||
MainUtil.connected_cache = null;
|
MainUtil.connected_cache = null;
|
||||||
MainUtil.regions_cache = null;
|
MainUtil.regions_cache = null;
|
||||||
|
if (origin != null) {
|
||||||
|
origin.origin = null;
|
||||||
origin = null;
|
origin = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the raw merge data<br>
|
* Set the raw merge data<br>
|
||||||
@ -1145,11 +1149,26 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public void setMerged(int direction, boolean value) {
|
public void setMerged(int direction, boolean value) {
|
||||||
if (getSettings().setMerged(direction, value)) {
|
if (getSettings().setMerged(direction, value)) {
|
||||||
DBFunc.setMerged(this, getSettings().getMerged());
|
if (value) {
|
||||||
|
Plot other = MainUtil.getPlotRelative(this, direction).getBasePlot(false);
|
||||||
|
if (!other.equals(getBasePlot(false))) {
|
||||||
|
Plot base = ((other.id.y < id.y) || ((other.id.y == id.y) && (other.id.x < id.x))) ? other : origin;
|
||||||
|
origin.origin = base;
|
||||||
|
other.origin = base;
|
||||||
|
origin = base;
|
||||||
MainUtil.connected_cache = null;
|
MainUtil.connected_cache = null;
|
||||||
MainUtil.regions_cache = null;
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (origin != null) {
|
||||||
|
origin.origin = null;
|
||||||
origin = null;
|
origin = null;
|
||||||
}
|
}
|
||||||
|
MainUtil.connected_cache = null;
|
||||||
|
}
|
||||||
|
DBFunc.setMerged(this, getSettings().getMerged());
|
||||||
|
MainUtil.regions_cache = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean[] getMerged() {
|
public boolean[] getMerged() {
|
||||||
|
@ -111,7 +111,10 @@ public class PlotSettings {
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(final BlockLoc position) {
|
public void setPosition(BlockLoc position) {
|
||||||
|
if (position != null && position.x == 0 && position.y == 0 && position.z == 0) {
|
||||||
|
position = null;
|
||||||
|
}
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
for (final Plot p : PS.get().getPlotsInWorld(worldname)) {
|
for (final Plot p : PS.get().getPlotsInWorld(worldname)) {
|
||||||
final String name = p.getAlias();
|
final String name = p.getAlias();
|
||||||
if ((name.length() != 0) && name.equalsIgnoreCase(arg)) {
|
if ((name.length() != 0) && StringMan.isEqualIgnoreCase(name, arg)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -631,22 +631,24 @@ public class MainUtil {
|
|||||||
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||||
final int x;
|
final int x;
|
||||||
final int z;
|
final int z;
|
||||||
Location bot = plot.getBottomAbs();
|
|
||||||
if ((plotworld.DEFAULT_HOME.x == Integer.MAX_VALUE) && (plotworld.DEFAULT_HOME.z == Integer.MAX_VALUE)) {
|
if ((plotworld.DEFAULT_HOME.x == Integer.MAX_VALUE) && (plotworld.DEFAULT_HOME.z == Integer.MAX_VALUE)) {
|
||||||
Location top = plot.getTopAbs();
|
// center
|
||||||
x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
RegionWrapper largest = getLargestRegion(plot);
|
||||||
z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ();
|
x = ((largest.maxX - largest.minX) / 2) + largest.minX;
|
||||||
|
z = ((largest.maxZ - largest.minZ) / 2) + largest.minZ;
|
||||||
} else {
|
} else {
|
||||||
|
// specific
|
||||||
|
Location bot = plot.getBottomAbs();
|
||||||
x = bot.getX() + plotworld.DEFAULT_HOME.x;
|
x = bot.getX() + plotworld.DEFAULT_HOME.x;
|
||||||
z = bot.getZ() + plotworld.DEFAULT_HOME.z;
|
z = bot.getZ() + plotworld.DEFAULT_HOME.z;
|
||||||
}
|
}
|
||||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PS.get().getPlotWorld(plot.world), plot).getY());
|
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PS.get().getPlotWorld(plot.world), plot).getY());
|
||||||
return new Location(plot.world, x, y + 1, z);
|
return new Location(plot.world, x, y + 1, z);
|
||||||
}
|
}
|
||||||
Location bot = plot.getBottomAbs();
|
// Side
|
||||||
Location top = plot.getTopAbs();
|
RegionWrapper largest = getLargestRegion(plot);
|
||||||
final int x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
final int x = ((largest.maxX - largest.minX) / 2) + largest.minX;
|
||||||
final int z = bot.getZ() - 1;
|
final int z = largest.minZ - 1;
|
||||||
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PS.get().getPlotWorld(plot.world), plot).getY());
|
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PS.get().getPlotWorld(plot.world), plot).getY());
|
||||||
return new Location(plot.world, x, y + 1, z);
|
return new Location(plot.world, x, y + 1, z);
|
||||||
@ -770,6 +772,18 @@ public class MainUtil {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* direction 0 = north, 1 = south, etc:
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param direction
|
||||||
|
*
|
||||||
|
* @return Plot relative
|
||||||
|
*/
|
||||||
|
public static Plot getPlotRelative(final Plot plot, final int direction) {
|
||||||
|
return getPlotAbs(plot.world, getPlotIdRelative(plot.id, direction));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of plot ids within a selection
|
* Get a list of plot ids within a selection
|
||||||
* @param pos1
|
* @param pos1
|
||||||
@ -1019,13 +1033,18 @@ public class MainUtil {
|
|||||||
a.setFlags(net);
|
a.setFlags(net);
|
||||||
b.setFlags(net);
|
b.setFlags(net);
|
||||||
}
|
}
|
||||||
|
if (a.getAlias().length() > 0) {
|
||||||
|
b.setAlias(a.getAlias());
|
||||||
|
}
|
||||||
|
else if (b.getAlias().length() > 0) {
|
||||||
|
a.setAlias(b.getAlias());
|
||||||
|
}
|
||||||
for (UUID uuid : a.getTrusted()) {
|
for (UUID uuid : a.getTrusted()) {
|
||||||
b.addTrusted(uuid);
|
b.addTrusted(uuid);
|
||||||
}
|
}
|
||||||
for (UUID uuid : b.getTrusted()) {
|
for (UUID uuid : b.getTrusted()) {
|
||||||
a.addTrusted(uuid);
|
a.addTrusted(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (UUID uuid : a.getMembers()) {
|
for (UUID uuid : a.getMembers()) {
|
||||||
b.addMember(uuid);
|
b.addMember(uuid);
|
||||||
}
|
}
|
||||||
@ -1174,62 +1193,58 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
HashSet<Plot> visited = new HashSet<>();
|
HashSet<Plot> visited = new HashSet<>();
|
||||||
HashSet<PlotId> merged = new HashSet<>();
|
HashSet<PlotId> merged = new HashSet<>();
|
||||||
|
for (Plot current : getConnectedPlots(plot)) {
|
||||||
|
merged.add(current.id);
|
||||||
|
}
|
||||||
ArrayDeque<Plot> frontier = new ArrayDeque<>(getConnectedPlots(plot));
|
ArrayDeque<Plot> frontier = new ArrayDeque<>(getConnectedPlots(plot));
|
||||||
Plot current;
|
Plot current;
|
||||||
boolean toReturn = false;
|
boolean toReturn = false;
|
||||||
while ((current = frontier.poll()) != null && max > 0) {
|
Set<Plot> plots;
|
||||||
|
while ((current = frontier.poll()) != null && max >= 0) {
|
||||||
if (visited.contains(current)) {
|
if (visited.contains(current)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
visited.add(current);
|
visited.add(current);
|
||||||
if (max > 0 && (dir == -1 || dir == 0) && !current.getMerged(0)) {
|
if (max >= 0 && (dir == -1 || dir == 0) && !current.getMerged(0)) {
|
||||||
Plot other = getPlotAbs(current.world, getPlotIdRelative(current.id, 0));
|
Plot other = getPlotRelative(current, 0);
|
||||||
if (other.isOwner(uuid)) {
|
if (other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || ((plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1))) {
|
||||||
frontier.addAll(other.getConnectedPlots());
|
|
||||||
mergePlot(current.world, current, other, removeRoads);
|
mergePlot(current.world, current, other, removeRoads);
|
||||||
merged.add(current.id);
|
merged.add(current.id);
|
||||||
merged.add(other.id);
|
merged.add(other.id);
|
||||||
toReturn = true;
|
toReturn = true;
|
||||||
max--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max > 0 && (dir == -1 || dir == 1) && !current.getMerged(1)) {
|
if (max >= 0 && (dir == -1 || dir == 1) && !current.getMerged(1)) {
|
||||||
Plot other = getPlotAbs(current.world, getPlotIdRelative(current.id, 1));
|
Plot other = getPlotRelative(current, 1);
|
||||||
if (other.isOwner(uuid)) {
|
if (other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || ((plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1))) {
|
||||||
frontier.addAll(other.getConnectedPlots());
|
|
||||||
mergePlot(current.world, current, other, removeRoads);
|
mergePlot(current.world, current, other, removeRoads);
|
||||||
merged.add(current.id);
|
merged.add(current.id);
|
||||||
merged.add(other.id);
|
merged.add(other.id);
|
||||||
toReturn = true;
|
toReturn = true;
|
||||||
max--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max > 0 && (dir == -1 || dir == 2) && !current.getMerged(2)) {
|
if (max >= 0 && (dir == -1 || dir == 2) && !current.getMerged(2)) {
|
||||||
Plot other = getPlotAbs(current.world, getPlotIdRelative(current.id, 2));
|
Plot other = getPlotRelative(current, 2);
|
||||||
if (other.isOwner(uuid)) {
|
if (other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || ((plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1))) {
|
||||||
frontier.addAll(other.getConnectedPlots());
|
|
||||||
mergePlot(current.world, current, other, removeRoads);
|
mergePlot(current.world, current, other, removeRoads);
|
||||||
merged.add(current.id);
|
merged.add(current.id);
|
||||||
merged.add(other.id);
|
merged.add(other.id);
|
||||||
toReturn = true;
|
toReturn = true;
|
||||||
max--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max > 0 && (dir == -1 || dir == 3) && !current.getMerged(3)) {
|
if (max >= 0 && (dir == -1 || dir == 3) && !current.getMerged(3)) {
|
||||||
Plot other = getPlotAbs(current.world, getPlotIdRelative(current.id, 3));
|
Plot other = getPlotRelative(current, 3);
|
||||||
if (other.isOwner(uuid)) {
|
if (other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || ((plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1))) {
|
||||||
frontier.addAll(other.getConnectedPlots());
|
|
||||||
mergePlot(current.world, current, other, removeRoads);
|
mergePlot(current.world, current, other, removeRoads);
|
||||||
merged.add(current.id);
|
merged.add(current.id);
|
||||||
merged.add(other.id);
|
merged.add(other.id);
|
||||||
toReturn = true;
|
toReturn = true;
|
||||||
max--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (removeRoads && toReturn) {
|
||||||
PlotManager manager = PS.get().getPlotManager(plot.world);
|
PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||||
ArrayList<PlotId> ids = new ArrayList<>(merged);
|
ArrayList<PlotId> ids = new ArrayList<>(merged);
|
||||||
if (removeRoads) {
|
|
||||||
manager.finishPlotMerge(plot.getWorld(), ids);
|
manager.finishPlotMerge(plot.getWorld(), ids);
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
@ -1548,7 +1563,7 @@ public class MainUtil {
|
|||||||
* @return Home Location
|
* @return Home Location
|
||||||
*/
|
*/
|
||||||
public static Location getPlotHome(final String w, final PlotId plotid) {
|
public static Location getPlotHome(final String w, final PlotId plotid) {
|
||||||
final Plot plot = getPlotAbs(w, plotid).getBasePlot(false);
|
final Plot plot = getPlot(w, plotid);
|
||||||
final BlockLoc home = plot.getPosition();
|
final BlockLoc home = plot.getPosition();
|
||||||
PS.get().getPlotManager(w);
|
PS.get().getPlotManager(w);
|
||||||
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
|
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
|
||||||
@ -2153,7 +2168,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
Plot current;
|
Plot current;
|
||||||
while ((current = frontier.poll()) != null) {
|
while ((current = frontier.poll()) != null) {
|
||||||
if (current.settings == null) {
|
if (current.owner == null || current.settings == null) {
|
||||||
// Invalid plot
|
// Invalid plot
|
||||||
// merged onto unclaimed plot
|
// merged onto unclaimed plot
|
||||||
PS.debug("Ignoring invalid merged plot: " + current + " | " + current.owner);
|
PS.debug("Ignoring invalid merged plot: " + current + " | " + current.owner);
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user