Finalize immutable locations and add a platform world implementation

This commit is contained in:
Alexander Söderberg 2020-07-10 12:21:29 +02:00
parent cf1b027db9
commit 5341015cb1
51 changed files with 503 additions and 246 deletions

View File

@ -50,6 +50,7 @@ import com.plotsquared.bukkit.util.BukkitRegionManager;
import com.plotsquared.bukkit.util.BukkitSetupUtils; import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitTaskManager; import com.plotsquared.bukkit.util.BukkitTaskManager;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.BukkitWorld;
import com.plotsquared.bukkit.util.SetGenCB; import com.plotsquared.bukkit.util.SetGenCB;
import com.plotsquared.bukkit.util.UpdateUtility; import com.plotsquared.bukkit.util.UpdateUtility;
import com.plotsquared.bukkit.uuid.BungeePermsUUIDService; import com.plotsquared.bukkit.uuid.BungeePermsUUIDService;
@ -1168,4 +1169,8 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
return this.playerManager; return this.playerManager;
} }
@Override @NotNull public com.plotsquared.core.location.World<?> getPlatformWorld(@NotNull final String worldName) {
return BukkitWorld.of(worldName);
}
} }

View File

@ -150,23 +150,23 @@ public class ChunkListener implements Listener {
int z = chunkZ << 4; int z = chunkZ << 4;
int x2 = x + 15; int x2 = x + 15;
int z2 = z + 15; int z2 = z + 15;
Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs(); Plot plot = Location.at(world, x, 1, z).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) { if (plot != null && plot.hasOwner()) {
return true; return true;
} }
plot = new Location(world, x2, 1, z2).getOwnedPlotAbs(); plot = Location.at(world, x2, 1, z2).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) { if (plot != null && plot.hasOwner()) {
return true; return true;
} }
plot = new Location(world, x2, 1, z).getOwnedPlotAbs(); plot = Location.at(world, x2, 1, z).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) { if (plot != null && plot.hasOwner()) {
return true; return true;
} }
plot = new Location(world, x, 1, z2).getOwnedPlotAbs(); plot = Location.at(world, x, 1, z2).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) { if (plot != null && plot.hasOwner()) {
return true; return true;
} }
plot = new Location(world, x + 7, 1, z + 7).getOwnedPlotAbs(); plot = Location.at(world, x + 7, 1, z + 7).getOwnedPlotAbs();
return plot != null && plot.hasOwner(); return plot != null && plot.hasOwner();
} }

View File

@ -305,7 +305,7 @@ public class PaperListener implements Listener {
return; return;
} }
Location location = BukkitUtil.getLocation(entity); Location location = BukkitUtil.getLocation(entity);
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return; return;
} }
PlotPlayer<?> pp = BukkitUtil.getPlayer((Player) shooter); PlotPlayer<?> pp = BukkitUtil.getPlayer((Player) shooter);

View File

@ -256,7 +256,7 @@ public class PlayerEvents extends PlotListener implements Listener {
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) { for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
Location location = player.getLocation(); Location location = player.getLocation();
if (location.getWorld().equals(world)) { if (location.getWorldName().equals(world)) {
if (16 * Math.abs(location.getX() - x) / 16 > distance if (16 * Math.abs(location.getX() - x) / 16 > distance
|| 16 * Math.abs(location.getZ() - z) / 16 > distance) { || 16 * Math.abs(location.getZ() - z) / 16 > distance) {
continue; continue;
@ -455,16 +455,16 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
switch (piston.getFacing()) { switch (piston.getFacing()) {
case EAST: case EAST:
location.setX(location.getX() + 1); location = location.add(1, 0, 0);
break; break;
case SOUTH: case SOUTH:
location.setX(location.getX() - 1); location = location.add(-1, 0, 0);
break; break;
case WEST: case WEST:
location.setZ(location.getZ() + 1); location = location.add(0, 0, 1);
break; break;
case NORTH: case NORTH:
location.setZ(location.getZ() - 1); location = location.add(0, 0, -1);
break; break;
} }
Plot newPlot = area.getOwnedPlotAbs(location); Plot newPlot = area.getOwnedPlotAbs(location);
@ -490,7 +490,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
Location location = BukkitUtil.getLocation(entity); Location location = BukkitUtil.getLocation(entity);
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return; return;
} }
PlotPlayer<Player> pp = BukkitUtil.getPlayer((Player) shooter); PlotPlayer<Player> pp = BukkitUtil.getPlayer((Player) shooter);
@ -504,7 +504,7 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler public boolean onProjectileHit(ProjectileHitEvent event) { @EventHandler public boolean onProjectileHit(ProjectileHitEvent event) {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
Location location = BukkitUtil.getLocation(entity); Location location = BukkitUtil.getLocation(entity);
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return true; return true;
} }
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
@ -1078,7 +1078,7 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
boolean plotArea = location.isPlotArea(); boolean plotArea = location.isPlotArea();
if (!plotArea) { if (!plotArea) {
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return; return;
} }
return; return;
@ -1505,7 +1505,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ()); Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return; return;
} }
for (Block block1 : event.getBlocks()) { for (Block block1 : event.getBlocks()) {
@ -1542,7 +1542,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Location location = BukkitUtil.getLocation(block.getLocation()); Location location = BukkitUtil.getLocation(block.getLocation());
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return; return;
} }
if (this.pistonBlocks) { if (this.pistonBlocks) {
@ -1840,7 +1840,7 @@ public class PlayerEvents extends PlotListener implements Listener {
public void onPotionSplash(LingeringPotionSplashEvent event) { public void onPotionSplash(LingeringPotionSplashEvent event) {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
Location location = BukkitUtil.getLocation(entity); Location location = BukkitUtil.getLocation(entity);
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return; return;
} }
if (!this.onProjectileHit(event)) { if (!this.onProjectileHit(event)) {
@ -1907,7 +1907,7 @@ public class PlayerEvents extends PlotListener implements Listener {
public void onBigBoom(BlockExplodeEvent event) { public void onBigBoom(BlockExplodeEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
Location location = BukkitUtil.getLocation(block.getLocation()); Location location = BukkitUtil.getLocation(block.getLocation());
String world = location.getWorld(); String world = location.getWorldName();
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
return; return;
} }
@ -2707,7 +2707,7 @@ public class PlayerEvents extends PlotListener implements Listener {
public void onPotionSplash(PotionSplashEvent event) { public void onPotionSplash(PotionSplashEvent event) {
ThrownPotion damager = event.getPotion(); ThrownPotion damager = event.getPotion();
Location location = BukkitUtil.getLocation(damager); Location location = BukkitUtil.getLocation(damager);
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return; return;
} }
int count = 0; int count = 0;
@ -2737,7 +2737,7 @@ public class PlayerEvents extends PlotListener implements Listener {
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) { public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager(); Entity damager = event.getDamager();
Location location = BukkitUtil.getLocation(damager); Location location = BukkitUtil.getLocation(damager);
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
return; return;
} }
Entity victim = event.getEntity(); Entity victim = event.getEntity();

View File

@ -241,7 +241,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
return; return;
} }
final org.bukkit.Location bukkitLocation = final org.bukkit.Location bukkitLocation =
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5, new org.bukkit.Location(BukkitUtil.getWorld(location.getWorldName()), location.getX() + 0.5,
location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch()); location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch());
PaperLib.teleportAsync(player, bukkitLocation, getTeleportCause(cause)); PaperLib.teleportAsync(player, bukkitLocation, getTeleportCause(cause));
} }
@ -259,7 +259,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
@Override public void setCompassTarget(Location location) { @Override public void setCompassTarget(Location location) {
this.player.setCompassTarget( this.player.setCompassTarget(
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX(), new org.bukkit.Location(BukkitUtil.getWorld(location.getWorldName()), location.getX(),
location.getY(), location.getZ())); location.getY(), location.getZ()));
} }

View File

