Address comments

This commit is contained in:
dordsor21 2021-01-09 19:55:19 +00:00 committed by Alexander Söderberg
parent ae0ee1ebdd
commit 8b332adbe7
6 changed files with 18 additions and 7 deletions

View File

@ -32,7 +32,6 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.WorldType; import org.bukkit.WorldType;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View File

@ -663,7 +663,7 @@ public class Area extends SubCommand {
Location center; Location center;
if (area instanceof SinglePlotArea) { if (area instanceof SinglePlotArea) {
((SinglePlotArea) area).loadWorld(PlotId.of(0, 0)); ((SinglePlotArea) area).loadWorld(PlotId.of(0, 0));
center = this.worldUtil.getSpawn(PlotId.of(0, 0).toSeparatedString("_")); center = this.worldUtil.getSpawn(PlotId.of(0, 0).toUnderscoreSeparatedString());
player.teleport(center, TeleportCause.COMMAND); player.teleport(center, TeleportCause.COMMAND);
} else if (area.getType() != PlotAreaType.PARTIAL) { } else if (area.getType() != PlotAreaType.PARTIAL) {
center = this.worldUtil.getSpawn(area.getWorldName()); center = this.worldUtil.getSpawn(area.getWorldName());

View File

@ -242,6 +242,16 @@ public final class PlotId {
return this.getX() + "," + this.getY(); 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 toUnderscoreSeparatedString() {
return this.getX() + "_" + this.getY();
}
/** /**
* Get a String representation of the plot ID where the * Get a String representation of the plot ID where the
* components are separated by "-" * components are separated by "-"

View File

@ -60,7 +60,7 @@ public class SinglePlot extends Plot {
} }
@Override public String getWorldName() { @Override public String getWorldName() {
return getId().toSeparatedString("_"); return getId().toUnderscoreSeparatedString();
} }
@Override public SinglePlotArea getArea() { @Override public SinglePlotArea getArea() {

View File

@ -87,7 +87,7 @@ public class SinglePlotArea extends GridPlotWorld {
} }
public void loadWorld(final PlotId id) { public void loadWorld(final PlotId id) {
String worldName = id.toSeparatedString("_"); String worldName = id.toUnderscoreSeparatedString();
if (PlotSquared.platform().worldUtil().isWorld(worldName)) { if (PlotSquared.platform().worldUtil().isWorld(worldName)) {
return; return;
} }
@ -145,7 +145,7 @@ public class SinglePlotArea extends GridPlotWorld {
try { try {
TaskManager.getPlatformImplementation().sync(() -> { TaskManager.getPlatformImplementation().sync(() -> {
final String name = id.toSeparatedString("_"); final String name = id.toUnderscoreSeparatedString();
if (!PlotSquared.platform().worldUtil().isWorld(name)) { if (!PlotSquared.platform().worldUtil().isWorld(name)) {
PlotSquared.platform().setupUtils().setupWorld(builder); PlotSquared.platform().setupUtils().setupWorld(builder);
} }

View File

@ -44,6 +44,8 @@ import java.util.List;
public class SinglePlotManager extends PlotManager { public class SinglePlotManager extends PlotManager {
private static final int MAX_COORDINATE = 30000000;
public SinglePlotManager(@Nonnull final PlotArea plotArea) { public SinglePlotManager(@Nonnull final PlotArea plotArea) {
super(plotArea); super(plotArea);
} }
@ -57,11 +59,11 @@ public class SinglePlotManager extends PlotManager {
} }
@Override public Location getPlotBottomLocAbs(@Nonnull final PlotId plotId) { @Override public Location getPlotBottomLocAbs(@Nonnull final PlotId plotId) {
return Location.at(plotId.toSeparatedString("_"), -30000000, 0, -30000000); return Location.at(plotId.toUnderscoreSeparatedString(), -MAX_COORDINATE, 0, -MAX_COORDINATE);
} }
@Override public Location getPlotTopLocAbs(@Nonnull final PlotId plotId) { @Override public Location getPlotTopLocAbs(@Nonnull final PlotId plotId) {
return Location.at(plotId.toSeparatedString("_"), 30000000, 0, 30000000); return Location.at(plotId.toUnderscoreSeparatedString(), MAX_COORDINATE, 0, MAX_COORDINATE);
} }
@Override public boolean clearPlot(@Nonnull Plot plot, final Runnable whenDone, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue) { @Override public boolean clearPlot(@Nonnull Plot plot, final Runnable whenDone, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue) {