Clean up PlotId

This commit is contained in:
Alexander Söderberg 2020-07-18 11:05:16 +02:00
parent d077fafd29
commit e80ade65c7
33 changed files with 378 additions and 392 deletions

View File

@ -832,7 +832,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
BukkitUtil.adapt(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
PlotId currentPlotId = area.getPlotAbs(pLoc).getId();
if (!originalPlotId.equals(currentPlotId) && (
currentPlotId == null || !area
.getPlot(originalPlotId)
@ -851,7 +851,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
BukkitUtil.adapt(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
PlotId currentPlotId = area.getPlotAbs(pLoc).getId();
if (currentPlotId != null) {
entity.setMetadata("shulkerPlot",
new FixedMetadataValue(

View File

@ -152,16 +152,16 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
this.stack = item.getItemStack();
return;
case "ITEM_FRAME":
this.x = Math.floor(this.x);
this.y = Math.floor(this.y);
this.x = Math.floor(this.getX());
this.y = Math.floor(this.getY());
this.z = Math.floor(this.z);
ItemFrame itemFrame = (ItemFrame) entity;
this.dataByte = getOrdinal(Rotation.values(), itemFrame.getRotation());
this.stack = itemFrame.getItem().clone();
return;
case "PAINTING":
this.x = Math.floor(this.x);
this.y = Math.floor(this.y);
this.x = Math.floor(this.getX());
this.y = Math.floor(this.getY());
this.z = Math.floor(this.z);
Painting painting = (Painting) entity;
Art art = painting.getArt();
@ -407,8 +407,8 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
this.lived.leashed = lived.isLeashed();
if (this.lived.leashed) {
Location location = lived.getLeashHolder().getLocation();
this.lived.leashX = (short) (this.x - location.getBlockX());
this.lived.leashY = (short) (this.y - location.getBlockY());
this.lived.leashX = (short) (this.getX() - location.getBlockX());
this.lived.leashY = (short) (this.getY() - location.getBlockY());
this.lived.leashZ = (short) (this.z - location.getBlockZ());
}
EntityEquipment equipment = lived.getEquipment();
@ -460,7 +460,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
}
@Override public Entity spawn(World world, int xOffset, int zOffset) {
Location location = new Location(world, this.x + xOffset, this.y, this.z + zOffset);
Location location = new Location(world, this.getX() + xOffset, this.getY(), this.z + zOffset);
location.setYaw(this.yaw);
location.setPitch(this.pitch);
if (!this.getType().isSpawnable()) {

View File

@ -67,8 +67,8 @@ public class TeleportEntityWrapper extends EntityWrapper {
// To account for offsets in the chunk manager
this.oldLocation = oldLocation.clone();
this.oldLocation.setX(this.x);
this.oldLocation.setY(this.y);
this.oldLocation.setX(this.getX());
this.oldLocation.setY(this.getY());
this.oldLocation.setZ(this.z);
this.gravityOld = this.getEntity().hasGravity();

View File

@ -1005,7 +1005,7 @@ import java.util.regex.Pattern;
}
}
String partial = ChatColor.translateAlternateColorCodes('&',
format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender));
format.replace("%plot_id%", id.getX() + ";" + id.getY()).replace("%sender%", sender));
if (plotPlayer.hasPermission("plots.chat.color")) {
message = Captions.color(message);
}
@ -1015,7 +1015,7 @@ import java.util.regex.Pattern;
}
if (!spies.isEmpty()) {
String spyMessage = Captions.PLOT_CHAT_SPY_FORMAT.getTranslated()
.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender)
.replace("%plot_id%", id.getX() + ";" + id.getY()).replace("%sender%", sender)
.replace("%msg%", message);
for (Player player : spies) {
player.sendMessage(spyMessage);

View File

@ -503,7 +503,7 @@ public class PlotSquared {
} else {
extra.add(plot);
}
} else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) {
} else if (Math.abs(plot.getId().getX()) > 15446 || Math.abs(plot.getId().getY()) > 15446) {
extra.add(plot);
} else {
overflow.add(plot);
@ -578,7 +578,7 @@ public class PlotSquared {
} else {
extra.add(plot);
}
} else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) {
} else if (Math.abs(plot.getId().getX()) > 15446 || Math.abs(plot.getId().getY()) > 15446) {
extra.add(plot);
} else {
overflow.add(plot);
@ -718,8 +718,8 @@ public class PlotSquared {
}
if (plot.getArea().removePlot(plot.getId())) {
PlotId last = (PlotId) plot.getArea().getMeta("lastPlot");
int last_max = Math.max(Math.abs(last.x), Math.abs(last.y));
int this_max = Math.max(Math.abs(plot.getId().x), Math.abs(plot.getId().y));
int last_max = Math.max(Math.abs(last.getX()), Math.abs(last.getY()));
int this_max = Math.max(Math.abs(plot.getId().getX()), Math.abs(plot.getId().getY()));
if (this_max < last_max) {
plot.getArea().setMeta("lastPlot", plot.getId());
}

View File

@ -169,7 +169,7 @@ public class Area extends SubCommand {
BlockVector3.at(playerSelectionMin.getX(), 0, playerSelectionMin.getZ()),
BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ()));
// There's only one plot in the area...
final PlotId plotId = new PlotId(1, 1);
final PlotId plotId = PlotId.of(1, 1);
final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory.create(player.getLocation().getWorldName(), args[1],
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId);
// Plot size is the same as the region width
@ -315,8 +315,8 @@ public class Area extends SubCommand {
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area)
.plotManager(PlotSquared.platform().getPluginName())
.generatorName(PlotSquared.platform().getPluginName())
.minimumId(new PlotId(1, 1))
.maximumId(new PlotId(numX, numZ));
.minimumId(PlotId.of(1, 1))
.maximumId(PlotId.of(numX, numZ));
final String path =
"worlds." + area.getWorldName() + ".areas." + area.getId() + '-'
+ builder.minimumId() + '-' + builder.maximumId();
@ -542,7 +542,7 @@ public class Area extends SubCommand {
PlotId min = area.getMin();
PlotId max = area.getMax();
name = area.getWorldName() + ';' + area.getId() + ';' + min + ';' + max;
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
int size = (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1);
percent = claimed == 0 ? 0 : size / (double) claimed;
region = area.getRegion().toString();
} else {
@ -595,7 +595,7 @@ public class Area extends SubCommand {
PlotId max = area.getMax();
name = area.getWorldName() + ';' + area.getId() + ';' + min + ';'
+ max;
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
int size = (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1);
percent = claimed == 0 ? 0 : size / (double) claimed;
region = area.getRegion().toString();
} else {

View File

@ -64,7 +64,7 @@ public abstract class Argument<T> {
}
};
public static final Argument<PlotId> PlotID =
new Argument<PlotId>("PlotID", new PlotId(-6, 3)) {
new Argument<PlotId>("PlotID", PlotId.of(-6, 3)) {
@Override public PlotId parse(String in) {
return PlotId.fromString(in);
}

View File

@ -76,10 +76,6 @@ public class Auto extends SubCommand {
this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler;
}
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
return id.getNextId(step);
}
public static boolean checkAllowedPlots(PlotPlayer player, PlotArea plotarea,
@Nullable Integer allowedPlots, int sizeX, int sizeZ) {
@ -298,14 +294,14 @@ public class Auto extends SubCommand {
return false;
}
while (true) {
PlotId start = plotarea.getMeta("lastPlot", new PlotId(0, 0)).getNextId(1);
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
PlotId start = plotarea.getMeta("lastPlot", PlotId.of(0, 0)).getNextId();
PlotId end = PlotId.of(start.getX() + size_x - 1, start.getY() + size_z - 1);
if (plotarea.canClaim(player, start, end)) {
plotarea.setMeta("lastPlot", start);
for (int i = start.x; i <= end.x; i++) {
for (int j = start.y; j <= end.y; j++) {
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
boolean teleport = i == end.x && j == end.y;
for (int i = start.getX(); i <= end.getX(); i++) {
for (int j = start.getY(); j <= end.getY(); j++) {
Plot plot = plotarea.getPlotAbs(PlotId.of(i, j));
boolean teleport = i == end.getX() && j == end.getY();
if (plot == null) {
return false;
}

View File

@ -137,9 +137,9 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(player, Captions.ALIAS_IS_TAKEN);
return false;
}
if (pos2.x < pos1.x || pos2.y < pos1.y) {
PlotId tmp = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y));
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) {
PlotId tmp = PlotId.of(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()));
pos2 = PlotId.of(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()));
pos1 = tmp;
}
//check if overlap
@ -265,9 +265,9 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
return false;
}
if (pos2.x < pos1.x || pos2.y < pos1.y) {
pos1 = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y));
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) {
pos1 = PlotId.of(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()));
pos2 = PlotId.of(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()));
}
// check if in cluster
PlotArea area = player.getApplicablePlotArea();
@ -326,7 +326,7 @@ public class Cluster extends SubCommand {
} else {
current = player.getPlayerClusterCount(player.getLocation().getWorldName());
}
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
current -= cluster.getArea() + (1 + pos2.getX() - pos1.getX()) * (1 + pos2.getY() - pos1.getY());
int allowed = Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER,
Settings.Limit.MAX_PLOTS);
if (current + cluster.getArea() > allowed) {
@ -648,8 +648,8 @@ public class Cluster extends SubCommand {
owner = username;
}
String name = cluster.getName();
String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (
cluster.getP2().y - cluster.getP1().y + 1);
String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + (
cluster.getP2().getY() - cluster.getP1().getY() + 1);
String rights = cluster.isAdded(player.getUUID()) + "";
String message = Captions.CLUSTER_INFO.getTranslated();
message = message.replaceAll("%id%", id);

View File

@ -138,13 +138,13 @@ public class Condense extends SubCommand {
}
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
final List<PlotId> free = new ArrayList<>();
PlotId start = new PlotId(0, 0);
while (start.x <= minimumRadius && start.y <= minimumRadius) {
PlotId start = PlotId.of(0, 0);
while (start.getX() <= minimumRadius && start.getY() <= minimumRadius) {
Plot plot = area.getPlotAbs(start);
if (plot != null && !plot.hasOwner()) {
free.add(plot.getId());
}
start = Auto.getNextPlotId(start, 1);
start = start.getNextId();
}
if (free.isEmpty() || toMove.isEmpty()) {
MainUtil.sendMessage(player, "NO FREE PLOTS FOUND");
@ -249,8 +249,8 @@ public class Condense extends SubCommand {
public Set<PlotId> getPlots(Collection<Plot> plots, int radius) {
HashSet<PlotId> outside = new HashSet<>();
for (Plot plot : plots) {
if (plot.getId().x > radius || plot.getId().x < -radius || plot.getId().y > radius
|| plot.getId().y < -radius) {
if (plot.getId().getX() > radius || plot.getId().getX() < -radius || plot.getId().getY() > radius
|| plot.getId().getY() < -radius) {
outside.add(plot.getId());
}
}

View File

@ -158,9 +158,7 @@ public class DatabaseCommand extends SubCommand {
newId.toCommaSeparatedString());
worldFile.renameTo(newFile);
}
id.x = newId.x;
id.y = newId.y;
id.recalculateHash();
plot.setId(newId.copy());
plot.setArea(pa);
plots.add(plot);
continue;

View File

@ -70,7 +70,7 @@ public class DebugImportWorlds extends Command {
return CompletableFuture.completedFuture(false);
}
SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
PlotId id = new PlotId(0, 0);
PlotId id = PlotId.of(0, 0);
File container = PlotSquared.platform().getWorldContainer();
if (container.equals(new File("."))) {
player.sendMessage(
@ -92,7 +92,7 @@ public class DebugImportWorlds extends Command {
UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
}
while (new File(container, id.toCommaSeparatedString()).exists()) {
id = Auto.getNextPlotId(id, 1);
id = id.getNextId();
}
File newDir = new File(container, id.toCommaSeparatedString());
if (folder.renameTo(newDir)) {

View File

@ -118,7 +118,7 @@ public class Info extends SubCommand {
// Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) {
MainUtil.sendMessage(player, Captions.PLOT_INFO_UNCLAIMED,
plot.getId().x + ";" + plot.getId().y);
plot.getId().getX() + ";" + plot.getId().getY());
return true;
}
String info = Captions.PLOT_INFO_FORMAT.getTranslated();

View File

@ -94,7 +94,7 @@ public class Save extends SubCommand {
PlotId id = plot.getId();
String world1 = plot.getArea().toString().replaceAll(";", "-")
.replaceAll("[^A-Za-z0-9]", "");
final String file = time + '_' + world1 + '_' + id.x + '_' + id.y + '_' + size;
final String file = time + '_' + world1 + '_' + id.getX() + '_' + id.getY() + '_' + size;
UUID uuid = player.getUUID();
schematicHandler.upload(value, uuid, file, new RunnableVal<URL>() {
@Override public void run(URL url) {

View File

@ -573,8 +573,8 @@ public class SQLManager implements AbstractDB {
addPlotTask(plot, new UniqueStatement("setOwner") {
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setString(1, uuid.toString());
statement.setInt(2, plot.getId().x);
statement.setInt(3, plot.getId().y);
statement.setInt(2, plot.getId().getX());
statement.setInt(3, plot.getId().getY());
statement.setString(4, plot.getArea().toString());
}
@ -610,7 +610,7 @@ public class SQLManager implements AbstractDB {
int id = result.getInt("id");
int x = result.getInt("plot_id_x");
int y = result.getInt("plot_id_z");
PlotId plotId = new PlotId(x, y);
PlotId plotId = PlotId.of(x, y);
Plot plot = plotMap.get(plotId);
idMap.put(plotId, id);
if (plot != null) {
@ -759,8 +759,8 @@ public class SQLManager implements AbstractDB {
@Override public void setMySQL(PreparedStatement stmt, int i, Plot plot)
throws SQLException {
stmt.setInt(i * 5 + 1, plot.getId().x);
stmt.setInt(i * 5 + 2, plot.getId().y);
stmt.setInt(i * 5 + 1, plot.getId().getX());
stmt.setInt(i * 5 + 2, plot.getId().getY());
try {
stmt.setString(i * 5 + 3, plot.getOwnerAbs().toString());
} catch (SQLException ignored) {
@ -773,8 +773,8 @@ public class SQLManager implements AbstractDB {
@Override public void setSQLite(PreparedStatement stmt, int i, Plot plot)
throws SQLException {
stmt.setNull(i * 6 + 1, 4);
stmt.setInt(i * 6 + 2, plot.getId().x);
stmt.setInt(i * 6 + 3, plot.getId().y);
stmt.setInt(i * 6 + 2, plot.getId().getX());
stmt.setInt(i * 6 + 3, plot.getId().getY());
try {
stmt.setString(i * 6 + 4, plot.getOwnerAbs().toString());
} catch (SQLException ignored) {
@ -785,8 +785,8 @@ public class SQLManager implements AbstractDB {
}
@Override public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException {
stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.getId().y);
stmt.setInt(1, plot.getId().getX());
stmt.setInt(2, plot.getId().getY());
stmt.setString(3, plot.getOwnerAbs().toString());
stmt.setString(4, plot.getArea().toString());
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
@ -1016,14 +1016,14 @@ public class SQLManager implements AbstractDB {
public void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure) {
addPlotTask(plot, new UniqueStatement("createPlotSafe_" + plot.hashCode()) {
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, plot.getId().x);
statement.setInt(2, plot.getId().y);
statement.setInt(1, plot.getId().getX());
statement.setInt(2, plot.getId().getY());
statement.setString(3, plot.getOwnerAbs().toString());
statement.setString(4, plot.getArea().toString());
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
statement.setString(6, plot.getArea().toString());
statement.setInt(7, plot.getId().x);
statement.setInt(8, plot.getId().y);
statement.setInt(7, plot.getId().getX());
statement.setInt(8, plot.getId().getY());
}
@Override public PreparedStatement get() throws SQLException {
@ -1085,8 +1085,8 @@ public class SQLManager implements AbstractDB {
@Override public void createPlotAndSettings(final Plot plot, Runnable whenDone) {
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, plot.getId().x);
statement.setInt(2, plot.getId().y);
statement.setInt(1, plot.getId().getX());
statement.setInt(2, plot.getId().getY());
statement.setString(3, plot.getOwnerAbs().toString());
statement.setString(4, plot.getArea().toString());
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
@ -1436,10 +1436,10 @@ public class SQLManager implements AbstractDB {
try (PreparedStatement stmt = this.connection.prepareStatement(
"SELECT `id` FROM `" + this.prefix
+ "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC")) {
stmt.setInt(1, cluster.getP1().x);
stmt.setInt(2, cluster.getP1().y);
stmt.setInt(3, cluster.getP2().x);
stmt.setInt(4, cluster.getP2().y);
stmt.setInt(1, cluster.getP1().getX());
stmt.setInt(2, cluster.getP1().getY());
stmt.setInt(3, cluster.getP2().getX());
stmt.setInt(4, cluster.getP2().getY());
stmt.setString(5, cluster.area.toString());
try (ResultSet resultSet = stmt.executeQuery()) {
c_id = Integer.MAX_VALUE;
@ -1475,8 +1475,8 @@ public class SQLManager implements AbstractDB {
try (PreparedStatement statement = this.connection.prepareStatement(
"SELECT `id` FROM `" + this.prefix
+ "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC")) {
statement.setInt(1, plot.getId().x);
statement.setInt(2, plot.getId().y);
statement.setInt(1, plot.getId().getX());
statement.setInt(2, plot.getId().getY());
statement.setString(3, plot.getArea().toString());
try (ResultSet resultSet = statement.executeQuery()) {
id = Integer.MAX_VALUE;
@ -1745,7 +1745,7 @@ public class SQLManager implements AbstractDB {
+ this.prefix + "plot`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (resultSet.next()) {
PlotId plot_id = new PlotId(resultSet.getInt("plot_id_x"),
PlotId plot_id = PlotId.of(resultSet.getInt("plot_id_x"),
resultSet.getInt("plot_id_z"));
id = resultSet.getInt("id");
String areaID = resultSet.getString("world");
@ -2094,8 +2094,8 @@ public class SQLManager implements AbstractDB {
@Override public void movePlot(final Plot original, final Plot newPlot) {
addPlotTask(original, new UniqueStatement("movePlot") {
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, newPlot.getId().x);
statement.setInt(2, newPlot.getId().y);
statement.setInt(1, newPlot.getId().getX());
statement.setInt(2, newPlot.getId().getY());
statement.setString(3, newPlot.getArea().toString());
statement.setInt(4, getId(original));
}
@ -2245,7 +2245,7 @@ public class SQLManager implements AbstractDB {
try (ResultSet r = stmt.executeQuery()) {
ids = new HashSet<>();
while (r.next()) {
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
PlotId plot_id = PlotId.of(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
if (plots.contains(plot_id)) {
ids.add(r.getInt("id"));
}
@ -2259,7 +2259,7 @@ public class SQLManager implements AbstractDB {
for (Iterator<PlotId> iterator = plots.iterator(); iterator.hasNext(); ) {
PlotId plotId = iterator.next();
iterator.remove();
PlotId id = new PlotId(plotId.x, plotId.y);
PlotId id = PlotId.of(plotId.getX(), plotId.getY());
area.removePlot(id);
}
});
@ -2695,9 +2695,9 @@ public class SQLManager implements AbstractDB {
int id;
while (resultSet.next()) {
PlotId pos1 =
new PlotId(resultSet.getInt("pos1_x"), resultSet.getInt("pos1_z"));
PlotId.of(resultSet.getInt("pos1_x"), resultSet.getInt("pos1_z"));
PlotId pos2 =
new PlotId(resultSet.getInt("pos2_x"), resultSet.getInt("pos2_z"));
PlotId.of(resultSet.getInt("pos2_x"), resultSet.getInt("pos2_z"));
id = resultSet.getInt("id");
String areaid = resultSet.getString("world");
if (!areas.contains(areaid)) {
@ -2854,10 +2854,10 @@ public class SQLManager implements AbstractDB {
@Override public void createCluster(final PlotCluster cluster) {
addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, cluster.getP1().x);
statement.setInt(2, cluster.getP1().y);
statement.setInt(3, cluster.getP2().x);
statement.setInt(4, cluster.getP2().y);
statement.setInt(1, cluster.getP1().getX());
statement.setInt(2, cluster.getP1().getY());
statement.setInt(3, cluster.getP2().getX());
statement.setInt(4, cluster.getP2().getY());
statement.setString(5, cluster.owner.toString());
statement.setString(6, cluster.area.toString());
}
@ -2895,17 +2895,17 @@ public class SQLManager implements AbstractDB {
}
@Override public void resizeCluster(final PlotCluster current, PlotId min, PlotId max) {
final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y);
final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y);
final PlotId pos1 = PlotId.of(current.getP1().getX(), current.getP1().getY());
final PlotId pos2 = PlotId.of(current.getP2().getX(), current.getP2().getY());
current.setP1(min);
current.setP2(max);
addClusterTask(current, new UniqueStatement("resizeCluster") {
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, pos1.x);
statement.setInt(2, pos1.y);
statement.setInt(3, pos2.x);
statement.setInt(4, pos2.y);
statement.setInt(1, pos1.getX());
statement.setInt(2, pos1.getY());
statement.setInt(3, pos2.getX());
statement.setInt(4, pos2.getY());
statement.setInt(5, getClusterId(current));
}
@ -3141,10 +3141,10 @@ public class SQLManager implements AbstractDB {
+ "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) {
stmt.setString(1, newWorld);
stmt.setString(2, oldWorld);
stmt.setInt(3, min.x);
stmt.setInt(4, max.x);
stmt.setInt(5, min.y);
stmt.setInt(6, max.y);
stmt.setInt(3, min.getX());
stmt.setInt(4, max.getX());
stmt.setInt(5, min.getY());
stmt.setInt(6, max.getY());
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
@ -3154,10 +3154,10 @@ public class SQLManager implements AbstractDB {
+ "cluster` SET `world` = ? WHERE `world` = ? AND `pos1_x` <= ? AND `pos1_z` <= ? AND `pos2_x` >= ? AND `pos2_z` >= ?")) {
stmt.setString(1, newWorld);
stmt.setString(2, oldWorld);
stmt.setInt(3, max.x);
stmt.setInt(4, max.y);
stmt.setInt(5, min.x);
stmt.setInt(6, min.y);
stmt.setInt(3, max.getX());
stmt.setInt(4, max.getY());
stmt.setInt(5, min.getX());
stmt.setInt(6, min.getY());
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();

View File

@ -103,7 +103,7 @@ public class HybridPlotManager extends ClassicPlotManager {
@Override public boolean createRoadEast(Plot plot) {
super.createRoadEast(plot);
PlotId id = plot.getId();
PlotId id2 = new PlotId(id.x + 1, id.y);
PlotId id2 = PlotId.of(id.getX() + 1, id.getY());
Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id);
Location pos1 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
@ -164,7 +164,7 @@ public class HybridPlotManager extends ClassicPlotManager {
@Override public boolean createRoadSouth(Plot plot) {
super.createRoadSouth(plot);
PlotId id = plot.getId();
PlotId id2 = new PlotId(id.x, id.y + 1);
PlotId id2 = PlotId.of(id.getX(), id.getY() + 1);
Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id);
Location pos1 = Location.at(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
@ -183,7 +183,7 @@ public class HybridPlotManager extends ClassicPlotManager {
@Override public boolean createRoadSouthEast(Plot plot) {
super.createRoadSouthEast(plot);
PlotId id = plot.getId();
PlotId id2 = new PlotId(id.x + 1, id.y + 1);
PlotId id2 = PlotId.of(id.getX() + 1, id.getY() + 1);
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);

View File

@ -77,8 +77,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
}
@Override public Location getPlotTopLocAbs(PlotId plotId) {
int px = plotId.x;
int pz = plotId.y;
int px = plotId.getX();
int pz = plotId.getY();
int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
@ -126,7 +126,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
if (z <= pathWidthLower || z > end || x <= pathWidthLower || x > end) {
return null;
} else {
return new PlotId(idx, idz);
return PlotId.of(idx, idz);
}
}
@ -151,7 +151,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
} else {
idz = (z / size) + 1;
}
return new PlotId(idx, idz);
return PlotId.of(idx, idz);
}
@Override public PlotId getPlotId(int x, int y, int z) {
@ -190,7 +190,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
dz = (z / size) + 1;
rz = z % size;
}
PlotId id = new PlotId(dx, dz);
PlotId id = PlotId.of(dx, dz);
boolean[] merged =
new boolean[] {rz <= pathWidthLower, rx > end, rz > end, rx <= pathWidthLower};
int hash = MainUtil.hash(merged);
@ -240,8 +240,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
* Get the bottom plot loc (some basic math).
*/
@Override public Location getPlotBottomLocAbs(PlotId plotId) {
int px = plotId.x;
int pz = plotId.y;
int px = plotId.getX();
int pz = plotId.getY();
int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math
.floor(squarePlotWorld.ROAD_WIDTH / 2);

View File

@ -266,8 +266,8 @@ public class PlotListener {
Plot lastPlot = player.getMeta(PlotPlayer.META_LAST_PLOT);
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
Map<String, String> replacements = new HashMap<>();
replacements.put("%x%", String.valueOf(lastPlot.getId().x));
replacements.put("%z%", lastPlot.getId().y + "");
replacements.put("%x%", String.valueOf(lastPlot.getId().getX()));
replacements.put("%z%", lastPlot.getId().getY() + "");
replacements.put("%world%", plot.getArea().toString());
replacements.put("%greeting%", greeting);
replacements.put("%alias", plot.toString());

View File

@ -117,4 +117,5 @@ public class BlockLoc {
public float getPitch() {
return pitch;
}
}

View File

@ -25,13 +25,13 @@
*/
package com.plotsquared.core.location;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.khelekore.prtree.MBR;
import org.khelekore.prtree.SimpleMBR;
@ -42,8 +42,7 @@ import javax.annotation.Nullable;
/**
* An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
*/
@EqualsAndHashCode @SuppressWarnings("unused")
public final class Location implements Comparable<Location> {
public final class Location extends BlockLoc implements Comparable<Location> {
@Getter private final float yaw;
@Getter private final float pitch;
@ -52,6 +51,7 @@ public final class Location implements Comparable<Location> {
private Location(@Nonnull final World<?> world, @Nonnull final BlockVector3 blockVector3,
final float yaw, final float pitch) {
super(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), yaw, pitch);
this.world = Preconditions.checkNotNull(world, "World may not be null");
this.blockVector3 = Preconditions.checkNotNull(blockVector3, "Vector may not be null");
this.yaw = yaw;
@ -60,6 +60,7 @@ public final class Location implements Comparable<Location> {
private Location(@Nonnull final String worldName, @Nonnull final BlockVector3 blockVector3,
final float yaw, final float pitch) {
super(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), yaw, pitch);
Preconditions.checkNotNull(worldName, "World name may not be null");
if (worldName.isEmpty()) {
this.world = World.nullWorld();
@ -446,6 +447,28 @@ public final class Location implements Comparable<Location> {
return 1;
}
@Override public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
final Location location = (Location) o;
return Float.compare(location.getYaw(), getYaw()) == 0
&& Float.compare(location.getPitch(), getPitch()) == 0 && Objects
.equal(getBlockVector3(), location.getBlockVector3()) && Objects
.equal(getWorld(), location.getWorld());
}
@Override public int hashCode() {
return Objects
.hashCode(super.hashCode(), getYaw(), getPitch(), getBlockVector3(), getWorld());
}
@Override public String toString() {
return "\"plotsquaredlocation\":{\"x\":" + this.getX() + ",\"y\":" + this.getY() + ",\"z\":"
+ this.getZ() + ",\"yaw\":" + this.yaw + ",\"pitch\":" + this.pitch + ",\"world\":\""

View File

@ -76,11 +76,11 @@ public final class PlotLoc {
}
public int getX() {
return this.x;
return this.getX();
}
public int getY() {
return this.y;
return this.getY();
}
public int getZ() {
@ -90,14 +90,14 @@ public final class PlotLoc {
@Override public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + this.x;
result = (prime * result) + this.y;
result = (prime * result) + this.getX();
result = (prime * result) + this.getY();
result = (prime * result) + this.z;
return result;
}
@Override public String toString() {
if (this.y == -1) {
if (this.getY() == -1) {
return String.format("%d,%d", x, z);
}
return String.format("%d,%d,%d", x, y, z);
@ -111,6 +111,6 @@ public final class PlotLoc {
return false;
}
final PlotLoc other = (PlotLoc) obj;
return (this.x == other.x) && (this.y == other.y) && (this.z == other.z);
return (this.getX() == other.getX()) && (this.getY() == other.getY()) && (this.z == other.z);
}
}

View File

@ -576,8 +576,8 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
if (plot != null && Settings.Enabled_Components.PERSISTENT_META && plot
.getArea() instanceof SinglePlotArea) {
PlotId id = plot.getId();
int x = id.x;
int z = id.y;
int x = id.getX();
int z = id.getY();
ByteBuffer buffer = ByteBuffer.allocate(13);
buffer.putShort((short) x);
buffer.putShort((short) z);
@ -677,7 +677,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
ByteBuffer quitWorld = ByteBuffer.wrap(arr);
final int plotX = quitWorld.getShort();
final int plotZ = quitWorld.getShort();
PlotId id = new PlotId(plotX, plotZ);
PlotId id = PlotId.of(plotX, plotZ);
int x = quitWorld.getInt();
int y = quitWorld.get() & 0xFF;
int z = quitWorld.getInt();

View File

@ -76,11 +76,11 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockTypes;
import lombok.Getter;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D;
@ -131,7 +131,7 @@ public class Plot {
private static Set<Plot> connected_cache;
private static Set<CuboidRegion> regions_cache;
@Nonnull private final PlotId id;
@Nonnull private PlotId id;
// These will be injected
@Inject private EventDispatcher eventDispatcher;
@ -664,7 +664,7 @@ public class Plot {
this.origin = this;
PlotId min = this.id;
for (Plot plot : this.getConnectedPlots()) {
if (plot.id.y < min.y || plot.id.y == min.y && plot.id.x < min.x) {
if (plot.id.getY() < min.getY() || plot.id.getY() == min.getY() && plot.id.getX() < min.getX()) {
this.origin = plot;
min = plot.id;
}
@ -733,8 +733,10 @@ public class Plot {
int i2 = 0;
if (this.getSettings().getMerged(i2)) {
if (this.getSettings().getMerged(i)) {
if (this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)) {
return this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
if (this.area.getPlotAbs(this.id.getRelative(Direction.getFromIndex(i)))
.getMerged(i2)) {
return this.area.getPlotAbs(this.id.getRelative(Direction.getFromIndex(i2)))
.getMerged(i);
}
}
}
@ -745,8 +747,9 @@ public class Plot {
i = dir - 4;
i2 = dir - 3;
return this.getSettings().getMerged(i2) && this.getSettings().getMerged(i)
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2) && this.area
.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
&& this.area.getPlotAbs(this.id.getRelative(Direction.getFromIndex(i)))
.getMerged(i2) && this.area
.getPlotAbs(this.id.getRelative(Direction.getFromIndex(i2))).getMerged(i);
}
return false;
@ -1910,15 +1913,11 @@ public class Plot {
return CompletableFuture.completedFuture(true);
}
// Swap cached
PlotId temp = new PlotId(this.getId().x, this.getId().y);
this.getId().x = plot.getId().x;
this.getId().y = plot.getId().y;
plot.getId().x = temp.x;
plot.getId().y = temp.y;
final PlotId temp = PlotId.of(this.getId().getX(), this.getId().getY());
this.id = plot.getId().copy();
plot.id = temp.copy();
this.area.removePlot(this.getId());
plot.area.removePlot(plot.getId());
this.getId().recalculateHash();
plot.getId().recalculateHash();
this.area.addPlotAbs(this);
plot.area.addPlotAbs(plot);
// Swap database
@ -1942,9 +1941,7 @@ public class Plot {
return false;
}
this.area.removePlot(this.id);
this.getId().x = plot.getId().x;
this.getId().y = plot.getId().y;
this.getId().recalculateHash();
this.id = plot.getId().copy();
this.area.addPlotAbs(this);
DBFunc.movePlot(this, plot);
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
@ -2078,7 +2075,7 @@ public class Plot {
if (this.settings != null && this.settings.getAlias().length() > 1) {
return this.settings.getAlias();
}
return this.area + ";" + this.id.x + ";" + this.id.y;
return this.area + ";" + this.id.toString();
}
@ -2293,8 +2290,8 @@ public class Plot {
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;
Plot base = other.id.getY() < this.id.getY()
|| other.id.getY() == this.id.getY() && other.id.getX() < this.id.getX() ? other : this.origin;
this.origin.origin = base;
other.origin = base;
this.origin = base;
@ -2583,36 +2580,21 @@ public class Plot {
* @return Plot
*/
public Plot getRelative(int x, int y) {
return this.area.getPlotAbs(this.id.getRelative(x, y));
return this.area.getPlotAbs(PlotId.of(this.id.getX() + x, this.id.getY() + y));
}
public Plot getRelative(PlotArea area, int x, int y) {
return area.getPlotAbs(this.id.getRelative(x, y));
}
/**
* Gets the plot in a relative direction<br>
* 0 = north<br>
* 1 = east<br>
* 2 = south<br>
* 3 = west<br>
* Note: May be null if the partial plot area does not include the relative location
*
* @param direction
* @return
*/
@Deprecated public Plot getRelative(int direction) {
return this.area.getPlotAbs(this.id.getRelative(direction));
return area.getPlotAbs(PlotId.of(this.id.getX() + x, this.id.getY() + y));
}
/**
* Gets the plot in a relative direction
* Note: May be null if the partial plot area does not include the relative location
*
* @param direction
* @param direction Direction
* @return the plot relative to this one
*/
public Plot getRelative(Direction direction) {
@Nullable public Plot getRelative(@Nonnull Direction direction) {
return this.area.getPlotAbs(this.id.getRelative(direction));
}
@ -2768,12 +2750,12 @@ public class Plot {
continue;
}
boolean merge = true;
PlotId bot = new PlotId(current.getId().x, current.getId().y);
PlotId top = new PlotId(current.getId().x, current.getId().y);
PlotId bot = PlotId.of(current.getId().getX(), current.getId().getY());
PlotId top = PlotId.of(current.getId().getX(), current.getId().getY());
while (merge) {
merge = false;
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(new PlotId(bot.x, bot.y - 1),
new PlotId(top.x, bot.y - 1));
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(PlotId.of(bot.getX(), bot.getY() - 1),
PlotId.of(top.getX(), bot.getY() - 1));
boolean tmp = true;
for (PlotId id : ids) {
Plot plot = this.area.getPlotAbs(id);
@ -2784,10 +2766,10 @@ public class Plot {
}
if (tmp) {
merge = true;
bot.y--;
bot = PlotId.of(bot.getX(), bot.getY() - 1);
}
ids = MainUtil.getPlotSelectionIds(new PlotId(top.x + 1, bot.y),
new PlotId(top.x + 1, top.y));
ids = MainUtil.getPlotSelectionIds(PlotId.of(top.getX() + 1, bot.getY()),
PlotId.of(top.getX() + 1, top.getY()));
tmp = true;
for (PlotId id : ids) {
Plot plot = this.area.getPlotAbs(id);
@ -2798,10 +2780,10 @@ public class Plot {
}
if (tmp) {
merge = true;
top.x++;
top = PlotId.of(top.getX() + 1, top.getY());
}
ids = MainUtil.getPlotSelectionIds(new PlotId(bot.x, top.y + 1),
new PlotId(top.x, top.y + 1));
ids = MainUtil.getPlotSelectionIds(PlotId.of(bot.getX(), top.getY() + 1),
PlotId.of(top.getX(), top.getY() + 1));
tmp = true;
for (PlotId id : ids) {
Plot plot = this.area.getPlotAbs(id);
@ -2812,10 +2794,10 @@ public class Plot {
}
if (tmp) {
merge = true;
top.y++;
top = PlotId.of(top.getX(), top.getY() + 1);
}
ids = MainUtil.getPlotSelectionIds(new PlotId(bot.x - 1, bot.y),
new PlotId(bot.x - 1, top.y));
ids = MainUtil.getPlotSelectionIds(PlotId.of(bot.getX() - 1, bot.getY()),
PlotId.of(bot.getX() - 1, top.getY()));
tmp = true;
for (PlotId id : ids) {
Plot plot = this.area.getPlotAbs(id);
@ -2826,14 +2808,14 @@ public class Plot {
}
if (tmp) {
merge = true;
bot.x--;
bot = PlotId.of(bot.getX() - 1, bot.getX());
}
}
Location gtopabs = this.area.getPlotAbs(top).getTopAbs();
Location gbotabs = this.area.getPlotAbs(bot).getBottomAbs();
visited.addAll(MainUtil.getPlotSelectionIds(bot, top));
for (int x = bot.x; x <= top.x; x++) {
Plot plot = this.area.getPlotAbs(new PlotId(x, top.y));
for (int x = bot.getX(); x <= top.getX(); x++) {
Plot plot = this.area.getPlotAbs(PlotId.of(x, top.getY()));
if (plot.getMerged(Direction.SOUTH)) {
// south wedge
Location toploc = plot.getExtendedTopAbs();
@ -2852,8 +2834,8 @@ public class Plot {
}
}
for (int y = bot.y; y <= top.y; y++) {
Plot plot = this.area.getPlotAbs(new PlotId(top.x, y));
for (int y = bot.getY(); y <= top.getY(); y++) {
Plot plot = this.area.getPlotAbs(PlotId.of(top.getX(), y));
if (plot.getMerged(Direction.EAST)) {
// east wedge
Location toploc = plot.getExtendedTopAbs();
@ -3084,8 +3066,8 @@ public class Plot {
public void mergePlot(Plot lesserPlot, boolean removeRoads) {
Plot greaterPlot = this;
lesserPlot.removeSign();
if (lesserPlot.getId().x == greaterPlot.getId().x) {
if (lesserPlot.getId().y > greaterPlot.getId().y) {
if (lesserPlot.getId().getX() == greaterPlot.getId().getX()) {
if (lesserPlot.getId().getY() > greaterPlot.getId().getY()) {
Plot tmp = lesserPlot;
lesserPlot = greaterPlot;
greaterPlot = tmp;
@ -3110,7 +3092,7 @@ public class Plot {
}
}
} else {
if (lesserPlot.getId().x > greaterPlot.getId().x) {
if (lesserPlot.getId().getX() > greaterPlot.getId().getX()) {
Plot tmp = lesserPlot;
lesserPlot = greaterPlot;
greaterPlot = tmp;
@ -3148,8 +3130,8 @@ public class Plot {
*/
public CompletableFuture<Boolean> move(final Plot destination, final Runnable whenDone,
boolean allowSwap) {
final PlotId offset = new PlotId(destination.getId().x - this.getId().x,
destination.getId().y - this.getId().y);
final PlotId offset = PlotId.of(destination.getId().getX() - this.getId().getX(),
destination.getId().getY() - this.getId().getY());
Location db = destination.getBottomAbs();
Location ob = this.getBottomAbs();
final int offsetX = db.getX() - ob.getX();
@ -3161,7 +3143,7 @@ public class Plot {
AtomicBoolean occupied = new AtomicBoolean(false);
Set<Plot> plots = this.getConnectedPlots();
for (Plot plot : plots) {
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
Plot other = plot.getRelative(destination.getArea(), offset.getX(), offset.getY());
if (other.hasOwner()) {
if (!allowSwap) {
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
@ -3184,7 +3166,7 @@ public class Plot {
if (plotIterator.hasNext()) {
while (plotIterator.hasNext()) {
final Plot plot = plotIterator.next();
final Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
final Plot other = plot.getRelative(destination.getArea(), offset.getX(), offset.getY());
final CompletableFuture<Boolean> swapResult = plot.swapData(other);
if (future == null) {
future = swapResult;
@ -3227,7 +3209,7 @@ public class Plot {
if (regions.isEmpty()) {
Plot plot = destination.getRelative(0, 0);
Plot originPlot = originArea
.getPlotAbs(new PlotId(plot.id.x - offset.x, plot.id.y - offset.y));
.getPlotAbs(PlotId.of(plot.id.getX() - offset.getX(), plot.id.getY() - offset.getY()));
final Runnable clearDone = () -> {
for (final Plot current : plot.getConnectedPlots()) {
getManager().claimPlot(current);
@ -3264,8 +3246,8 @@ public class Plot {
* @return
*/
public boolean copy(final Plot destination, final Runnable whenDone) {
PlotId offset = new PlotId(destination.getId().x - this.getId().x,
destination.getId().y - this.getId().y);
PlotId offset = PlotId.of(destination.getId().getX() - this.getId().getX(),
destination.getId().getY() - this.getId().getY());
Location db = destination.getBottomAbs();
Location ob = this.getBottomAbs();
final int offsetX = db.getX() - ob.getX();
@ -3276,7 +3258,7 @@ public class Plot {
}
Set<Plot> plots = this.getConnectedPlots();
for (Plot plot : plots) {
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
Plot other = plot.getRelative(destination.getArea(), offset.getX(), offset.getY());
if (other.hasOwner()) {
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
return false;
@ -3286,7 +3268,7 @@ public class Plot {
destination.updateWorldBorder();
// copy data
for (Plot plot : plots) {
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
Plot other = plot.getRelative(destination.getArea(), offset.getX(), offset.getY());
other.create(plot.getOwner(), false);
if (!plot.getFlagContainer().getFlagMap().isEmpty()) {
final Collection<PlotFlag<?, ?>> existingFlags = other.getFlags();
@ -3399,4 +3381,13 @@ public class Plot {
return FlagContainer.<T, V>castUnsafe(flagInstance).getValue();
}
/**
* Change the plot ID
*
* @param id new plot ID
*/
public void setId(@Nonnull final PlotId id) {
this.id = id;
}
}

View File

@ -27,7 +27,6 @@ package com.plotsquared.core.plot;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.collection.QuadMap;
import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions;
@ -66,11 +65,11 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -215,8 +214,8 @@ public abstract class PlotArea {
*
* @return the minimum value for a {@link PlotId}
*/
public PlotId getMin() {
return this.min == null ? new PlotId(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min;
@Nonnull public PlotId getMin() {
return this.min == null ? PlotId.of(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min;
}
/**
@ -224,8 +223,8 @@ public abstract class PlotArea {
*
* @return the maximum value for a {@link PlotId}
*/
public PlotId getMax() {
return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
@Nonnull public PlotId getMax() {
return this.max == null ? PlotId.of(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
}
@Override public boolean equals(Object obj) {
@ -596,8 +595,8 @@ public abstract class PlotArea {
}
public boolean contains(@Nonnull final PlotId id) {
return this.min == null || (id.x >= this.min.x && id.x <= this.max.x && id.y >= this.min.y
&& id.y <= this.max.y);
return this.min == null || (id.getX() >= this.min.getX() && id.getX() <= this.max.getX() &&
id.getY() >= this.min.getY() && id.getY() <= this.max.getY());
}
public boolean contains(@Nonnull final Location location) {
@ -661,8 +660,8 @@ public abstract class PlotArea {
@Nullable public Plot getPlotAbs(@Nonnull final PlotId id) {
Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
if (this.min != null && (id.x < this.min.x || id.x > this.max.x || id.y < this.min.y
|| id.y > this.max.y)) {
if (this.min != null && (id.getX() < this.min.getX() || id.getX() > this.max.getX() || id.getY() < this.min.getY()
|| id.getY() > this.max.getY())) {
return null;
}
return new Plot(this, id);
@ -673,8 +672,8 @@ public abstract class PlotArea {
@Nullable public Plot getPlot(@Nonnull final PlotId id) {
final Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
if (this.min != null && (id.x < this.min.x || id.x > this.max.x || id.y < this.min.y
|| id.y > this.max.y)) {
if (this.min != null && (id.getX() < this.min.getX() || id.getX() > this.max.getX() || id.getY() < this.min.getY()
|| id.getY() > this.max.getY())) {
return null;
}
return new Plot(this, id);
@ -696,7 +695,7 @@ public abstract class PlotArea {
if (plot == null) {
return null;
}
return this.clusters != null ? this.clusters.get(plot.getId().x, plot.getId().y) : null;
return this.clusters != null ? this.clusters.get(plot.getId().getX(), plot.getId().getY()) : null;
}
@Nullable
@ -714,7 +713,7 @@ public abstract class PlotArea {
}
@Nullable PlotCluster getCluster(@Nonnull final PlotId id) {
return this.clusters != null ? this.clusters.get(id.x, id.y) : null;
return this.clusters != null ? this.clusters.get(id.getX(), id.getY()) : null;
}
/**
@ -800,22 +799,22 @@ public abstract class PlotArea {
PlotId min = getMin();
PlotId max = getMax();
if (getType() == PlotAreaType.PARTIAL) {
center = new PlotId(MathMan.average(min.x, max.x), MathMan.average(min.y, max.y));
plots = Math.max(max.x - min.x + 1, max.y - min.y + 1) + 1;
center = PlotId.of(MathMan.average(min.getX(), max.getX()), MathMan.average(min.getY(), max.getY()));
plots = Math.max(max.getX() - min.getX() + 1, max.getY() - min.getY() + 1) + 1;
if (start != null) {
start = new PlotId(start.x - center.x, start.y - center.y);
start = PlotId.of(start.getX() - center.getX(), start.getY() - center.getY());
}
} else {
center = new PlotId(0, 0);
center = PlotId.of(0, 0);
plots = Integer.MAX_VALUE;
}
for (int i = 0; i < plots; i++) {
if (start == null) {
start = getMeta("lastPlot", new PlotId(0, 0));
start = getMeta("lastPlot", PlotId.of(0, 0));
} else {
start = start.getNextId(1);
start = start.getNextId();
}
PlotId currentId = new PlotId(center.x + start.x, center.y + start.y);
PlotId currentId = PlotId.of(center.getX() + start.getX(), center.getY() + start.getY());
Plot plot = getPlotAbs(currentId);
if (plot != null && plot.canClaim(player)) {
setMeta("lastPlot", start);
@ -888,7 +887,7 @@ public abstract class PlotArea {
public boolean canClaim(@Nullable final PlotPlayer player, @Nonnull final PlotId pos1,
@Nonnull final PlotId pos2) {
if (pos1.x == pos2.x && pos1.y == pos2.y) {
if (pos1.getX() == pos2.getX() && pos1.getY() == pos2.getY()) {
if (getOwnedPlot(pos1) != null) {
return false;
}
@ -898,9 +897,9 @@ public abstract class PlotArea {
}
return plot.canClaim(player);
}
for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) {
final PlotId id = new PlotId(x, y);
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
final PlotId id = PlotId.of(x, y);
final Plot plot = getPlotAbs(id);
if (plot == null) {
return false;
@ -930,9 +929,9 @@ public abstract class PlotArea {
final Set<UUID> trusted = new HashSet<>();
final Set<UUID> members = new HashSet<>();
final Set<UUID> denied = new HashSet<>();
for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) {
PlotId id = new PlotId(x, y);
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
PlotId id = PlotId.of(x, y);
Plot plot = getPlotAbs(id);
trusted.addAll(plot.getTrusted());
members.addAll(plot.getMembers());
@ -945,11 +944,11 @@ public abstract class PlotArea {
members.removeAll(trusted);
denied.removeAll(trusted);
denied.removeAll(members);
for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) {
final boolean lx = x < pos2.x;
final boolean ly = y < pos2.y;
final PlotId id = new PlotId(x, y);
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
final boolean lx = x < pos2.getX();
final boolean ly = y < pos2.getY();
final PlotId id = PlotId.of(x, y);
final Plot plot = getPlotAbs(id);
plot.setTrusted(trusted);
@ -991,22 +990,22 @@ public abstract class PlotArea {
* @return the plots in the selection which are owned
*/
public Set<Plot> getPlotSelectionOwned(@Nonnull final PlotId pos1, @Nonnull final PlotId pos2) {
final int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
final int size = (1 + pos2.getX() - pos1.getX()) * (1 + pos2.getY() - pos1.getY());
final Set<Plot> result = new HashSet<>();
if (size < 16 || size < getPlotCount()) {
for (final PlotId pid : MainUtil.getPlotSelectionIds(pos1, pos2)) {
final Plot plot = getPlotAbs(pid);
if (plot.hasOwner()) {
if (plot.getId().x > pos1.x || plot.getId().y > pos1.y
|| plot.getId().x < pos2.x || plot.getId().y < pos2.y) {
if (plot.getId().getX() > pos1.getX() || plot.getId().getY() > pos1.getY()
|| plot.getId().getX() < pos2.getX() || plot.getId().getY() < pos2.getY()) {
result.add(plot);
}
}
}
} else {
for (final Plot plot : getPlots()) {
if (plot.getId().x > pos1.x || plot.getId().y > pos1.y || plot.getId().x < pos2.x
|| plot.getId().y < pos2.y) {
if (plot.getId().getX() > pos1.getX() || plot.getId().getY() > pos1.getY() || plot.getId().getX() < pos2.getX()
|| plot.getId().getY() < pos2.getY()) {
result.add(plot);
}
}
@ -1026,8 +1025,8 @@ public abstract class PlotArea {
if (this.clusters == null) {
this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) {
@Override public CuboidRegion getRegion(PlotCluster value) {
BlockVector2 pos1 = BlockVector2.at(value.getP1().x, value.getP1().y);
BlockVector2 pos2 = BlockVector2.at(value.getP2().x, value.getP2().y);
BlockVector2 pos1 = BlockVector2.at(value.getP1().getX(), value.getP1().getY());
BlockVector2 pos2 = BlockVector2.at(value.getP2().getX(), value.getP2().getY());
return new CuboidRegion(pos1.toBlockVector3(),
pos2.toBlockVector3(Plot.MAX_HEIGHT - 1));
}

View File

@ -32,6 +32,7 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.UUID;
@ -87,7 +88,8 @@ public class PlotCluster {
}
private void setRegion() {
this.region = RegionUtil.createRegion(this.pos1.x, this.pos2.x, this.pos1.y, this.pos2.y);
this.region = RegionUtil.createRegion(this.pos1.getX(), this.pos2.getX(),
this.pos1.getY(), this.pos2.getY());
}
public CuboidRegion getRegion() {
@ -117,7 +119,7 @@ public class PlotCluster {
* Get the area (in plots).
*/
public int getArea() {
return (1 + this.pos2.x - this.pos1.x) * (1 + this.pos2.y - this.pos1.y);
return (1 + this.pos2.getX() - this.pos1.getX()) * (1 + this.pos2.getY() - this.pos1.getY());
}
public void setArea(PlotArea plotArea) {
@ -148,8 +150,7 @@ public class PlotCluster {
}
@Override public String toString() {
return this.area + ";" + this.pos1.x + ";" + this.pos1.y + ";" + this.pos2.x + ";"
+ this.pos2.y;
return this.area + ";" + this.pos1.toString() + ";" + this.pos2.toString();
}
public void getHome(@Nonnull final Consumer<Location> result) {
@ -180,13 +181,13 @@ public class PlotCluster {
}
}
public PlotId getCenterPlotId() {
PlotId bot = getP1();
PlotId top = getP2();
return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
@Nonnull public PlotId getCenterPlotId() {
final PlotId bot = getP1();
final PlotId top = getP2();
return PlotId.of((bot.getX() + top.getX()) / 2, (bot.getY() + top.getY()) / 2);
}
public Plot getCenterPlot() {
@Nullable public Plot getCenterPlot() {
return this.area.getPlotAbs(getCenterPlotId());
}
@ -201,12 +202,12 @@ public class PlotCluster {
}
public boolean intersects(PlotId pos1, PlotId pos2) {
return pos1.x <= this.pos2.x && pos2.x >= this.pos1.x && pos1.y <= this.pos2.y
&& pos2.y >= this.pos1.y;
return pos1.getX() <= this.pos2.getX() && pos2.getX() >= this.pos1.getX() &&
pos1.getY() <= this.pos2.getY() && pos2.getY() >= this.pos1.getY();
}
public boolean contains(PlotId id) {
return this.pos1.x <= id.x && this.pos1.y <= id.y && this.pos2.x >= id.x
&& this.pos2.y >= id.y;
return this.pos1.getX() <= id.getX() && this.pos1.getY() <= id.getY() &&
this.pos2.getX() >= id.getX() && this.pos2.getY() >= id.getY();
}
}

View File

@ -26,14 +26,20 @@
package com.plotsquared.core.plot;
import com.plotsquared.core.location.Direction;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Plot (X,Y) tuples for plot locations
* within a plot area
*/
public class PlotId {
@Deprecated public int x;
@Deprecated public int y;
private int hash;
private final int x;
private final int y;
private final int hash;
/**
* PlotId class (PlotId x,y values do not correspond to Block locations)
@ -41,9 +47,20 @@ public class PlotId {
* @param x The plot x coordinate
* @param y The plot y coordinate
*/
public PlotId(int x, int y) {
private PlotId(int x, int y) {
this.x = x;
this.y = y;
this.hash = (this.getX() << 16) | (this.getY() & 0xFFFF);
}
/**
* Create a new plot ID instance
*
* @param x The plot x coordinate
* @param y The plot y coordinate
*/
@Nonnull public static PlotId of(final int x, final int y) {
return PlotId.of(x, y);
}
/**
@ -60,6 +77,12 @@ public class PlotId {
return plot;
}
/**
* Attempt to parse a plot ID from a string
*
* @param string ID string
* @return Plot ID, or {@code null} if none could be parsed
*/
@Nullable public static PlotId fromStringOrNull(@Nonnull String string) {
String[] parts = string.split("[;,.]");
if (parts.length < 2) {
@ -73,101 +96,102 @@ public class PlotId {
} catch (NumberFormatException ignored) {
return null;
}
return new PlotId(x, y);
}
public static PlotId of(@Nullable Plot plot) {
return plot != null ? plot.getId() : null;
return of(x, y);
}
/**
* Gets the PlotId from the HashCode<br>
* Note: Only accurate for small x,z values (short)
*
* @param hash
* @return
* @param hash ID hash
* @return Plot ID
*/
public static PlotId unpair(int hash) {
return new PlotId(hash >> 16, hash & 0xFFFF);
@Nonnull public static PlotId unpair(final int hash) {
return PlotId.of(hash >> 16, hash & 0xFFFF);
}
/**
* Get a copy of the plot ID
*
* @return Plot ID copy
*/
@NotNull public PlotId copy() {
return of(this.getX(), this.getY());
}
/**
* Get the ID X component
*
* @return X component
*/
public int getX() {
return x;
return this.getX();
}
/**
* Get the ID Y component
*
* @return Y component
*/
public int getY() {
return y;
return this.getY();
}
public PlotId getNextId(int step) {
/**
* Get the next plot ID for claiming purposes
*
* @return Next plot ID
*/
@Nonnull public PlotId getNextId() {
int absX = Math.abs(x);
int absY = Math.abs(y);
if (absX > absY) {
if (x > 0) {
return new PlotId(x, y + 1);
return PlotId.of(x, y + 1);
} else {
return new PlotId(x, y - 1);
return PlotId.of(x, y - 1);
}
} else if (absY > absX) {
if (y > 0) {
return new PlotId(x - 1, y);
return PlotId.of(x - 1, y);
} else {
return new PlotId(x + 1, y);
return PlotId.of(x + 1, y);
}
} else {
if (x == y && x > 0) {
return new PlotId(x, y + step);
return PlotId.of(x, y + 1);
}
if (x == absX) {
return new PlotId(x, y + 1);
return PlotId.of(x, y + 1);
}
if (y == absY) {
return new PlotId(x, y - 1);
return PlotId.of(x, y - 1);
}
return new PlotId(x + 1, y);
return PlotId.of(x + 1, y);
}
}
public PlotId getRelative(Direction direction) {
return getRelative(direction.getIndex());
}
/**
* Get the PlotId in a relative direction
* 0 = north<br>
* 1 = east<br>
* 2 = south<br>
* 3 = west<br>
*
* @param direction
* @return PlotId
* @param direction Direction
* @return Relative plot ID
*/
public PlotId getRelative(int direction) {
@Nonnull public PlotId getRelative(@Nonnull final Direction direction) {
switch (direction) {
case 0:
return new PlotId(this.x, this.y - 1);
case 1:
return new PlotId(this.x + 1, this.y);
case 2:
return new PlotId(this.x, this.y + 1);
case 3:
return new PlotId(this.x - 1, this.y);
case NORTH:
return PlotId.of(this.getX(), this.getY() - 1);
case EAST:
return PlotId.of(this.getX() + 1, this.getY());
case SOUTH:
return PlotId.of(this.getX(), this.getY() + 1);
case WEST:
return PlotId.of(this.getX() - 1, this.getY());
}
return this;
}
/**
* Get the PlotId in a relative location
*
* @param x
* @param y
* @return PlotId
*/
public PlotId getRelative(int x, int y) {
return new PlotId(this.x + x, this.y + y);
}
@Override public boolean equals(Object obj) {
@Override public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
@ -180,42 +204,42 @@ public class PlotId {
if (getClass() != obj.getClass()) {
return false;
}
PlotId other = (PlotId) obj;
return this.x == other.x && this.y == other.y;
final PlotId other = (PlotId) obj;
return this.getX() == other.getX() && this.getY() == other.getY();
}
/**
* e.g.
* 5;-6
* Get a String representation of the plot ID where the
* components are separated by ";"
*
* @return
* @return {@code x + ";" + y}
*/
@Override public String toString() {
return this.x + ";" + this.y;
}
public String toCommaSeparatedString() {
return this.x + "," + this.y;
}
public String toDashSeparatedString() {
return this.x + "-" + this.y;
@Override @Nonnull public String toString() {
return this.getX() + ";" + this.getY();
}
/**
* The PlotId object caches the hashcode for faster mapping/fetching/sorting<br>
* - Recalculation is required if the x/y values change
* TODO maybe make x/y values private and add this to the mutators
* Get a String representation of the plot ID where the
* components are separated by ","
*
* @return {@code x + "," + y}
*/
public void recalculateHash() {
this.hash = 0;
hashCode();
@Nonnull public String toCommaSeparatedString() {
return this.getX() + "," + this.getY();
}
/**
* Get a String representation of the plot ID where the
* components are separated by "-"
*
* @return {@code x + "-" + y}
*/
@Nonnull public String toDashSeparatedString() {
return this.getX() + "-" + this.getY();
}
@Override public int hashCode() {
if (this.hash == 0) {
this.hash = (this.x << 16) | (this.y & 0xFFFF);
}
return this.hash;
}
}

View File

@ -1,47 +0,0 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2020 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.plot.schematic;
import com.sk89q.worldedit.world.item.ItemType;
public class PlotItem {
public final int x;
public final int y;
public final int z;
// public final short[] id;
// public final byte[] data;
public final ItemType[] types;
public final byte[] amount;
public PlotItem(short x, short y, short z, ItemType[] types, byte[] amount) {
this.x = x;
this.y = y;
this.z = z;
this.types = types;
this.amount = amount;
}
}

View File

@ -46,11 +46,11 @@ public class SinglePlotManager extends PlotManager {
}
@Override public PlotId getPlotIdAbs(int x, int y, int z) {
return new PlotId(0, 0);
return PlotId.of(0, 0);
}
@Override public PlotId getPlotId(int x, int y, int z) {
return new PlotId(0, 0);
return PlotId.of(0, 0);
}
@Override public Location getPlotBottomLocAbs(@Nonnull final PlotId plotId) {

View File

@ -250,7 +250,7 @@ public class EventDispatcher {
}));
MainUtil.sendMessage(player,
CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated())
+ " (on-login) " + "(" + plot.getId().x + ";" + plot.getId().y + ")");
+ " (on-login) " + "(" + plot.getId().getX() + ";" + plot.getId().getY() + ")");
}
}

View File

@ -363,9 +363,9 @@ public class MainUtil {
*/
public static ArrayList<PlotId> getPlotSelectionIds(PlotId pos1, PlotId pos2) {
ArrayList<PlotId> myPlots = new ArrayList<>();
for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) {
myPlots.add(new PlotId(x, y));
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
myPlots.add(PlotId.of(x, y));
}
}
return myPlots;

View File

@ -139,11 +139,11 @@ public abstract class SchematicHandler {
final String name;
if (namingScheme == null) {
name =
plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + owner;
plot.getId().getX() + ";" + plot.getId().getY() + ',' + plot.getArea() + ',' + owner;
} else {
name = namingScheme.replaceAll("%id%", plot.getId().toString())
.replaceAll("%idx%", plot.getId().x + "")
.replaceAll("%idy%", plot.getId().y + "")
.replaceAll("%idx%", plot.getId().getX() + "")
.replaceAll("%idy%", plot.getId().getY() + "")
.replaceAll("%world%", plot.getArea().toString());
}

View File

@ -34,20 +34,20 @@ if (PS.hasPlotArea("%s0")) {
var maxplot;
for (var i in plots) {
var plot = plots[i];
if (plot.x > max) {
max = plot.x;
if (plot.getX() > max) {
max = plot.getX();
maxplot = plot;
}
if (plot.y > max) {
max = plot.y;
if (plot.getY() > max) {
max = plot.getY();
maxplot = plot;
}
if (-plot.x > max) {
max = -plot.x;
if (-plot.getX() > max) {
max = -plot.getX();
maxplot = plot;
}
if (-plot.y > max) {
max = -plot.y;
if (-plot.getY() > max) {
max = -plot.getY();
maxplot = plot;
}
}

View File

@ -42,7 +42,7 @@ public class FlagTest {
}
// @Test public void flagTest() throws Exception {
// Plot plot = new Plot(null, new PlotId(0, 0));
// Plot plot = new Plot(null, PlotId.of(0, 0));
// plot.owner = UUID.fromString("84499644-ad72-454b-a19d-f28c28df382b");
// //plot.setFlag(use, use.parseValue("33,33:1,6:4")); //TODO fix this so FlagTest will run during compile
// Optional<? extends Collection> flag = plot.getFlag(use);