@ -62,7 +62,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
@Getter @Setter private ChunkData chunkData = null; @Getter @Setter private ChunkData chunkData = null;
public GenChunk() { public GenChunk() {
super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15)); super(null, Location.at("", 0, 0, 0), Location.at("", 15, 255, 15));
this.biomes = Biome.values(); this.biomes = Biome.values();
} }
@ -196,11 +196,11 @@ public class GenChunk extends ScopedLocalBlockQueue {
} }
@Override public Location getMax() { @Override public Location getMax() {
return new Location(getWorld(), 15 + (getX() << 4), 255, 15 + (getZ() << 4)); return Location.at(getWorld(), 15 + (getX() << 4), 255, 15 + (getZ() << 4));
} }
@Override public Location getMin() { @Override public Location getMin() {
return new Location(getWorld(), getX() << 4, 0, getZ() << 4); return Location.at(getWorld(), getX() << 4, 0, getZ() << 4);
} }
public GenChunk clone() { public GenChunk clone() {

View File

@ -198,9 +198,9 @@ public class BukkitRegionManager extends RegionManager {
final CuboidRegion region = final CuboidRegion region =
RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
final World oldWorld = Bukkit.getWorld(pos1.getWorld()); final World oldWorld = Bukkit.getWorld(pos1.getWorldName());
final BukkitWorld oldBukkitWorld = new BukkitWorld(oldWorld); final BukkitWorld oldBukkitWorld = new BukkitWorld(oldWorld);
final World newWorld = Bukkit.getWorld(newPos.getWorld()); final World newWorld = Bukkit.getWorld(newPos.getWorldName());
assert newWorld != null; assert newWorld != null;
assert oldWorld != null; assert oldWorld != null;
final String newWorldName = newWorld.getName(); final String newWorldName = newWorld.getName();
@ -248,7 +248,7 @@ public class BukkitRegionManager extends RegionManager {
@Override @Override
public boolean regenerateRegion(final Location pos1, final Location pos2, public boolean regenerateRegion(final Location pos1, final Location pos2,
final boolean ignoreAugment, final Runnable whenDone) { final boolean ignoreAugment, final Runnable whenDone) {
final String world = pos1.getWorld(); final String world = pos1.getWorldName();
final int p1x = pos1.getX(); final int p1x = pos1.getX();
final int p1z = pos1.getZ(); final int p1z = pos1.getZ();
@ -401,7 +401,7 @@ public class BukkitRegionManager extends RegionManager {
} }
@Override public void clearAllEntities(Location pos1, Location pos2) { @Override public void clearAllEntities(Location pos1, Location pos2) {
String world = pos1.getWorld(); String world = pos1.getWorldName();
List<Entity> entities = BukkitUtil.getEntities(world); List<Entity> entities = BukkitUtil.getEntities(world);
int bx = pos1.getX(); int bx = pos1.getX();
int bz = pos1.getZ(); int bz = pos1.getZ();
@ -428,8 +428,8 @@ public class BukkitRegionManager extends RegionManager {
RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ()); RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
CuboidRegion region2 = CuboidRegion region2 =
RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ()); RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
final World world1 = Bukkit.getWorld(bot1.getWorld()); final World world1 = Bukkit.getWorld(bot1.getWorldName());
final World world2 = Bukkit.getWorld(bot2.getWorld()); final World world2 = Bukkit.getWorld(bot2.getWorldName());
checkNotNull(world1, "Critical error during swap."); checkNotNull(world1, "Critical error during swap.");
checkNotNull(world2, "Critical error during swap."); checkNotNull(world2, "Critical error during swap.");
int relX = bot2.getX() - bot1.getX(); int relX = bot2.getX() - bot1.getX();
@ -456,9 +456,9 @@ public class BukkitRegionManager extends RegionManager {
@Override @Override
public void setBiome(final CuboidRegion region, final int extendBiome, final BiomeType biome, public void setBiome(final CuboidRegion region, final int extendBiome, final BiomeType biome,
final String world, final Runnable whenDone) { final String world, final Runnable whenDone) {
Location pos1 = new Location(world, region.getMinimumPoint().getX() - extendBiome, Location pos1 = Location.at(world, region.getMinimumPoint().getX() - extendBiome,
region.getMinimumPoint().getY(), region.getMinimumPoint().getZ() - extendBiome); region.getMinimumPoint().getY(), region.getMinimumPoint().getZ() - extendBiome);
Location pos2 = new Location(world, region.getMaximumPoint().getX() + extendBiome, Location pos2 = Location.at(world, region.getMaximumPoint().getX() + extendBiome,
region.getMaximumPoint().getY(), region.getMaximumPoint().getZ() + extendBiome); region.getMaximumPoint().getY(), region.getMaximumPoint().getZ() + extendBiome);
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false); final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);

View File

@ -276,18 +276,18 @@ public class BukkitUtil extends WorldUtil {
} }
public static Location getLocation(@NonNull final org.bukkit.Location location) { public static Location getLocation(@NonNull final org.bukkit.Location location) {
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ())); MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()));
} }
public static Location getLocationFull(@NonNull final org.bukkit.Location location) { public static Location getLocationFull(@NonNull final org.bukkit.Location location) {
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(), MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
location.getPitch()); location.getPitch());
} }
public static org.bukkit.Location getLocation(@NonNull final Location location) { public static org.bukkit.Location getLocation(@NonNull final Location location) {
return new org.bukkit.Location(getWorld(location.getWorld()), location.getX(), return new org.bukkit.Location((World) location.getWorld().getPlatformWorld(), location.getX(),
location.getY(), location.getZ()); location.getY(), location.getZ());
} }
@ -311,13 +311,13 @@ public class BukkitUtil extends WorldUtil {
public static Location getLocation(@NonNull final Entity entity) { public static Location getLocation(@NonNull final Entity entity) {
final org.bukkit.Location location = entity.getLocation(); final org.bukkit.Location location = entity.getLocation();
String world = location.getWorld().getName(); String world = location.getWorld().getName();
return new Location(world, location.getBlockX(), location.getBlockY(), return Location.at(world, location.getBlockX(), location.getBlockY(),
location.getBlockZ()); location.getBlockZ());
} }
@NotNull public static Location getLocationFull(@NonNull final Entity entity) { @NotNull public static Location getLocationFull(@NonNull final Entity entity) {
final org.bukkit.Location location = entity.getLocation(); final org.bukkit.Location location = entity.getLocation();
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), return Location.at(location.getWorld().getName(), MathMan.roundInt(location.getX()),
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
location.getPitch()); location.getPitch());
} }
@ -409,7 +409,7 @@ public class BukkitUtil extends WorldUtil {
} }
@Override @Nullable public String[] getSignSynchronous(@NonNull final Location location) { @Override @Nullable public String[] getSignSynchronous(@NonNull final Location location) {
Block block = getWorld(location.getWorld()) Block block = getWorld(location.getWorldName())
.getBlockAt(location.getX(), location.getY(), location.getZ()); .getBlockAt(location.getX(), location.getY(), location.getZ());
return TaskManager.IMP.sync(new RunnableVal<String[]>() { return TaskManager.IMP.sync(new RunnableVal<String[]>() {
@Override public void run(String[] value) { @Override public void run(String[] value) {
@ -423,12 +423,12 @@ public class BukkitUtil extends WorldUtil {
@Override public Location getSpawn(@NonNull final String world) { @Override public Location getSpawn(@NonNull final String world) {
final org.bukkit.Location temp = getWorld(world).getSpawnLocation(); final org.bukkit.Location temp = getWorld(world).getSpawnLocation();
return new Location(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(), return Location.at(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(),
temp.getYaw(), temp.getPitch()); temp.getYaw(), temp.getPitch());
} }
@Override public void setSpawn(@NonNull final Location location) { @Override public void setSpawn(@NonNull final Location location) {
final World world = getWorld(location.getWorld()); final World world = getWorld(location.getWorldName());
if (world != null) { if (world != null) {
world.setSpawnLocation(location.getX(), location.getY(), location.getZ()); world.setSpawnLocation(location.getX(), location.getY(), location.getZ());
} }
@ -526,14 +526,14 @@ public class BukkitUtil extends WorldUtil {
@Override @Override
public void getBlock(@NonNull final Location location, final Consumer<BlockState> result) { public void getBlock(@NonNull final Location location, final Consumer<BlockState> result) {
ensureLoaded(location, chunk -> { ensureLoaded(location, chunk -> {
final World world = getWorld(location.getWorld()); final World world = getWorld(location.getWorldName());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ()); final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
result.accept(BukkitAdapter.asBlockType(block.getType()).getDefaultState()); result.accept(BukkitAdapter.asBlockType(block.getType()).getDefaultState());
}); });
} }
@Override public BlockState getBlockSynchronous(@NonNull final Location location) { @Override public BlockState getBlockSynchronous(@NonNull final Location location) {
final World world = getWorld(location.getWorld()); final World world = getWorld(location.getWorldName());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ()); final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
return BukkitAdapter.asBlockType(block.getType()).getDefaultState(); return BukkitAdapter.asBlockType(block.getType()).getDefaultState();
} }

View File

@ -0,0 +1,85 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* 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.bukkit.util;
import com.google.common.collect.Maps;
import com.plotsquared.core.location.World;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
@EqualsAndHashCode @ToString public class BukkitWorld implements World<org.bukkit.World> {
private static final Map<String, BukkitWorld> worldMap = Maps.newHashMap();
private final org.bukkit.World world;
private BukkitWorld(@NotNull final org.bukkit.World world) {
this.world = world;
}
/**
* Get a new {@link BukkitWorld} from a world name
*
* @param worldName World name
* @return World instance
*/
@NotNull public static BukkitWorld of(@NotNull final String worldName) {
final org.bukkit.World bukkitWorld = Bukkit.getWorld(worldName);
if (bukkitWorld == null) {
throw new IllegalArgumentException(String.format("There is no world with the name '%s'", worldName));
}
return of(bukkitWorld);
}
/**
* Get a new {@link BukkitWorld} from a Bukkit world
*
* @param world Bukkit world
* @return World instance
*/
@NotNull public static BukkitWorld of(@NotNull final org.bukkit.World world) {
BukkitWorld bukkitWorld = worldMap.get(world.getName());
if (bukkitWorld != null && bukkitWorld.getPlatformWorld().equals(world)) {
return bukkitWorld;
}
bukkitWorld = new BukkitWorld(world);
worldMap.put(world.getName(), bukkitWorld);
return bukkitWorld;
}
@NotNull @Override public org.bukkit.World getPlatformWorld() {
return this.world;
}
@Override public @NotNull String getName() {
return this.world.getName();
}
}

View File

@ -29,6 +29,7 @@ import com.plotsquared.core.backup.BackupManager;
import com.plotsquared.core.generator.GeneratorWrapper; import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.location.World;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.queue.QueueProvider; import com.plotsquared.core.queue.QueueProvider;
import com.plotsquared.core.util.ChatManager; import com.plotsquared.core.util.ChatManager;
@ -302,4 +303,12 @@ public interface PlotPlatform<P> extends ILogger {
*/ */
@NotNull PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager(); @NotNull PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager();
/**
* Get a platform world wrapper from a world name
*
* @param worldName World name
* @return Platform world wrapper
*/
@NotNull World<?> getPlatformWorld(@NotNull final String worldName);
} }

View File

@ -129,13 +129,13 @@ import java.util.zip.ZipInputStream;
* An implementation of the core, with a static getter for easy access. * An implementation of the core, with a static getter for easy access.
*/ */
@SuppressWarnings({"WeakerAccess"}) @SuppressWarnings({"WeakerAccess"})
public class PlotSquared<P> { public class PlotSquared {
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet()); private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
private static PlotSquared<?> instance; private static PlotSquared instance;
// Implementation // Implementation
private final PlotPlatform<P> platform; private final PlotPlatform<?> platform;
// Current thread // Current thread
private final Thread thread; private final Thread thread;
// UUID pipelines // UUID pipelines
@ -174,7 +174,7 @@ public class PlotSquared<P> {
* @param iPlotMain Implementation of {@link PlotPlatform} used * @param iPlotMain Implementation of {@link PlotPlatform} used
* @param platform The platform being used * @param platform The platform being used
*/ */
public PlotSquared(final PlotPlatform<P> iPlotMain, final String platform) { public PlotSquared(final PlotPlatform<?> iPlotMain, final String platform) {
if (instance != null) { if (instance != null) {
throw new IllegalStateException("Cannot re-initialize the PlotSquared singleton"); throw new IllegalStateException("Cannot re-initialize the PlotSquared singleton");
} }
@ -375,11 +375,10 @@ public class PlotSquared<P> {
* *
* @return instance of PlotSquared * @return instance of PlotSquared
*/ */
public static PlotSquared<?> get() { public static PlotSquared get() {
return PlotSquared.instance; return PlotSquared.instance;
} }
/** /**
* Get the platform specific implementation of PlotSquared * Get the platform specific implementation of PlotSquared
* *
@ -1700,7 +1699,7 @@ public class PlotSquared<P> {
*/ */
public boolean isNonStandardGeneration(@NotNull final String world, public boolean isNonStandardGeneration(@NotNull final String world,
@NotNull final BlockVector2 chunkCoordinates) { @NotNull final BlockVector2 chunkCoordinates) {
final Location location = new Location(world, chunkCoordinates.getBlockX() << 4, 64, chunkCoordinates.getBlockZ() << 4); final Location location = Location.at(world, chunkCoordinates.getBlockX() << 4, 64, chunkCoordinates.getBlockZ() << 4);
final PlotArea area = plotAreaManager.getApplicablePlotArea(location); final PlotArea area = plotAreaManager.getApplicablePlotArea(location);
if (area == null) { if (area == null) {
return true; return true;

View File

@ -104,7 +104,7 @@ public class Area extends SubCommand {
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NEEDS_NAME); MainUtil.sendMessage(player, Captions.SINGLE_AREA_NEEDS_NAME);
return false; return false;
} }
final PlotArea existingArea = PlotSquared.get().getPlotAreaManager().getPlotArea(player.getLocation().getWorld(), args[1]); final PlotArea existingArea = PlotSquared.get().getPlotAreaManager().getPlotArea(player.getLocation().getWorldName(), args[1]);
if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) { if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) {
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NAME_TAKEN); MainUtil.sendMessage(player, Captions.SINGLE_AREA_NAME_TAKEN);
return false; return false;
@ -139,7 +139,7 @@ public class Area extends SubCommand {
BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ())); BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ()));
// There's only one plot in the area... // There's only one plot in the area...
final PlotId plotId = new PlotId(1, 1); final PlotId plotId = new PlotId(1, 1);
final HybridPlotWorld hybridPlotWorld = new HybridPlotWorld(player.getLocation().getWorld(), args[1], final HybridPlotWorld hybridPlotWorld = new HybridPlotWorld(player.getLocation().getWorldName(), args[1],
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId); Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId);
// Plot size is the same as the region width // Plot size is the same as the region width
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth(); hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
@ -462,7 +462,7 @@ public class Area extends SubCommand {
return false; return false;
} }
if (WorldUtil.IMP.isWorld(pa.getWorldName())) { if (WorldUtil.IMP.isWorld(pa.getWorldName())) {
if (!player.getLocation().getWorld().equals(pa.getWorldName())) { if (!player.getLocation().getWorldName().equals(pa.getWorldName())) {
player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()), player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND); TeleportCause.COMMAND);
} }
@ -648,15 +648,13 @@ public class Area extends SubCommand {
player.teleport(center, TeleportCause.COMMAND); player.teleport(center, TeleportCause.COMMAND);
} else { } else {
CuboidRegion region = area.getRegion(); CuboidRegion region = area.getRegion();
center = new Location(area.getWorldName(), region.getMinimumPoint().getX() center = Location.at(area.getWorldName(), region.getMinimumPoint().getX()
+ (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.getMinimumPoint().getZ() 0, region.getMinimumPoint().getZ()
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2); + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
WorldUtil.IMP WorldUtil.IMP
.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y -> { .getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y ->
center.setY(1 + y); player.teleport(center.withY(1 + y), TeleportCause.COMMAND));
player.teleport(center, TeleportCause.COMMAND);
});
} }
return true; return true;
case "delete": case "delete":

View File

@ -74,7 +74,7 @@ public class Claim extends SubCommand {
boolean force = event.getEventResult() == Result.FORCE; boolean force = event.getEventResult() == Result.FORCE;
int currentPlots = Settings.Limit.GLOBAL ? int currentPlots = Settings.Limit.GLOBAL ?
player.getPlotCount() : player.getPlotCount() :
player.getPlotCount(location.getWorld()); player.getPlotCount(location.getWorldName());
int grants = 0; int grants = 0;
if (currentPlots >= player.getAllowedPlots() && !force) { if (currentPlots >= player.getAllowedPlots() && !force) {
if (player.hasPersistentMeta("grantedPlots")) { if (player.hasPersistentMeta("grantedPlots")) {

View File

@ -117,7 +117,7 @@ public class Cluster extends SubCommand {
} }
int currentClusters = Settings.Limit.GLOBAL ? int currentClusters = Settings.Limit.GLOBAL ?
player.getClusterCount() : player.getClusterCount() :
player.getPlotCount(player.getLocation().getWorld()); player.getPlotCount(player.getLocation().getWorldName());
if (currentClusters >= player.getAllowedPlots()) { if (currentClusters >= player.getAllowedPlots()) {
return sendMessage(player, Captions.CANT_CLAIM_MORE_CLUSTERS); return sendMessage(player, Captions.CANT_CLAIM_MORE_CLUSTERS);
} }
@ -173,7 +173,7 @@ public class Cluster extends SubCommand {
if (Settings.Limit.GLOBAL) { if (Settings.Limit.GLOBAL) {
current = player.getPlayerClusterCount(); current = player.getPlayerClusterCount();
} else { } else {
current = player.getPlayerClusterCount(player.getLocation().getWorld()); current = player.getPlayerClusterCount(player.getLocation().getWorldName());
} }
int allowed = Permissions int allowed = Permissions
.hasPermissionRange(player, Captions.PERMISSION_CLUSTER_SIZE, .hasPermissionRange(player, Captions.PERMISSION_CLUSTER_SIZE,
@ -324,7 +324,7 @@ public class Cluster extends SubCommand {
if (Settings.Limit.GLOBAL) { if (Settings.Limit.GLOBAL) {
current = player.getPlayerClusterCount(); current = player.getPlayerClusterCount();
} else { } else {
current = player.getPlayerClusterCount(player.getLocation().getWorld()); current = player.getPlayerClusterCount(player.getLocation().getWorldName());
} }
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y); current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
int allowed = Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER, int allowed = Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER,
@ -454,7 +454,7 @@ public class Cluster extends SubCommand {
cluster.getName()); cluster.getName());
} }
for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation() for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation()
.getWorld()).ownedBy(uuid).asCollection()) { .getWorldName()).ownedBy(uuid).asCollection()) {
PlotCluster current = plot.getCluster(); PlotCluster current = plot.getCluster();
if (current != null && current.equals(cluster)) { if (current != null && current.equals(cluster)) {
plot.unclaim(); plot.unclaim();
@ -512,7 +512,7 @@ public class Cluster extends SubCommand {
cluster.invited.remove(uuid); cluster.invited.remove(uuid);
DBFunc.removeInvited(cluster, uuid); DBFunc.removeInvited(cluster, uuid);
MainUtil.sendMessage(player, Captions.CLUSTER_REMOVED, cluster.getName()); MainUtil.sendMessage(player, Captions.CLUSTER_REMOVED, cluster.getName());
for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorld()) for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorldName())
.ownedBy(uuid).asCollection()) { .ownedBy(uuid).asCollection()) {
PlotCluster current = plot.getCluster(); PlotCluster current = plot.getCluster();
if (current != null && current.equals(cluster)) { if (current != null && current.equals(cluster)) {

View File

@ -86,7 +86,7 @@ public class Comment extends SubCommand {
String message = StringMan.join(Arrays.copyOfRange(args, index, args.length), " "); String message = StringMan.join(Arrays.copyOfRange(args, index, args.length), " ");
PlotComment comment = PlotComment comment =
new PlotComment(player.getLocation().getWorld(), plot.getId(), message, new PlotComment(player.getLocation().getWorldName(), plot.getId(), message,
player.getName(), inbox.toString(), System.currentTimeMillis()); player.getName(), inbox.toString(), System.currentTimeMillis());
boolean result = inbox.addComment(plot, comment); boolean result = inbox.addComment(plot, comment);
if (!result) { if (!result) {

View File

@ -63,7 +63,7 @@ public class Debug extends SubCommand {
MainUtil.sendMessage(player, "Fetching loaded chunks..."); MainUtil.sendMessage(player, "Fetching loaded chunks...");
TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player, TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player,
"Loaded chunks: " + RegionManager.manager "Loaded chunks: " + RegionManager.manager
.getChunkChunks(player.getLocation().getWorld()).size() + "(" + ( .getChunkChunks(player.getLocation().getWorldName()).size() + "(" + (
System.currentTimeMillis() - start) + "ms) using thread: " + Thread System.currentTimeMillis() - start) + "ms) using thread: " + Thread
.currentThread().getName())); .currentThread().getName()));
return true; return true;

View File

@ -77,7 +77,7 @@ public class Delete extends SubCommand {
final java.util.Set<Plot> plots = plot.getConnectedPlots(); final java.util.Set<Plot> plots = plot.getConnectedPlots();
final int currentPlots = Settings.Limit.GLOBAL ? final int currentPlots = Settings.Limit.GLOBAL ?
player.getPlotCount() : player.getPlotCount() :
player.getPlotCount(location.getWorld()); player.getPlotCount(location.getWorldName());
Runnable run = () -> { Runnable run = () -> {
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);

View File

@ -133,7 +133,7 @@ public class Deny extends SubCommand {
player.stopSpectating(); player.stopSpectating();
} }
Location location = player.getLocation(); Location location = player.getLocation();
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld()); Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
MainUtil.sendMessage(player, Captions.YOU_GOT_DENIED); MainUtil.sendMessage(player, Captions.YOU_GOT_DENIED);
if (plot.equals(spawn.getPlot())) { if (plot.equals(spawn.getPlot())) {
Location newSpawn = Location newSpawn =

View File

@ -51,7 +51,7 @@ import java.net.URL;
public class Download extends SubCommand { public class Download extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorldName();
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
} }

View File

@ -105,7 +105,7 @@ public class Kick extends SubCommand {
Captions.CANNOT_KICK_PLAYER.send(player, player2.getName()); Captions.CANNOT_KICK_PLAYER.send(player, player2.getName());
return; return;
} }
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld()); Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
Captions.YOU_GOT_KICKED.send(player2); Captions.YOU_GOT_KICKED.send(player2);
if (plot.equals(spawn.getPlot())) { if (plot.equals(spawn.getPlot())) {
Location newSpawn = WorldUtil.IMP Location newSpawn = WorldUtil.IMP

View File

@ -138,7 +138,7 @@ public class ListCmd extends SubCommand {
page = 0; page = 0;
} }
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorldName();
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
String arg = args[0].toLowerCase(); String arg = args[0].toLowerCase();
final boolean[] sort = new boolean[] {true}; final boolean[] sort = new boolean[] {true};

View File

@ -53,7 +53,7 @@ import java.util.List;
public class Load extends SubCommand { public class Load extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorldName();
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
} }

View File

@ -50,7 +50,7 @@ import java.util.UUID;
public class Save extends SubCommand { public class Save extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorldName();
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
} }
@ -77,8 +77,8 @@ public class Save extends SubCommand {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
String time = (System.currentTimeMillis() / 1000) + ""; String time = (System.currentTimeMillis() / 1000) + "";
Location[] corners = plot.getCorners(); Location[] corners = plot.getCorners();
corners[0].setY(0); corners[0] = corners[0].withY(0);
corners[1].setY(255); corners[1] = corners[1].withY(255);
int size = (corners[1].getX() - corners[0].getX()) + 1; int size = (corners[1].getX() - corners[0].getX()) + 1;
PlotId id = plot.getId(); PlotId id = plot.getId();
String world1 = plot.getArea().toString().replaceAll(";", "-") String world1 = plot.getArea().toString().replaceAll(";", "-")

View File

@ -54,7 +54,7 @@ public class Target extends SubCommand {
Plot target = null; Plot target = null;
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) { if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
int distance = Integer.MAX_VALUE; int distance = Integer.MAX_VALUE;
for (Plot plot : PlotQuery.newQuery().inWorld(location.getWorld()).asCollection()) { for (Plot plot : PlotQuery.newQuery().inWorld(location.getWorldName()).asCollection()) {
double current = plot.getCenterSynchronous().getEuclideanDistanceSquared(location); double current = plot.getCenterSynchronous().getEuclideanDistanceSquared(location);
if (current < distance) { if (current < distance) {
distance = (int) current; distance = (int) current;

View File

@ -153,8 +153,8 @@ public class AugmentedUtils {
secondaryMask.setForceSync(true); secondaryMask.setForceSync(true);
ScopedLocalBlockQueue scoped = ScopedLocalBlockQueue scoped =
new ScopedLocalBlockQueue(secondaryMask, new Location(world, blockX, 0, blockZ), new ScopedLocalBlockQueue(secondaryMask, Location.at(world, blockX, 0, blockZ),
new Location(world, blockX + 15, 255, blockZ + 15)); Location.at(world, blockX + 15, 255, blockZ + 15));
generator.generateChunk(scoped, area); generator.generateChunk(scoped, area);
generator.populateChunk(scoped, area); generator.populateChunk(scoped, area);
} }

View File

@ -192,10 +192,10 @@ public class ClassicPlotManager extends SquarePlotManager {
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (CuboidRegion region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(), Location.at(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
maxY, region.getMinimumPoint().getZ()); maxY, region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(), Location.at(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
maxY, region.getMaximumPoint().getZ()); maxY, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
@ -314,31 +314,31 @@ public class ClassicPlotManager extends SquarePlotManager {
int ez = pos2.getZ() + 2; int ez = pos2.getZ() + 2;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
int maxY = getWorldHeight(); int maxY = getWorldHeight();
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz + 1), Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, maxY, ez - 1), Location.at(classicPlotWorld.getWorldName(), ex, maxY, ez - 1),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 0, sz + 1), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 0, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, 0, ez - 1), Location.at(classicPlotWorld.getWorldName(), ex, 0, ez - 1),
BlockUtil.get((short) 7, (byte) 0)); BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1), Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1,
sz + 1), sz + 1),
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1,
ez - 1), classicPlotWorld.WALL_BLOCK.toPattern()); ez - 1), classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), ex, 1, sz + 1), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), ex, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1), Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1,
sz + 1), sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1,
ez - 1), classicPlotWorld.WALL_BLOCK.toPattern()); ez - 1), classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern()); ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -351,32 +351,32 @@ public class ClassicPlotManager extends SquarePlotManager {
int sx = pos1.getX() - 2; int sx = pos1.getX() - 2;
int ex = pos2.getX() + 2; int ex = pos2.getX() + 2;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
new Location(classicPlotWorld.getWorldName(), ex - 1, Location.at(classicPlotWorld.getWorldName(), ex - 1,
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 0, sz), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 0, sz),
new Location(classicPlotWorld.getWorldName(), ex - 1, 0, ez), Location.at(classicPlotWorld.getWorldName(), ex - 1, 0, ez),
BlockUtil.get((short) 7, (byte) 0)); BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz), Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
sz), sz),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1,
sz), classicPlotWorld.WALL_BLOCK.toPattern()); sz), classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, ez), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, ez),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez), Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
ez), ez),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1,
ez), classicPlotWorld.WALL_BLOCK.toPattern()); ez), classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern()); ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -389,15 +389,15 @@ public class ClassicPlotManager extends SquarePlotManager {
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1; int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1, Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1,
sz + 1), new Location(classicPlotWorld.getWorldName(), ex - 1, sz + 1), Location.at(classicPlotWorld.getWorldName(), ex - 1,
classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1), classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 0, sz + 1), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 0, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex - 1, 0, ez - 1), Location.at(classicPlotWorld.getWorldName(), ex - 1, 0, ez - 1),
BlockUtil.get((short) 7, (byte) 0)); BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern()); ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -410,17 +410,17 @@ public class ClassicPlotManager extends SquarePlotManager {
int sz = pos1.getZ() - 1; int sz = pos1.getZ() - 1;
int ez = pos2.getZ() + 1; int ez = pos2.getZ() + 1;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
new Location(classicPlotWorld.getWorldName(), ex, Location.at(classicPlotWorld.getWorldName(), ex,
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1,
ez - 1), classicPlotWorld.MAIN_BLOCK.toPattern()); ez - 1), classicPlotWorld.MAIN_BLOCK.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz + 1), Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez - 1),
classicPlotWorld.TOP_BLOCK.toPattern()); classicPlotWorld.TOP_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -433,17 +433,17 @@ public class ClassicPlotManager extends SquarePlotManager {
int sx = pos1.getX() - 1; int sx = pos1.getX() - 1;
int ex = pos2.getX() + 1; int ex = pos2.getX() + 1;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
new Location(classicPlotWorld.getWorldName(), ex, Location.at(classicPlotWorld.getWorldName(), ex,
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1,
ez), classicPlotWorld.MAIN_BLOCK.toPattern()); ez), classicPlotWorld.MAIN_BLOCK.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.PLOT_HEIGHT, sz), Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT, ez),
classicPlotWorld.TOP_BLOCK.toPattern()); classicPlotWorld.TOP_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -455,17 +455,17 @@ public class ClassicPlotManager extends SquarePlotManager {
int sz = location.getZ() + 1; int sz = location.getZ() + 1;
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1; int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
new Location(classicPlotWorld.getWorldName(), ex, Location.at(classicPlotWorld.getWorldName(), ex,
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz), queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez), Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez),
classicPlotWorld.MAIN_BLOCK.toPattern()); classicPlotWorld.MAIN_BLOCK.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz), Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez), Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez),
classicPlotWorld.TOP_BLOCK.toPattern()); classicPlotWorld.TOP_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -529,8 +529,8 @@ public class ClassicPlotManager extends SquarePlotManager {
*/ */
@Override public Location getSignLoc(Plot plot) { @Override public Location getSignLoc(Plot plot) {
plot = plot.getBasePlot(false); plot = plot.getBasePlot(false);
Location bot = plot.getBottomAbs(); final Location bot = plot.getBottomAbs();
return new Location(classicPlotWorld.getWorldName(), bot.getX() - 1, return Location.at(classicPlotWorld.getWorldName(), bot.getX() - 1,
classicPlotWorld.ROAD_HEIGHT + 1, bot.getZ() - 2); classicPlotWorld.ROAD_HEIGHT + 1, bot.getZ() - 2);
} }

View File

@ -103,9 +103,8 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x + 1, id.y); PlotId id2 = new PlotId(id.x + 1, id.y);
Location bot = getPlotBottomLocAbs(id2); Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id); Location top = getPlotTopLocAbs(id);
Location pos1 = Location pos1 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1); Location pos2 = Location.at(hybridPlotWorld.getWorldName(), bot.getX(),
Location pos2 = new Location(hybridPlotWorld.getWorldName(), bot.getX(),
Math.min(getWorldHeight(), 255), top.getZ() + 1); Math.min(getWorldHeight(), 255), top.getZ() + 1);
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2); MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@ -163,9 +162,8 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x, id.y + 1); PlotId id2 = new PlotId(id.x, id.y + 1);
Location bot = getPlotBottomLocAbs(id2); Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id); Location top = getPlotTopLocAbs(id);
Location pos1 = Location pos1 = Location.at(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
new Location(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1); Location pos2 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1,
Location pos2 = new Location(hybridPlotWorld.getWorldName(), top.getX() + 1,
Math.min(getWorldHeight(), 255), bot.getZ()); Math.min(getWorldHeight(), 255), bot.getZ());
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2); MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@ -181,10 +179,8 @@ public class HybridPlotManager extends ClassicPlotManager {
super.createRoadSouthEast(plot); super.createRoadSouthEast(plot);
PlotId id = plot.getId(); PlotId id = plot.getId();
PlotId id2 = new PlotId(id.x + 1, id.y + 1); PlotId id2 = new PlotId(id.x + 1, id.y + 1);
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1); Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
Location pos2 = getPlotBottomLocAbs(id2); Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
pos1.setY(0);
pos2.setY(Math.min(getWorldHeight(), 255));
LocalBlockQueue queue = hybridPlotWorld.getQueue(false); LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
createSchemAbs(queue, pos1, pos2); createSchemAbs(queue, pos1, pos2);
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@ -239,18 +235,18 @@ public class HybridPlotManager extends ClassicPlotManager {
// Set the biome // Set the biome
MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome); MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome);
// These two locations are for each component (e.g. bedrock, main block, floor, air) // These two locations are for each component (e.g. bedrock, main block, floor, air)
Location bot = new Location(world, value[2], 0, value[3]); Location bot = Location.at(world, value[2], 0, value[3]);
Location top = new Location(world, value[4], 1, value[5]); Location top = Location.at(world, value[4], 1, value[5]);
queue.setCuboid(bot, top, bedrock); queue.setCuboid(bot, top, bedrock);
// Each component has a different layer // Each component has a different layer
bot.setY(1); bot = bot.withY(1);
top.setY(hybridPlotWorld.PLOT_HEIGHT); top = top.withY(hybridPlotWorld.PLOT_HEIGHT);
queue.setCuboid(bot, top, filling); queue.setCuboid(bot, top, filling);
bot.setY(hybridPlotWorld.PLOT_HEIGHT); bot = bot.withY(hybridPlotWorld.PLOT_HEIGHT);
top.setY(hybridPlotWorld.PLOT_HEIGHT + 1); top = top.withY(hybridPlotWorld.PLOT_HEIGHT + 1);
queue.setCuboid(bot, top, plotfloor); queue.setCuboid(bot, top, plotfloor);
bot.setY(hybridPlotWorld.PLOT_HEIGHT + 1); bot = bot.withY(hybridPlotWorld.PLOT_HEIGHT + 1);
top.setY(getWorldHeight()); top = top.withY(getWorldHeight());
queue.setCuboid(bot, top, air); queue.setCuboid(bot, top, air);
// And finally set the schematic, the y value is unimportant for this function // And finally set the schematic, the y value is unimportant for this function
pastePlotSchematic(queue, bot, top); pastePlotSchematic(queue, bot, top);

View File

@ -128,15 +128,13 @@ public class HybridPlotWorld extends ClassicPlotWorld {
return new HybridPlotManager(this); return new HybridPlotManager(this);
} }
public Location getSignLocation(Plot plot) { public Location getSignLocation(@NotNull Plot plot) {
plot = plot.getBasePlot(false); plot = plot.getBasePlot(false);
Location bot = plot.getBottomAbs(); final Location bot = plot.getBottomAbs();
if (SIGN_LOCATION == null) { if (SIGN_LOCATION == null) {
bot.setY(ROAD_HEIGHT + 1); return bot.withY(ROAD_HEIGHT + 1).add(-1, 0, -2);
return bot.add(-1, 0, -2);
} else { } else {
bot.setY(0); return bot.withY(0).add(SIGN_LOCATION.getX(), SIGN_LOCATION.getY(), SIGN_LOCATION.getZ());
return bot.add(SIGN_LOCATION.getX(), SIGN_LOCATION.getY(), SIGN_LOCATION.getZ());
} }
} }

View File

@ -222,8 +222,8 @@ public abstract class HybridUtils {
}); });
System.gc(); System.gc();
MainUtil.initCache(); MainUtil.initCache();
Location botLoc = new Location(world, bot.getX(), bot.getY(), bot.getZ()); Location botLoc = Location.at(world, bot.getX(), bot.getY(), bot.getZ());
Location topLoc = new Location(world, top.getX(), top.getY(), top.getZ()); Location topLoc = Location.at(world, top.getX(), top.getY(), top.getZ());
ChunkManager.chunkTask(botLoc, topLoc, new RunnableVal<int[]>() { ChunkManager.chunkTask(botLoc, topLoc, new RunnableVal<int[]>() {
@Override public void run(int[] value) { @Override public void run(int[] value) {
int X = value[0]; int X = value[0];

View File

@ -36,12 +36,13 @@ import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
public class SingleWorldGenerator extends IndependentPlotGenerator { public class SingleWorldGenerator extends IndependentPlotGenerator {
private Location bedrock1 = new Location(null, 0, 0, 0);
private Location bedrock2 = new Location(null, 15, 0, 15); private static final Location bedrock1 = Location.at("", 0, 0, 0);
private Location dirt1 = new Location(null, 0, 1, 0); private static final Location bedrock2 = Location.at("", 15, 0, 15);
private Location dirt2 = new Location(null, 15, 2, 15); private static final Location dirt1 = Location.at("", 0, 1, 0);
private Location grass1 = new Location(null, 0, 3, 0); private static final Location dirt2 = Location.at("", 15, 2, 15);
private Location grass2 = new Location(null, 15, 3, 15); private static final Location grass1 = Location.at("", 0, 3, 0);
private static final Location grass2 = Location.at("", 15, 3, 15);
@Override public String getName() { @Override public String getName() {
return "PlotSquared:single"; return "PlotSquared:single";

View File

@ -62,10 +62,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
Iterator<CuboidRegion> iterator = regions.iterator(); Iterator<CuboidRegion> iterator = regions.iterator();
CuboidRegion region = iterator.next(); CuboidRegion region = iterator.next();
iterator.remove(); iterator.remove();
Location pos1 = new Location(plot.getWorldName(), region.getMinimumPoint().getX(), final Location pos1 = Location.at(plot.getWorldName(), region.getMinimumPoint());
region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); final Location pos2 = Location.at(plot.getWorldName(), region.getMaximumPoint());
Location pos2 = new Location(plot.getWorldName(), region.getMaximumPoint().getX(),
region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
RegionManager.manager.regenerateRegion(pos1, pos2, false, this); RegionManager.manager.regenerateRegion(pos1, pos2, false, this);
} }
}; };
@ -80,7 +78,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1; + squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1; + squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
return new Location(squarePlotWorld.getWorldName(), x, Math.min(getWorldHeight(), 255), z); return Location.at(squarePlotWorld.getWorldName(), x, Math.min(getWorldHeight(), 255), z);
} }
@Override public PlotId getPlotIdAbs(int x, int y, int z) { @Override public PlotId getPlotIdAbs(int x, int y, int z) {
@ -247,7 +245,6 @@ public abstract class SquarePlotManager extends GridPlotManager {
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math + squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math
.floor(squarePlotWorld.ROAD_WIDTH / 2); .floor(squarePlotWorld.ROAD_WIDTH / 2);
return new Location(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), return Location.at(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), z);
z);
} }
} }

View File

@ -41,15 +41,15 @@ import org.khelekore.prtree.SimpleMBR;
/** /**
* An unmodifiable 6-tuple (world,x,y,z,yaw,pitch) * An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
*/ */
@EqualsAndHashCode @EqualsAndHashCode @SuppressWarnings("unused")
public final class Location implements Comparable<Location> { public final class Location implements Comparable<Location> {
@Getter private final float yaw; @Getter private final float yaw;
@Getter private final float pitch; @Getter private final float pitch;
@Getter private final String world;
@Getter private final BlockVector3 blockVector3; @Getter private final BlockVector3 blockVector3;
private final World<?> world;
private Location(@NotNull final String world, @NotNull final BlockVector3 blockVector3, private Location(@NotNull final World<?> world, @NotNull final BlockVector3 blockVector3,
final float yaw, final float pitch) { final float yaw, final float pitch) {
this.world = Preconditions.checkNotNull(world, "World may not be null"); this.world = Preconditions.checkNotNull(world, "World may not be null");
this.blockVector3 = Preconditions.checkNotNull(blockVector3, "Vector may not be null"); this.blockVector3 = Preconditions.checkNotNull(blockVector3, "Vector may not be null");
@ -57,6 +57,19 @@ public final class Location implements Comparable<Location> {
this.pitch = pitch; this.pitch = pitch;
} }
private Location(@NotNull final String worldName, @NotNull final BlockVector3 blockVector3,
final float yaw, final float pitch) {
Preconditions.checkNotNull(worldName, "World name may not be null");
if (worldName.isEmpty()) {
this.world = World.nullWorld();
} else {
this.world = PlotSquared.platform().getPlatformWorld(worldName);
}
this.blockVector3 = Preconditions.checkNotNull(blockVector3, "Vector may not be null");
this.yaw = yaw;
this.pitch = pitch;
}
/** /**
* Construct a new location * Construct a new location
* *
@ -113,6 +126,80 @@ public final class Location implements Comparable<Location> {
return at(world, BlockVector3.at(x, y, z)); return at(world, BlockVector3.at(x, y, z));
} }
/**
* Construct a new location
*
* @param world World
* @param blockVector3 (x,y,z) vector
* @param yaw yaw
* @param pitch pitch
* @return New location
*/
@NotNull public static Location at(@NotNull final World<?> world,
@NotNull final BlockVector3 blockVector3, final float yaw, final float pitch) {
return new Location(world, blockVector3, yaw, pitch);
}
/**
* Construct a new location with yaw and pitch equal to 0
*
* @param world World
* @param blockVector3 (x,y,z) vector
* @return New location
*/
@NotNull public static Location at(@NotNull final World<?> world,
@NotNull final BlockVector3 blockVector3) {
return at(world, blockVector3, 0f, 0f);
}
/**
* Construct a new location
*
* @param world World
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @param yaw Yaw
* @param pitch Pitch
* @return New location
*/
@NotNull public static Location at(@NotNull final World<?> world, final int x, final int y,
final int z, final float yaw, final float pitch) {
return at(world, BlockVector3.at(x, y, z), yaw, pitch);
}
/**
* Construct a new location with yaw and pitch equal to 0
*
* @param world World
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @return New location
*/
@NotNull public static Location at(@NotNull final World<?> world, final int x, final int y,
final int z) {
return at(world, BlockVector3.at(x, y, z));
}
/**
* Get the world object
*
* @return World object
*/
@NotNull public World<?> getWorld() {
return this.world;
}
/**
* Get the name of the world this location is in
*
* @return World name
*/
@NotNull public String getWorldName() {
return this.world.getName();
}
/** /**
* Get the X coordinate * Get the X coordinate
* *

View File

@ -0,0 +1,84 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* 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.location;
import org.jetbrains.annotations.NotNull;
/**
* PlotSquared representation of a platform world
*
* @param <T> Platform world type
*/
public interface World<T> {
/**
* Get the platform world represented by this world
*
* @return Platform world
*/
@NotNull T getPlatformWorld();
/**
* Get the name of the world
*
* @return World name
*/
@NotNull String getName();
/**
* Get a {@link NullWorld} implementation
*
* @return NullWorld instance
*/
static <T> NullWorld<T> nullWorld() {
return new NullWorld<>();
}
class NullWorld<T> implements World<T> {
private NullWorld() {
}
@NotNull @Override public T getPlatformWorld() {
throw new UnsupportedOperationException("Cannot get platform world from NullWorld");
}
@Override public @NotNull String getName() {
return "";
}
@Override public boolean equals(final Object obj) {
return obj instanceof NullWorld;
}
@Override public int hashCode() {
return "null".hashCode();
}
}
}

View File

@ -56,11 +56,11 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
Location location; Location location;
if (area != null) { if (area != null) {
CuboidRegion region = area.getRegion(); CuboidRegion region = area.getRegion();
location = new Location(area.getWorldName(), location = Location.at(area.getWorldName(),
region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0, region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0,
region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2); region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2);
} else { } else {
location = new Location("world", 0, 0, 0); location = Location.at("world", 0, 0, 0);
} }
setMeta("location", location); setMeta("location", location);
} }

View File

@ -266,7 +266,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
*/ */
public int getPlotCount() { public int getPlotCount() {
if (!Settings.Limit.GLOBAL) { if (!Settings.Limit.GLOBAL) {
return getPlotCount(getLocation().getWorld()); return getPlotCount(getLocation().getWorldName());
} }
final AtomicInteger count = new AtomicInteger(0); final AtomicInteger count = new AtomicInteger(0);
final UUID uuid = getUUID(); final UUID uuid = getUUID();
@ -286,7 +286,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
public int getClusterCount() { public int getClusterCount() {
if (!Settings.Limit.GLOBAL) { if (!Settings.Limit.GLOBAL) {
return getClusterCount(getLocation().getWorld()); return getClusterCount(getLocation().getWorldName());
} }
final AtomicInteger count = new AtomicInteger(0); final AtomicInteger count = new AtomicInteger(0);
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> { PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> {

View File

@ -1442,7 +1442,7 @@ public class Plot {
return this.getDefaultHomeSynchronous(true); return this.getDefaultHomeSynchronous(true);
} else { } else {
Location bottom = this.getBottomAbs(); Location bottom = this.getBottomAbs();
Location location = Location.at(bottom.getWorld(), bottom.getX() + home.getX(), Location location = Location.at(bottom.getWorldName(), bottom.getX() + home.getX(),
bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(), bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(),
home.getPitch()); home.getPitch());
if (!isLoaded()) { if (!isLoaded()) {
@ -1466,7 +1466,7 @@ public class Plot {
this.getDefaultHome(result); this.getDefaultHome(result);
} else { } else {
Location bottom = this.getBottomAbs(); Location bottom = this.getBottomAbs();
Location location = Location.at(bottom.getWorld(), bottom.getX() + home.getX(), Location location = Location.at(bottom.getWorldName(), bottom.getX() + home.getX(),
bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(), bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(),
home.getPitch()); home.getPitch());
if (!isLoaded()) { if (!isLoaded()) {
@ -1850,7 +1850,7 @@ public class Plot {
*/ */
public void getBiome(Consumer<BiomeType> result) { public void getBiome(Consumer<BiomeType> result) {
this.getCenter(location -> WorldUtil.IMP this.getCenter(location -> WorldUtil.IMP
.getBiome(location.getWorld(), location.getX(), location.getZ(), result)); .getBiome(location.getWorldName(), location.getX(), location.getZ(), result));
} }
/** /**
@ -1859,7 +1859,7 @@ public class Plot {
@Deprecated public BiomeType getBiomeSynchronous() { @Deprecated public BiomeType getBiomeSynchronous() {
final Location location = this.getCenterSynchronous(); final Location location = this.getCenterSynchronous();
return WorldUtil.IMP return WorldUtil.IMP
.getBiomeSynchronous(location.getWorld(), location.getX(), location.getZ()); .getBiomeSynchronous(location.getWorldName(), location.getX(), location.getZ());
} }
//TODO Better documentation needed. //TODO Better documentation needed.

View File

@ -585,7 +585,7 @@ public abstract class PlotArea {
} }
public boolean contains(@NotNull final Location location) { public boolean contains(@NotNull final Location location) {
return StringMan.isEqual(location.getWorld(), this.getWorldName()) && ( return StringMan.isEqual(location.getWorldName(), this.getWorldName()) && (
getRegionAbs() == null || this.region.contains(location.getBlockVector3())); getRegionAbs() == null || this.region.contains(location.getBlockVector3()));
} }

View File

@ -31,6 +31,7 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
@ -151,17 +152,17 @@ public class PlotCluster {
+ this.pos2.y; + this.pos2.y;
} }
public void getHome(Consumer<Location> result) { public void getHome(@NotNull final Consumer<Location> result) {
BlockLoc home = this.settings.getPosition(); final BlockLoc home = this.settings.getPosition();
Consumer<Location> locationConsumer = toReturn -> { Consumer<Location> locationConsumer = toReturn ->
MainUtil.getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(), MainUtil.getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(),
max -> { max -> {
if (max > toReturn.getY()) { if (max > toReturn.getY()) {
toReturn.setY(1 + max); result.accept(toReturn.withY(1 + max));
} else {
result.accept(toReturn);
} }
result.accept(toReturn); });
});
};
if (home.getY() == 0) { if (home.getY() == 0) {
// default pos // default pos
Plot center = getCenterPlot(); Plot center = getCenterPlot();
@ -170,7 +171,7 @@ public class PlotCluster {
if (toReturn.getY() == 0) { if (toReturn.getY() == 0) {
PlotManager manager = this.area.getPlotManager(); PlotManager manager = this.area.getPlotManager();
Location locationSign = manager.getSignLoc(center); Location locationSign = manager.getSignLoc(center);
toReturn.setY(locationSign.getY()); toReturn = toReturn.withY(locationSign.getY());
} }
locationConsumer.accept(toReturn); locationConsumer.accept(toReturn);
}); });

View File

@ -58,7 +58,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
if (location == null) { if (location == null) {
return null; return null;
} }
final PlotWorld world = this.plotWorlds.get(location.getWorld()); final PlotWorld world = this.plotWorlds.get(location.getWorldName());
if (world == null) { if (world == null) {
return null; return null;
} }

View File

@ -156,23 +156,23 @@ public class SinglePlotArea extends GridPlotWorld {
} }
@Nullable @Override public Plot getOwnedPlot(@NotNull final Location location) { @Nullable @Override public Plot getOwnedPlot(@NotNull final Location location) {
PlotId pid = PlotId.fromStringOrNull(location.getWorld()); PlotId pid = PlotId.fromStringOrNull(location.getWorldName());
Plot plot = pid == null ? null : this.plots.get(pid); Plot plot = pid == null ? null : this.plots.get(pid);
return plot == null ? null : plot.getBasePlot(false); return plot == null ? null : plot.getBasePlot(false);
} }
@Nullable @Override public Plot getOwnedPlotAbs(@NotNull Location location) { @Nullable @Override public Plot getOwnedPlotAbs(@NotNull Location location) {
PlotId pid = PlotId.fromStringOrNull(location.getWorld()); PlotId pid = PlotId.fromStringOrNull(location.getWorldName());
return pid == null ? null : plots.get(pid); return pid == null ? null : plots.get(pid);
} }
@Nullable @Override public Plot getPlot(@NotNull final Location location) { @Nullable @Override public Plot getPlot(@NotNull final Location location) {
PlotId pid = PlotId.fromStringOrNull(location.getWorld()); PlotId pid = PlotId.fromStringOrNull(location.getWorldName());
return pid == null ? null : getPlot(pid); return pid == null ? null : getPlot(pid);
} }
@Nullable @Override public Plot getPlotAbs(@NotNull final Location location) { @Nullable @Override public Plot getPlotAbs(@NotNull final Location location) {
final PlotId pid = PlotId.fromStringOrNull(location.getWorld()); final PlotId pid = PlotId.fromStringOrNull(location.getWorldName());
return pid == null ? null : getPlotAbs(pid); return pid == null ? null : getPlotAbs(pid);
} }

View File

@ -99,7 +99,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
if (location == null) { if (location == null) {
return null; return null;
} }
String world = location.getWorld(); String world = location.getWorldName();
return isWorld(world) || world.equals("*") || super.getAllPlotAreas().length == 0 ? return isWorld(world) || world.equals("*") || super.getAllPlotAreas().length == 0 ?
area : area :
super.getApplicablePlotArea(location); super.getApplicablePlotArea(location);
@ -118,7 +118,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
if (found != null) { if (found != null) {
return found; return found;
} }
return isWorld(location.getWorld()) || location.getWorld().equals("*") ? area : null; return isWorld(location.getWorldName()) || location.getWorldName().equals("*") ? area : null;
} }
@Override @NotNull public PlotArea[] getPlotAreas(@NotNull final String world, @NotNull final CuboidRegion region) { @Override @NotNull public PlotArea[] getPlotAreas(@NotNull final String world, @NotNull final CuboidRegion region) {

View File

@ -35,6 +35,7 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -52,12 +53,12 @@ public class SinglePlotManager extends PlotManager {
return new PlotId(0, 0); return new PlotId(0, 0);
} }
@Override public Location getPlotBottomLocAbs(PlotId plotId) { @Override public Location getPlotBottomLocAbs(@NotNull final PlotId plotId) {
return new Location(plotId.toCommaSeparatedString(), -30000000, 0, -30000000); return Location.at(plotId.toCommaSeparatedString(), -30000000, 0, -30000000);
} }
@Override public Location getPlotTopLocAbs(PlotId plotId) { @Override public Location getPlotTopLocAbs(@NotNull final PlotId plotId) {
return new Location(plotId.toCommaSeparatedString(), 30000000, 0, 30000000); return Location.at(plotId.toCommaSeparatedString(), 30000000, 0, 30000000);
} }
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) { @Override public boolean clearPlot(Plot plot, final Runnable whenDone) {

View File

@ -31,6 +31,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Arrays; import java.util.Arrays;
@ -46,7 +47,7 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
private final BlockVector3 top; private final BlockVector3 top;
public ChunkBlockQueue(BlockVector3 bot, BlockVector3 top, boolean biomes) { public ChunkBlockQueue(BlockVector3 bot, BlockVector3 top, boolean biomes) {
super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15)); super(null, Location.at("", 0, 0, 0), Location.at("", 15, 255, 15));
this.width = top.getX() - bot.getX() + 1; this.width = top.getX() - bot.getX() + 1;
this.length = top.getZ() - bot.getZ() + 1; this.length = top.getZ() - bot.getZ() + 1;
this.area = width * length; this.area = width * length;
@ -113,15 +114,15 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
return null; return null;
} }
@Override @Nullable public String getWorld() { @Override @NotNull public String getWorld() {
return null; return "";
} }
@Override public Location getMax() { @Override public Location getMax() {
return new Location(getWorld(), top.getX(), top.getY(), top.getZ()); return Location.at(getWorld(), top.getX(), top.getY(), top.getZ());
} }
@Override public Location getMin() { @Override public Location getMin() {
return new Location(getWorld(), bot.getX(), bot.getY(), bot.getZ()); return Location.at(getWorld(), bot.getX(), bot.getY(), bot.getZ());
} }
} }

View File

@ -125,7 +125,7 @@ public abstract class LocalBlockQueue {
for (final PlotPlayer pp : PlotSquared.platform().getPlayerManager().getPlayers()) { for (final PlotPlayer pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
Location pLoc = pp.getLocation(); Location pLoc = pp.getLocation();
if (!StringMan.isEqual(getWorld(), pLoc.getWorld()) || !pLoc.getChunkLocation() if (!StringMan.isEqual(getWorld(), pLoc.getWorldName()) || !pLoc.getChunkLocation()
.equals(loc)) { .equals(loc)) {
continue; continue;
} }

View File

@ -35,6 +35,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import org.jetbrains.annotations.NotNull;
public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue { public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
private final int minX; private final int minX;
@ -92,11 +93,11 @@ public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
} }
public Location getMin() { public Location getMin() {
return new Location(getWorld(), minX, minY, minZ); return Location.at(this.getWorld(), this.minX, this.minY, this.minZ);
} }
public Location getMax() { public Location getMax() {
return new Location(getWorld(), maxX, maxY, maxZ); return Location.at(this.getWorld(), this.maxX, this.maxY, this.maxZ);
} }
/** /**
@ -107,26 +108,22 @@ public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
* *
* @param task * @param task
*/ */
public void mapByType2D(RunnableVal3<Plot, Integer, Integer> task) { public void mapByType2D(@NotNull final RunnableVal3<Plot, Integer, Integer> task) {
int bx = minX; final int bx = minX;
int bz = minZ; final int bz = minZ;
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(getWorld(), null); final PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(getWorld(), null);
Location location = new Location(getWorld(), bx, 0, bz); final Location location = Location.at(getWorld(), bx, 0, bz);
if (area != null) { if (area != null) {
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
location.setX(bx + x);
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
location.setZ(bz + z); task.run(area.getPlotAbs(location.withX(bx + x).withZ(bz + z)), x, z);
task.run(area.getPlotAbs(location), x, z);
} }
} }
} else { } else {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
location.setX(bx + x);
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
location.setZ(bz + z); task.run(location.withX(bx + x).withZ(bz + z).getPlotAbs(), x, z);
task.run(location.getPlotAbs(), x, z);
} }
} }
} }

View File

@ -56,8 +56,8 @@ public abstract class ChunkManager {
int blockX = loc.getX() << 4; int blockX = loc.getX() << 4;
int blockZ = loc.getZ() << 4; int blockZ = loc.getZ() << 4;
ScopedLocalBlockQueue scoped = ScopedLocalBlockQueue scoped =
new ScopedLocalBlockQueue(queue, new Location(world, blockX, 0, blockZ), new ScopedLocalBlockQueue(queue, Location.at(world, blockX, 0, blockZ),
new Location(world, blockX + 15, 255, blockZ + 15)); Location.at(world, blockX + 15, 255, blockZ + 15));
if (force != null) { if (force != null) {
force.run(scoped); force.run(scoped);
} else { } else {
@ -108,9 +108,9 @@ public abstract class ChunkManager {
return; return;
} }
CuboidRegion value = regions.remove(0); CuboidRegion value = regions.remove(0);
Location pos1 = new Location(plot.getWorldName(), value.getMinimumPoint().getX(), 0, Location pos1 = Location.at(plot.getWorldName(), value.getMinimumPoint().getX(), 0,
value.getMinimumPoint().getZ()); value.getMinimumPoint().getZ());
Location pos2 = new Location(plot.getWorldName(), value.getMaximumPoint().getX(), 0, Location pos2 = Location.at(plot.getWorldName(), value.getMaximumPoint().getX(), 0,
value.getMaximumPoint().getZ()); value.getMaximumPoint().getZ());
chunkTask(pos1, pos2, task, this, allocate); chunkTask(pos1, pos2, task, this, allocate);
} }
@ -191,12 +191,12 @@ public abstract class ChunkManager {
int z1 = chunk.getZ() << 4; int z1 = chunk.getZ() << 4;
int x2 = x1 + 15; int x2 = x1 + 15;
int z2 = z1 + 15; int z2 = z1 + 15;
Location bot = new Location(world, x1, 0, z1); Location bot = Location.at(world, x1, 0, z1);
Plot plot = bot.getOwnedPlotAbs(); Plot plot = bot.getOwnedPlotAbs();
if (plot != null) { if (plot != null) {
return plot; return plot;
} }
Location top = new Location(world, x2, 0, z2); Location top = Location.at(world, x2, 0, z2);
plot = top.getOwnedPlotAbs(); plot = top.getOwnedPlotAbs();
return plot; return plot;
} }

View File

@ -397,12 +397,10 @@ public class MainUtil {
return plot.getFlag(ServerPlotFlag.class); return plot.getFlag(ServerPlotFlag.class);
} }
@NotNull public static Location[] getCorners(String world, CuboidRegion region) { @NotNull public static Location[] getCorners(@NotNull final String world, @NotNull final CuboidRegion region) {
BlockVector3 min = region.getMinimumPoint(); final BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); final BlockVector3 max = region.getMaximumPoint();
Location pos1 = new Location(world, min.getX(), min.getY(), min.getZ()); return new Location[] {Location.at(world, min), Location.at(world, max)};
Location pos2 = new Location(world, max.getX(), max.getY(), max.getZ());
return new Location[] {pos1, pos2};
} }
/** /**
@ -426,16 +424,16 @@ public class MainUtil {
Location pos1 = corners[0]; Location pos1 = corners[0];
Location pos2 = corners[1]; Location pos2 = corners[1];
if (pos2.getX() > max.getX()) { if (pos2.getX() > max.getX()) {
max.setX(pos2.getX()); max = max.withX(pos2.getX());
} }
if (pos1.getX() < min.getX()) { if (pos1.getX() < min.getX()) {
min.setX(pos1.getX()); min = min.withX(pos1.getX());
} }
if (pos2.getZ() > max.getZ()) { if (pos2.getZ() > max.getZ()) {
max.setZ(pos2.getZ()); max = max.withZ(pos2.getZ());
} }
if (pos1.getZ() < min.getZ()) { if (pos1.getZ() < min.getZ()) {
min.setZ(pos1.getZ()); min = min.withZ(pos1.getZ());
} }
} }
return new Location[] {min, max}; return new Location[] {min, max};

View File

@ -75,7 +75,7 @@ public class OperationUtil {
weWorld = ((Player) actor).getWorld(); weWorld = ((Player) actor).getWorld();
} else { } else {
@NotNull Location loc = plotPlayer.getLocation(); @NotNull Location loc = plotPlayer.getLocation();
String world = loc.getWorld(); String world = loc.getWorldName();
weWorld = getWorld(world); weWorld = getWorld(world);
} }
return weWorld; return weWorld;

View File

@ -155,9 +155,9 @@ public abstract class RegionManager {
final Pattern blocks, int minY, int maxY) { final Pattern blocks, int minY, int maxY) {
LocalBlockQueue queue = area.getQueue(false); LocalBlockQueue queue = area.getQueue(false);
for (CuboidRegion region : regions) { for (CuboidRegion region : regions) {
Location pos1 = new Location(area.getWorldName(), region.getMinimumPoint().getX(), minY, Location pos1 = Location.at(area.getWorldName(), region.getMinimumPoint().getX(), minY,
region.getMinimumPoint().getZ()); region.getMinimumPoint().getZ());
Location pos2 = new Location(area.getWorldName(), region.getMaximumPoint().getX(), maxY, Location pos2 = Location.at(area.getWorldName(), region.getMaximumPoint().getX(), maxY,
region.getMaximumPoint().getZ()); region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }

View File

@ -87,7 +87,7 @@ public class WEManager {
HashSet<CuboidRegion> regions = new HashSet<>(); HashSet<CuboidRegion> regions = new HashSet<>();
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
Location location = player.getLocation(); Location location = player.getLocation();
String world = location.getWorld(); String world = location.getWorldName();
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
regions.add(RegionUtil regions.add(RegionUtil
.createRegion(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, .createRegion(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE,

View File

@ -151,7 +151,7 @@ public abstract class WorldUtil {
int trx = top.getX() >> 9; int trx = top.getX() >> 9;
int trz = top.getZ() >> 9; int trz = top.getZ() >> 9;
Set<BlockVector2> files = Set<BlockVector2> files =
RegionManager.manager.getChunkChunks(bot.getWorld()); RegionManager.manager.getChunkChunks(bot.getWorldName());
for (BlockVector2 mca : files) { for (BlockVector2 mca : files) {
if (mca.getX() >= brx && mca.getX() <= trx && mca.getZ() >= brz if (mca.getX() >= brx && mca.getX() <= trx && mca.getZ() >= brz
&& mca.getZ() <= trz) { && mca.getZ() <= trz) {