mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Finalize immutable locations and add a platform world implementation
This commit is contained in:
parent
cf1b027db9
commit
5341015cb1
@ -50,6 +50,7 @@ import com.plotsquared.bukkit.util.BukkitRegionManager;
|
||||
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
||||
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitWorld;
|
||||
import com.plotsquared.bukkit.util.SetGenCB;
|
||||
import com.plotsquared.bukkit.util.UpdateUtility;
|
||||
import com.plotsquared.bukkit.uuid.BungeePermsUUIDService;
|
||||
@ -1168,4 +1169,8 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
return this.playerManager;
|
||||
}
|
||||
|
||||
@Override @NotNull public com.plotsquared.core.location.World<?> getPlatformWorld(@NotNull final String worldName) {
|
||||
return BukkitWorld.of(worldName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -150,23 +150,23 @@ public class ChunkListener implements Listener {
|
||||
int z = chunkZ << 4;
|
||||
int x2 = x + 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()) {
|
||||
return true;
|
||||
}
|
||||
plot = new Location(world, x2, 1, z2).getOwnedPlotAbs();
|
||||
plot = Location.at(world, x2, 1, z2).getOwnedPlotAbs();
|
||||
if (plot != null && plot.hasOwner()) {
|
||||
return true;
|
||||
}
|
||||
plot = new Location(world, x2, 1, z).getOwnedPlotAbs();
|
||||
plot = Location.at(world, x2, 1, z).getOwnedPlotAbs();
|
||||
if (plot != null && plot.hasOwner()) {
|
||||
return true;
|
||||
}
|
||||
plot = new Location(world, x, 1, z2).getOwnedPlotAbs();
|
||||
plot = Location.at(world, x, 1, z2).getOwnedPlotAbs();
|
||||
if (plot != null && plot.hasOwner()) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ public class PaperListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Location location = BukkitUtil.getLocation(entity);
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return;
|
||||
}
|
||||
PlotPlayer<?> pp = BukkitUtil.getPlayer((Player) shooter);
|
||||
|
@ -256,7 +256,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||
Location location = player.getLocation();
|
||||
if (location.getWorld().equals(world)) {
|
||||
if (location.getWorldName().equals(world)) {
|
||||
if (16 * Math.abs(location.getX() - x) / 16 > distance
|
||||
|| 16 * Math.abs(location.getZ() - z) / 16 > distance) {
|
||||
continue;
|
||||
@ -455,16 +455,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
switch (piston.getFacing()) {
|
||||
case EAST:
|
||||
location.setX(location.getX() + 1);
|
||||
location = location.add(1, 0, 0);
|
||||
break;
|
||||
case SOUTH:
|
||||
location.setX(location.getX() - 1);
|
||||
location = location.add(-1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
location.setZ(location.getZ() + 1);
|
||||
location = location.add(0, 0, 1);
|
||||
break;
|
||||
case NORTH:
|
||||
location.setZ(location.getZ() - 1);
|
||||
location = location.add(0, 0, -1);
|
||||
break;
|
||||
}
|
||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||
@ -490,7 +490,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Location location = BukkitUtil.getLocation(entity);
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return;
|
||||
}
|
||||
PlotPlayer<Player> pp = BukkitUtil.getPlayer((Player) shooter);
|
||||
@ -504,7 +504,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@EventHandler public boolean onProjectileHit(ProjectileHitEvent event) {
|
||||
Projectile entity = event.getEntity();
|
||||
Location location = BukkitUtil.getLocation(entity);
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return true;
|
||||
}
|
||||
PlotArea area = location.getPlotArea();
|
||||
@ -1078,7 +1078,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
PlotArea area = location.getPlotArea();
|
||||
boolean plotArea = location.isPlotArea();
|
||||
if (!plotArea) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
@ -1505,7 +1505,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return;
|
||||
}
|
||||
for (Block block1 : event.getBlocks()) {
|
||||
@ -1542,7 +1542,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return;
|
||||
}
|
||||
if (this.pistonBlocks) {
|
||||
@ -1840,7 +1840,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
public void onPotionSplash(LingeringPotionSplashEvent event) {
|
||||
Projectile entity = event.getEntity();
|
||||
Location location = BukkitUtil.getLocation(entity);
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return;
|
||||
}
|
||||
if (!this.onProjectileHit(event)) {
|
||||
@ -1907,7 +1907,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
public void onBigBoom(BlockExplodeEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
String world = location.getWorld();
|
||||
String world = location.getWorldName();
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
return;
|
||||
}
|
||||
@ -2707,7 +2707,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
public void onPotionSplash(PotionSplashEvent event) {
|
||||
ThrownPotion damager = event.getPotion();
|
||||
Location location = BukkitUtil.getLocation(damager);
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
@ -2737,7 +2737,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||
Entity damager = event.getDamager();
|
||||
Location location = BukkitUtil.getLocation(damager);
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) {
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
||||
return;
|
||||
}
|
||||
Entity victim = event.getEntity();
|
||||
|
@ -241,7 +241,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
return;
|
||||
}
|
||||
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());
|
||||
PaperLib.teleportAsync(player, bukkitLocation, getTeleportCause(cause));
|
||||
}
|
||||
@ -259,7 +259,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
|
||||
@Override public void setCompassTarget(Location location) {
|
||||
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()));
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
@Getter @Setter private ChunkData chunkData = null;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -196,11 +196,11 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
}
|
||||
|
||||
@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() {
|
||||
return new Location(getWorld(), getX() << 4, 0, getZ() << 4);
|
||||
return Location.at(getWorld(), getX() << 4, 0, getZ() << 4);
|
||||
}
|
||||
|
||||
public GenChunk clone() {
|
||||
|
@ -198,9 +198,9 @@ public class BukkitRegionManager extends RegionManager {
|
||||
|
||||
final CuboidRegion region =
|
||||
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 World newWorld = Bukkit.getWorld(newPos.getWorld());
|
||||
final World newWorld = Bukkit.getWorld(newPos.getWorldName());
|
||||
assert newWorld != null;
|
||||
assert oldWorld != null;
|
||||
final String newWorldName = newWorld.getName();
|
||||
@ -248,7 +248,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
@Override
|
||||
public boolean regenerateRegion(final Location pos1, final Location pos2,
|
||||
final boolean ignoreAugment, final Runnable whenDone) {
|
||||
final String world = pos1.getWorld();
|
||||
final String world = pos1.getWorldName();
|
||||
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
@ -401,7 +401,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
}
|
||||
|
||||
@Override public void clearAllEntities(Location pos1, Location pos2) {
|
||||
String world = pos1.getWorld();
|
||||
String world = pos1.getWorldName();
|
||||
List<Entity> entities = BukkitUtil.getEntities(world);
|
||||
int bx = pos1.getX();
|
||||
int bz = pos1.getZ();
|
||||
@ -428,8 +428,8 @@ public class BukkitRegionManager extends RegionManager {
|
||||
RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
|
||||
CuboidRegion region2 =
|
||||
RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
|
||||
final World world1 = Bukkit.getWorld(bot1.getWorld());
|
||||
final World world2 = Bukkit.getWorld(bot2.getWorld());
|
||||
final World world1 = Bukkit.getWorld(bot1.getWorldName());
|
||||
final World world2 = Bukkit.getWorld(bot2.getWorldName());
|
||||
checkNotNull(world1, "Critical error during swap.");
|
||||
checkNotNull(world2, "Critical error during swap.");
|
||||
int relX = bot2.getX() - bot1.getX();
|
||||
@ -456,9 +456,9 @@ public class BukkitRegionManager extends RegionManager {
|
||||
@Override
|
||||
public void setBiome(final CuboidRegion region, final int extendBiome, final BiomeType biome,
|
||||
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);
|
||||
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);
|
||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
|
||||
|
@ -276,18 +276,18 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
public static Location getLocation(@NonNull final org.bukkit.Location location) {
|
||||
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
|
||||
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()));
|
||||
return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
|
||||
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()));
|
||||
}
|
||||
|
||||
public static Location getLocationFull(@NonNull final org.bukkit.Location location) {
|
||||
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
|
||||
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
|
||||
return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
|
||||
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
|
||||
location.getPitch());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@ -311,13 +311,13 @@ public class BukkitUtil extends WorldUtil {
|
||||
public static Location getLocation(@NonNull final Entity entity) {
|
||||
final org.bukkit.Location location = entity.getLocation();
|
||||
String world = location.getWorld().getName();
|
||||
return new Location(world, location.getBlockX(), location.getBlockY(),
|
||||
return Location.at(world, location.getBlockX(), location.getBlockY(),
|
||||
location.getBlockZ());
|
||||
}
|
||||
|
||||
@NotNull public static Location getLocationFull(@NonNull final Entity entity) {
|
||||
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(),
|
||||
location.getPitch());
|
||||
}
|
||||
@ -409,7 +409,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@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());
|
||||
return TaskManager.IMP.sync(new RunnableVal<String[]>() {
|
||||
@Override public void run(String[] value) {
|
||||
@ -423,12 +423,12 @@ public class BukkitUtil extends WorldUtil {
|
||||
|
||||
@Override public Location getSpawn(@NonNull final String world) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override public void setSpawn(@NonNull final Location location) {
|
||||
final World world = getWorld(location.getWorld());
|
||||
final World world = getWorld(location.getWorldName());
|
||||
if (world != null) {
|
||||
world.setSpawnLocation(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
@ -526,14 +526,14 @@ public class BukkitUtil extends WorldUtil {
|
||||
@Override
|
||||
public void getBlock(@NonNull final Location location, final Consumer<BlockState> result) {
|
||||
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());
|
||||
result.accept(BukkitAdapter.asBlockType(block.getType()).getDefaultState());
|
||||
});
|
||||
}
|
||||
|
||||
@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());
|
||||
return BukkitAdapter.asBlockType(block.getType()).getDefaultState();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -29,6 +29,7 @@ import com.plotsquared.core.backup.BackupManager;
|
||||
import com.plotsquared.core.generator.GeneratorWrapper;
|
||||
import com.plotsquared.core.generator.HybridUtils;
|
||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||
import com.plotsquared.core.location.World;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.queue.QueueProvider;
|
||||
import com.plotsquared.core.util.ChatManager;
|
||||
@ -302,4 +303,12 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
*/
|
||||
@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);
|
||||
|
||||
}
|
||||
|
@ -129,13 +129,13 @@ import java.util.zip.ZipInputStream;
|
||||
* An implementation of the core, with a static getter for easy access.
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess"})
|
||||
public class PlotSquared<P> {
|
||||
public class PlotSquared {
|
||||
|
||||
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
||||
private static PlotSquared<?> instance;
|
||||
private static PlotSquared instance;
|
||||
|
||||
// Implementation
|
||||
private final PlotPlatform<P> platform;
|
||||
private final PlotPlatform<?> platform;
|
||||
// Current thread
|
||||
private final Thread thread;
|
||||
// UUID pipelines
|
||||
@ -174,7 +174,7 @@ public class PlotSquared<P> {
|
||||
* @param iPlotMain Implementation of {@link PlotPlatform} 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) {
|
||||
throw new IllegalStateException("Cannot re-initialize the PlotSquared singleton");
|
||||
}
|
||||
@ -375,11 +375,10 @@ public class PlotSquared<P> {
|
||||
*
|
||||
* @return instance of PlotSquared
|
||||
*/
|
||||
public static PlotSquared<?> get() {
|
||||
public static PlotSquared get() {
|
||||
return PlotSquared.instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the platform specific implementation of PlotSquared
|
||||
*
|
||||
@ -1700,7 +1699,7 @@ public class PlotSquared<P> {
|
||||
*/
|
||||
public boolean isNonStandardGeneration(@NotNull final String world,
|
||||
@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);
|
||||
if (area == null) {
|
||||
return true;
|
||||
|
@ -104,7 +104,7 @@ public class Area extends SubCommand {
|
||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NEEDS_NAME);
|
||||
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])) {
|
||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NAME_TAKEN);
|
||||
return false;
|
||||
@ -139,7 +139,7 @@ public class Area extends SubCommand {
|
||||
BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ()));
|
||||
// There's only one plot in the area...
|
||||
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);
|
||||
// Plot size is the same as the region width
|
||||
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
|
||||
@ -462,7 +462,7 @@ public class Area extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
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()),
|
||||
TeleportCause.COMMAND);
|
||||
}
|
||||
@ -648,15 +648,13 @@ public class Area extends SubCommand {
|
||||
player.teleport(center, TeleportCause.COMMAND);
|
||||
} else {
|
||||
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,
|
||||
0, region.getMinimumPoint().getZ()
|
||||
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
|
||||
WorldUtil.IMP
|
||||
.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y -> {
|
||||
center.setY(1 + y);
|
||||
player.teleport(center, TeleportCause.COMMAND);
|
||||
});
|
||||
.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y ->
|
||||
player.teleport(center.withY(1 + y), TeleportCause.COMMAND));
|
||||
}
|
||||
return true;
|
||||
case "delete":
|
||||
|
@ -74,7 +74,7 @@ public class Claim extends SubCommand {
|
||||
boolean force = event.getEventResult() == Result.FORCE;
|
||||
int currentPlots = Settings.Limit.GLOBAL ?
|
||||
player.getPlotCount() :
|
||||
player.getPlotCount(location.getWorld());
|
||||
player.getPlotCount(location.getWorldName());
|
||||
int grants = 0;
|
||||
if (currentPlots >= player.getAllowedPlots() && !force) {
|
||||
if (player.hasPersistentMeta("grantedPlots")) {
|
||||
|
@ -117,7 +117,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
int currentClusters = Settings.Limit.GLOBAL ?
|
||||
player.getClusterCount() :
|
||||
player.getPlotCount(player.getLocation().getWorld());
|
||||
player.getPlotCount(player.getLocation().getWorldName());
|
||||
if (currentClusters >= player.getAllowedPlots()) {
|
||||
return sendMessage(player, Captions.CANT_CLAIM_MORE_CLUSTERS);
|
||||
}
|
||||
@ -173,7 +173,7 @@ public class Cluster extends SubCommand {
|
||||
if (Settings.Limit.GLOBAL) {
|
||||
current = player.getPlayerClusterCount();
|
||||
} else {
|
||||
current = player.getPlayerClusterCount(player.getLocation().getWorld());
|
||||
current = player.getPlayerClusterCount(player.getLocation().getWorldName());
|
||||
}
|
||||
int allowed = Permissions
|
||||
.hasPermissionRange(player, Captions.PERMISSION_CLUSTER_SIZE,
|
||||
@ -324,7 +324,7 @@ public class Cluster extends SubCommand {
|
||||
if (Settings.Limit.GLOBAL) {
|
||||
current = player.getPlayerClusterCount();
|
||||
} 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);
|
||||
int allowed = Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER,
|
||||
@ -454,7 +454,7 @@ public class Cluster extends SubCommand {
|
||||
cluster.getName());
|
||||
}
|
||||
for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation()
|
||||
.getWorld()).ownedBy(uuid).asCollection()) {
|
||||
.getWorldName()).ownedBy(uuid).asCollection()) {
|
||||
PlotCluster current = plot.getCluster();
|
||||
if (current != null && current.equals(cluster)) {
|
||||
plot.unclaim();
|
||||
@ -512,7 +512,7 @@ public class Cluster extends SubCommand {
|
||||
cluster.invited.remove(uuid);
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
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()) {
|
||||
PlotCluster current = plot.getCluster();
|
||||
if (current != null && current.equals(cluster)) {
|
||||
|
@ -86,7 +86,7 @@ public class Comment extends SubCommand {
|
||||
|
||||
String message = StringMan.join(Arrays.copyOfRange(args, index, args.length), " ");
|
||||
PlotComment comment =
|
||||
new PlotComment(player.getLocation().getWorld(), plot.getId(), message,
|
||||
new PlotComment(player.getLocation().getWorldName(), plot.getId(), message,
|
||||
player.getName(), inbox.toString(), System.currentTimeMillis());
|
||||
boolean result = inbox.addComment(plot, comment);
|
||||
if (!result) {
|
||||
|
@ -63,7 +63,7 @@ public class Debug extends SubCommand {
|
||||
MainUtil.sendMessage(player, "Fetching loaded chunks...");
|
||||
TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player,
|
||||
"Loaded chunks: " + RegionManager.manager
|
||||
.getChunkChunks(player.getLocation().getWorld()).size() + "(" + (
|
||||
.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + (
|
||||
System.currentTimeMillis() - start) + "ms) using thread: " + Thread
|
||||
.currentThread().getName()));
|
||||
return true;
|
||||
|
@ -77,7 +77,7 @@ public class Delete extends SubCommand {
|
||||
final java.util.Set<Plot> plots = plot.getConnectedPlots();
|
||||
final int currentPlots = Settings.Limit.GLOBAL ?
|
||||
player.getPlotCount() :
|
||||
player.getPlotCount(location.getWorld());
|
||||
player.getPlotCount(location.getWorldName());
|
||||
Runnable run = () -> {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
|
@ -133,7 +133,7 @@ public class Deny extends SubCommand {
|
||||
player.stopSpectating();
|
||||
}
|
||||
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);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn =
|
||||
|
@ -51,7 +51,7 @@ import java.net.URL;
|
||||
public class Download extends SubCommand {
|
||||
|
||||
@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)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class Kick extends SubCommand {
|
||||
Captions.CANNOT_KICK_PLAYER.send(player, player2.getName());
|
||||
return;
|
||||
}
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
|
||||
Captions.YOU_GOT_KICKED.send(player2);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP
|
||||
|
@ -138,7 +138,7 @@ public class ListCmd extends SubCommand {
|
||||
page = 0;
|
||||
}
|
||||
|
||||
String world = player.getLocation().getWorld();
|
||||
String world = player.getLocation().getWorldName();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
String arg = args[0].toLowerCase();
|
||||
final boolean[] sort = new boolean[] {true};
|
||||
|
@ -53,7 +53,7 @@ import java.util.List;
|
||||
public class Load extends SubCommand {
|
||||
|
||||
@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)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ import java.util.UUID;
|
||||
public class Save extends SubCommand {
|
||||
|
||||
@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)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
@ -77,8 +77,8 @@ public class Save extends SubCommand {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
String time = (System.currentTimeMillis() / 1000) + "";
|
||||
Location[] corners = plot.getCorners();
|
||||
corners[0].setY(0);
|
||||
corners[1].setY(255);
|
||||
corners[0] = corners[0].withY(0);
|
||||
corners[1] = corners[1].withY(255);
|
||||
int size = (corners[1].getX() - corners[0].getX()) + 1;
|
||||
PlotId id = plot.getId();
|
||||
String world1 = plot.getArea().toString().replaceAll(";", "-")
|
||||
|
@ -54,7 +54,7 @@ public class Target extends SubCommand {
|
||||
Plot target = null;
|
||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||
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);
|
||||
if (current < distance) {
|
||||
distance = (int) current;
|
||||
|
@ -153,8 +153,8 @@ public class AugmentedUtils {
|
||||
secondaryMask.setForceSync(true);
|
||||
|
||||
ScopedLocalBlockQueue scoped =
|
||||
new ScopedLocalBlockQueue(secondaryMask, new Location(world, blockX, 0, blockZ),
|
||||
new Location(world, blockX + 15, 255, blockZ + 15));
|
||||
new ScopedLocalBlockQueue(secondaryMask, Location.at(world, blockX, 0, blockZ),
|
||||
Location.at(world, blockX + 15, 255, blockZ + 15));
|
||||
generator.generateChunk(scoped, area);
|
||||
generator.populateChunk(scoped, area);
|
||||
}
|
||||
|
@ -192,10 +192,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
if (plot.isBasePlot()) {
|
||||
for (CuboidRegion region : plot.getRegions()) {
|
||||
Location pos1 =
|
||||
new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
|
||||
Location.at(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
|
||||
maxY, region.getMinimumPoint().getZ());
|
||||
Location pos2 =
|
||||
new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
|
||||
Location.at(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
|
||||
maxY, region.getMaximumPoint().getZ());
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
@ -314,31 +314,31 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int ez = pos2.getZ() + 2;
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
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),
|
||||
new Location(classicPlotWorld.getWorldName(), ex, maxY, ez - 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, maxY, ez - 1),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 0, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), ex, 0, ez - 1),
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 0, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, 0, ez - 1),
|
||||
BlockUtil.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1),
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1),
|
||||
classicPlotWorld.WALL_FILLING.toPattern());
|
||||
queue.setCuboid(
|
||||
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 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());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), ex, 1, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1),
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), ex, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1),
|
||||
classicPlotWorld.WALL_FILLING.toPattern());
|
||||
queue.setCuboid(
|
||||
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 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());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
}
|
||||
@ -351,32 +351,32 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int sx = pos1.getX() - 2;
|
||||
int ex = pos2.getX() + 2;
|
||||
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),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1,
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 0, sz),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, 0, ez),
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 0, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, 0, ez),
|
||||
BlockUtil.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz),
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz),
|
||||
classicPlotWorld.WALL_FILLING.toPattern());
|
||||
queue.setCuboid(
|
||||
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
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());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, ez),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez),
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, ez),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez),
|
||||
classicPlotWorld.WALL_FILLING.toPattern());
|
||||
queue.setCuboid(
|
||||
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
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());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
}
|
||||
@ -389,15 +389,15 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
queue.setCuboid(
|
||||
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1,
|
||||
sz + 1), new Location(classicPlotWorld.getWorldName(), ex - 1,
|
||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1,
|
||||
sz + 1), Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 0, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, 0, ez - 1),
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 0, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, 0, ez - 1),
|
||||
BlockUtil.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
}
|
||||
@ -410,17 +410,17 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int sz = pos1.getZ() - 1;
|
||||
int ez = pos2.getZ() + 1;
|
||||
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),
|
||||
new Location(classicPlotWorld.getWorldName(), ex,
|
||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1,
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1,
|
||||
ez - 1), classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||
queue.setCuboid(
|
||||
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
|
||||
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez - 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez - 1),
|
||||
classicPlotWorld.TOP_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
}
|
||||
@ -433,17 +433,17 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int sx = pos1.getX() - 1;
|
||||
int ex = pos2.getX() + 1;
|
||||
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),
|
||||
new Location(classicPlotWorld.getWorldName(), ex,
|
||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1,
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1,
|
||||
ez), classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||
queue.setCuboid(
|
||||
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT, ez),
|
||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT, ez),
|
||||
classicPlotWorld.TOP_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
}
|
||||
@ -455,17 +455,17 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int sz = location.getZ() + 1;
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
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),
|
||||
new Location(classicPlotWorld.getWorldName(), ex,
|
||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz),
|
||||
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez),
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez),
|
||||
classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||
queue.setCuboid(
|
||||
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez),
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez),
|
||||
classicPlotWorld.TOP_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
}
|
||||
@ -529,8 +529,8 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
*/
|
||||
@Override public Location getSignLoc(Plot plot) {
|
||||
plot = plot.getBasePlot(false);
|
||||
Location bot = plot.getBottomAbs();
|
||||
return new Location(classicPlotWorld.getWorldName(), bot.getX() - 1,
|
||||
final Location bot = plot.getBottomAbs();
|
||||
return Location.at(classicPlotWorld.getWorldName(), bot.getX() - 1,
|
||||
classicPlotWorld.ROAD_HEIGHT + 1, bot.getZ() - 2);
|
||||
}
|
||||
|
||||
|
@ -103,9 +103,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
PlotId id2 = new PlotId(id.x + 1, id.y);
|
||||
Location bot = getPlotBottomLocAbs(id2);
|
||||
Location top = getPlotTopLocAbs(id);
|
||||
Location pos1 =
|
||||
new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
|
||||
Location pos2 = new Location(hybridPlotWorld.getWorldName(), bot.getX(),
|
||||
Location pos1 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
|
||||
Location pos2 = Location.at(hybridPlotWorld.getWorldName(), bot.getX(),
|
||||
Math.min(getWorldHeight(), 255), top.getZ() + 1);
|
||||
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
|
||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
@ -163,9 +162,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||
Location bot = getPlotBottomLocAbs(id2);
|
||||
Location top = getPlotTopLocAbs(id);
|
||||
Location pos1 =
|
||||
new Location(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
|
||||
Location pos2 = new Location(hybridPlotWorld.getWorldName(), top.getX() + 1,
|
||||
Location pos1 = Location.at(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
|
||||
Location pos2 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1,
|
||||
Math.min(getWorldHeight(), 255), bot.getZ());
|
||||
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
|
||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
@ -181,10 +179,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
super.createRoadSouthEast(plot);
|
||||
PlotId id = plot.getId();
|
||||
PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
||||
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1);
|
||||
Location pos2 = getPlotBottomLocAbs(id2);
|
||||
pos1.setY(0);
|
||||
pos2.setY(Math.min(getWorldHeight(), 255));
|
||||
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
|
||||
Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
|
||||
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
||||
createSchemAbs(queue, pos1, pos2);
|
||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
@ -239,18 +235,18 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
// Set the 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)
|
||||
Location bot = new Location(world, value[2], 0, value[3]);
|
||||
Location top = new Location(world, value[4], 1, value[5]);
|
||||
Location bot = Location.at(world, value[2], 0, value[3]);
|
||||
Location top = Location.at(world, value[4], 1, value[5]);
|
||||
queue.setCuboid(bot, top, bedrock);
|
||||
// Each component has a different layer
|
||||
bot.setY(1);
|
||||
top.setY(hybridPlotWorld.PLOT_HEIGHT);
|
||||
bot = bot.withY(1);
|
||||
top = top.withY(hybridPlotWorld.PLOT_HEIGHT);
|
||||
queue.setCuboid(bot, top, filling);
|
||||
bot.setY(hybridPlotWorld.PLOT_HEIGHT);
|
||||
top.setY(hybridPlotWorld.PLOT_HEIGHT + 1);
|
||||
bot = bot.withY(hybridPlotWorld.PLOT_HEIGHT);
|
||||
top = top.withY(hybridPlotWorld.PLOT_HEIGHT + 1);
|
||||
queue.setCuboid(bot, top, plotfloor);
|
||||
bot.setY(hybridPlotWorld.PLOT_HEIGHT + 1);
|
||||
top.setY(getWorldHeight());
|
||||
bot = bot.withY(hybridPlotWorld.PLOT_HEIGHT + 1);
|
||||
top = top.withY(getWorldHeight());
|
||||
queue.setCuboid(bot, top, air);
|
||||
// And finally set the schematic, the y value is unimportant for this function
|
||||
pastePlotSchematic(queue, bot, top);
|
||||
|
@ -128,15 +128,13 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
return new HybridPlotManager(this);
|
||||
}
|
||||
|
||||
public Location getSignLocation(Plot plot) {
|
||||
public Location getSignLocation(@NotNull Plot plot) {
|
||||
plot = plot.getBasePlot(false);
|
||||
Location bot = plot.getBottomAbs();
|
||||
final Location bot = plot.getBottomAbs();
|
||||
if (SIGN_LOCATION == null) {
|
||||
bot.setY(ROAD_HEIGHT + 1);
|
||||
return bot.add(-1, 0, -2);
|
||||
return bot.withY(ROAD_HEIGHT + 1).add(-1, 0, -2);
|
||||
} else {
|
||||
bot.setY(0);
|
||||
return bot.add(SIGN_LOCATION.getX(), SIGN_LOCATION.getY(), SIGN_LOCATION.getZ());
|
||||
return bot.withY(0).add(SIGN_LOCATION.getX(), SIGN_LOCATION.getY(), SIGN_LOCATION.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,8 +222,8 @@ public abstract class HybridUtils {
|
||||
});
|
||||
System.gc();
|
||||
MainUtil.initCache();
|
||||
Location botLoc = new Location(world, bot.getX(), bot.getY(), bot.getZ());
|
||||
Location topLoc = new Location(world, top.getX(), top.getY(), top.getZ());
|
||||
Location botLoc = Location.at(world, bot.getX(), bot.getY(), bot.getZ());
|
||||
Location topLoc = Location.at(world, top.getX(), top.getY(), top.getZ());
|
||||
ChunkManager.chunkTask(botLoc, topLoc, new RunnableVal<int[]>() {
|
||||
@Override public void run(int[] value) {
|
||||
int X = value[0];
|
||||
|
@ -36,12 +36,13 @@ import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class SingleWorldGenerator extends IndependentPlotGenerator {
|
||||
private Location bedrock1 = new Location(null, 0, 0, 0);
|
||||
private Location bedrock2 = new Location(null, 15, 0, 15);
|
||||
private Location dirt1 = new Location(null, 0, 1, 0);
|
||||
private Location dirt2 = new Location(null, 15, 2, 15);
|
||||
private Location grass1 = new Location(null, 0, 3, 0);
|
||||
private Location grass2 = new Location(null, 15, 3, 15);
|
||||
|
||||
private static final Location bedrock1 = Location.at("", 0, 0, 0);
|
||||
private static final Location bedrock2 = Location.at("", 15, 0, 15);
|
||||
private static final Location dirt1 = Location.at("", 0, 1, 0);
|
||||
private static final Location dirt2 = Location.at("", 15, 2, 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() {
|
||||
return "PlotSquared:single";
|
||||
|
@ -62,10 +62,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
Iterator<CuboidRegion> iterator = regions.iterator();
|
||||
CuboidRegion region = iterator.next();
|
||||
iterator.remove();
|
||||
Location pos1 = new Location(plot.getWorldName(), region.getMinimumPoint().getX(),
|
||||
region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
|
||||
Location pos2 = new Location(plot.getWorldName(), region.getMaximumPoint().getX(),
|
||||
region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
|
||||
final Location pos1 = Location.at(plot.getWorldName(), region.getMinimumPoint());
|
||||
final Location pos2 = Location.at(plot.getWorldName(), region.getMaximumPoint());
|
||||
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;
|
||||
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
|
||||
+ 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) {
|
||||
@ -247,7 +245,6 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
|
||||
+ squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math
|
||||
.floor(squarePlotWorld.ROAD_WIDTH / 2);
|
||||
return new Location(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(),
|
||||
z);
|
||||
return Location.at(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), z);
|
||||
}
|
||||
}
|
||||
|
@ -41,15 +41,15 @@ import org.khelekore.prtree.SimpleMBR;
|
||||
/**
|
||||
* An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@EqualsAndHashCode @SuppressWarnings("unused")
|
||||
public final class Location implements Comparable<Location> {
|
||||
|
||||
@Getter private final float yaw;
|
||||
@Getter private final float pitch;
|
||||
@Getter private final String world;
|
||||
@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) {
|
||||
this.world = Preconditions.checkNotNull(world, "World 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;
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
@ -113,6 +126,80 @@ public final class Location implements Comparable<Location> {
|
||||
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
|
||||
*
|
||||
|
84
Core/src/main/java/com/plotsquared/core/location/World.java
Normal file
84
Core/src/main/java/com/plotsquared/core/location/World.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -56,11 +56,11 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||
Location location;
|
||||
if (area != null) {
|
||||
CuboidRegion region = area.getRegion();
|
||||
location = new Location(area.getWorldName(),
|
||||
location = Location.at(area.getWorldName(),
|
||||
region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0,
|
||||
region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2);
|
||||
} else {
|
||||
location = new Location("world", 0, 0, 0);
|
||||
location = Location.at("world", 0, 0, 0);
|
||||
}
|
||||
setMeta("location", location);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
*/
|
||||
public int getPlotCount() {
|
||||
if (!Settings.Limit.GLOBAL) {
|
||||
return getPlotCount(getLocation().getWorld());
|
||||
return getPlotCount(getLocation().getWorldName());
|
||||
}
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
final UUID uuid = getUUID();
|
||||
@ -286,7 +286,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
|
||||
public int getClusterCount() {
|
||||
if (!Settings.Limit.GLOBAL) {
|
||||
return getClusterCount(getLocation().getWorld());
|
||||
return getClusterCount(getLocation().getWorldName());
|
||||
}
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> {
|
||||
|
@ -1442,7 +1442,7 @@ public class Plot {
|
||||
return this.getDefaultHomeSynchronous(true);
|
||||
} else {
|
||||
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(),
|
||||
home.getPitch());
|
||||
if (!isLoaded()) {
|
||||
@ -1466,7 +1466,7 @@ public class Plot {
|
||||
this.getDefaultHome(result);
|
||||
} else {
|
||||
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(),
|
||||
home.getPitch());
|
||||
if (!isLoaded()) {
|
||||
@ -1850,7 +1850,7 @@ public class Plot {
|
||||
*/
|
||||
public void getBiome(Consumer<BiomeType> result) {
|
||||
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() {
|
||||
final Location location = this.getCenterSynchronous();
|
||||
return WorldUtil.IMP
|
||||
.getBiomeSynchronous(location.getWorld(), location.getX(), location.getZ());
|
||||
.getBiomeSynchronous(location.getWorldName(), location.getX(), location.getZ());
|
||||
}
|
||||
|
||||
//TODO Better documentation needed.
|
||||
|
@ -585,7 +585,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.RegionUtil;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
@ -151,17 +152,17 @@ public class PlotCluster {
|
||||
+ this.pos2.y;
|
||||
}
|
||||
|
||||
public void getHome(Consumer<Location> result) {
|
||||
BlockLoc home = this.settings.getPosition();
|
||||
Consumer<Location> locationConsumer = toReturn -> {
|
||||
public void getHome(@NotNull final Consumer<Location> result) {
|
||||
final BlockLoc home = this.settings.getPosition();
|
||||
Consumer<Location> locationConsumer = toReturn ->
|
||||
MainUtil.getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(),
|
||||
max -> {
|
||||
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) {
|
||||
// default pos
|
||||
Plot center = getCenterPlot();
|
||||
@ -170,7 +171,7 @@ public class PlotCluster {
|
||||
if (toReturn.getY() == 0) {
|
||||
PlotManager manager = this.area.getPlotManager();
|
||||
Location locationSign = manager.getSignLoc(center);
|
||||
toReturn.setY(locationSign.getY());
|
||||
toReturn = toReturn.withY(locationSign.getY());
|
||||
}
|
||||
locationConsumer.accept(toReturn);
|
||||
});
|
||||
|
@ -58,7 +58,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
||||
if (location == null) {
|
||||
return null;
|
||||
}
|
||||
final PlotWorld world = this.plotWorlds.get(location.getWorld());
|
||||
final PlotWorld world = this.plotWorlds.get(location.getWorldName());
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -156,23 +156,23 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
}
|
||||
|
||||
@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);
|
||||
return plot == null ? null : plot.getBasePlot(false);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
if (location == null) {
|
||||
return null;
|
||||
}
|
||||
String world = location.getWorld();
|
||||
String world = location.getWorldName();
|
||||
return isWorld(world) || world.equals("*") || super.getAllPlotAreas().length == 0 ?
|
||||
area :
|
||||
super.getApplicablePlotArea(location);
|
||||
@ -118,7 +118,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
if (found != null) {
|
||||
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) {
|
||||
|
@ -35,6 +35,7 @@ import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.SetupUtils;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -52,12 +53,12 @@ public class SinglePlotManager extends PlotManager {
|
||||
return new PlotId(0, 0);
|
||||
}
|
||||
|
||||
@Override public Location getPlotBottomLocAbs(PlotId plotId) {
|
||||
return new Location(plotId.toCommaSeparatedString(), -30000000, 0, -30000000);
|
||||
@Override public Location getPlotBottomLocAbs(@NotNull final PlotId plotId) {
|
||||
return Location.at(plotId.toCommaSeparatedString(), -30000000, 0, -30000000);
|
||||
}
|
||||
|
||||
@Override public Location getPlotTopLocAbs(PlotId plotId) {
|
||||
return new Location(plotId.toCommaSeparatedString(), 30000000, 0, 30000000);
|
||||
@Override public Location getPlotTopLocAbs(@NotNull final PlotId plotId) {
|
||||
return Location.at(plotId.toCommaSeparatedString(), 30000000, 0, 30000000);
|
||||
}
|
||||
|
||||
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) {
|
||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -46,7 +47,7 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
||||
private final BlockVector3 top;
|
||||
|
||||
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.length = top.getZ() - bot.getZ() + 1;
|
||||
this.area = width * length;
|
||||
@ -113,15 +114,15 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override @Nullable public String getWorld() {
|
||||
return null;
|
||||
@Override @NotNull public String getWorld() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@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() {
|
||||
return new Location(getWorld(), bot.getX(), bot.getY(), bot.getZ());
|
||||
return Location.at(getWorld(), bot.getX(), bot.getY(), bot.getZ());
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public abstract class LocalBlockQueue {
|
||||
|
||||
for (final PlotPlayer pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||
Location pLoc = pp.getLocation();
|
||||
if (!StringMan.isEqual(getWorld(), pLoc.getWorld()) || !pLoc.getChunkLocation()
|
||||
if (!StringMan.isEqual(getWorld(), pLoc.getWorldName()) || !pLoc.getChunkLocation()
|
||||
.equals(loc)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||
private final int minX;
|
||||
@ -92,11 +93,11 @@ public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||
}
|
||||
|
||||
public Location getMin() {
|
||||
return new Location(getWorld(), minX, minY, minZ);
|
||||
return Location.at(this.getWorld(), this.minX, this.minY, this.minZ);
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
public void mapByType2D(RunnableVal3<Plot, Integer, Integer> task) {
|
||||
int bx = minX;
|
||||
int bz = minZ;
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(getWorld(), null);
|
||||
Location location = new Location(getWorld(), bx, 0, bz);
|
||||
public void mapByType2D(@NotNull final RunnableVal3<Plot, Integer, Integer> task) {
|
||||
final int bx = minX;
|
||||
final int bz = minZ;
|
||||
final PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(getWorld(), null);
|
||||
final Location location = Location.at(getWorld(), bx, 0, bz);
|
||||
if (area != null) {
|
||||
PlotManager manager = area.getPlotManager();
|
||||
for (int x = 0; x < 16; x++) {
|
||||
location.setX(bx + x);
|
||||
for (int z = 0; z < 16; z++) {
|
||||
location.setZ(bz + z);
|
||||
task.run(area.getPlotAbs(location), x, z);
|
||||
task.run(area.getPlotAbs(location.withX(bx + x).withZ(bz + z)), x, z);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
location.setX(bx + x);
|
||||
for (int z = 0; z < 16; z++) {
|
||||
location.setZ(bz + z);
|
||||
task.run(location.getPlotAbs(), x, z);
|
||||
task.run(location.withX(bx + x).withZ(bz + z).getPlotAbs(), x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ public abstract class ChunkManager {
|
||||
int blockX = loc.getX() << 4;
|
||||
int blockZ = loc.getZ() << 4;
|
||||
ScopedLocalBlockQueue scoped =
|
||||
new ScopedLocalBlockQueue(queue, new Location(world, blockX, 0, blockZ),
|
||||
new Location(world, blockX + 15, 255, blockZ + 15));
|
||||
new ScopedLocalBlockQueue(queue, Location.at(world, blockX, 0, blockZ),
|
||||
Location.at(world, blockX + 15, 255, blockZ + 15));
|
||||
if (force != null) {
|
||||
force.run(scoped);
|
||||
} else {
|
||||
@ -108,9 +108,9 @@ public abstract class ChunkManager {
|
||||
return;
|
||||
}
|
||||
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());
|
||||
Location pos2 = new Location(plot.getWorldName(), value.getMaximumPoint().getX(), 0,
|
||||
Location pos2 = Location.at(plot.getWorldName(), value.getMaximumPoint().getX(), 0,
|
||||
value.getMaximumPoint().getZ());
|
||||
chunkTask(pos1, pos2, task, this, allocate);
|
||||
}
|
||||
@ -191,12 +191,12 @@ public abstract class ChunkManager {
|
||||
int z1 = chunk.getZ() << 4;
|
||||
int x2 = x1 + 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();
|
||||
if (plot != null) {
|
||||
return plot;
|
||||
}
|
||||
Location top = new Location(world, x2, 0, z2);
|
||||
Location top = Location.at(world, x2, 0, z2);
|
||||
plot = top.getOwnedPlotAbs();
|
||||
return plot;
|
||||
}
|
||||
|
@ -397,12 +397,10 @@ public class MainUtil {
|
||||
return plot.getFlag(ServerPlotFlag.class);
|
||||
}
|
||||
|
||||
@NotNull public static Location[] getCorners(String world, CuboidRegion region) {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
Location pos1 = new Location(world, min.getX(), min.getY(), min.getZ());
|
||||
Location pos2 = new Location(world, max.getX(), max.getY(), max.getZ());
|
||||
return new Location[] {pos1, pos2};
|
||||
@NotNull public static Location[] getCorners(@NotNull final String world, @NotNull final CuboidRegion region) {
|
||||
final BlockVector3 min = region.getMinimumPoint();
|
||||
final BlockVector3 max = region.getMaximumPoint();
|
||||
return new Location[] {Location.at(world, min), Location.at(world, max)};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -426,16 +424,16 @@ public class MainUtil {
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
if (pos2.getX() > max.getX()) {
|
||||
max.setX(pos2.getX());
|
||||
max = max.withX(pos2.getX());
|
||||
}
|
||||
if (pos1.getX() < min.getX()) {
|
||||
min.setX(pos1.getX());
|
||||
min = min.withX(pos1.getX());
|
||||
}
|
||||
if (pos2.getZ() > max.getZ()) {
|
||||
max.setZ(pos2.getZ());
|
||||
max = max.withZ(pos2.getZ());
|
||||
}
|
||||
if (pos1.getZ() < min.getZ()) {
|
||||
min.setZ(pos1.getZ());
|
||||
min = min.withZ(pos1.getZ());
|
||||
}
|
||||
}
|
||||
return new Location[] {min, max};
|
||||
|
@ -75,7 +75,7 @@ public class OperationUtil {
|
||||
weWorld = ((Player) actor).getWorld();
|
||||
} else {
|
||||
@NotNull Location loc = plotPlayer.getLocation();
|
||||
String world = loc.getWorld();
|
||||
String world = loc.getWorldName();
|
||||
weWorld = getWorld(world);
|
||||
}
|
||||
return weWorld;
|
||||
|
@ -155,9 +155,9 @@ public abstract class RegionManager {
|
||||
final Pattern blocks, int minY, int maxY) {
|
||||
LocalBlockQueue queue = area.getQueue(false);
|
||||
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());
|
||||
Location pos2 = new Location(area.getWorldName(), region.getMaximumPoint().getX(), maxY,
|
||||
Location pos2 = Location.at(area.getWorldName(), region.getMaximumPoint().getX(), maxY,
|
||||
region.getMaximumPoint().getZ());
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class WEManager {
|
||||
HashSet<CuboidRegion> regions = new HashSet<>();
|
||||
UUID uuid = player.getUUID();
|
||||
Location location = player.getLocation();
|
||||
String world = location.getWorld();
|
||||
String world = location.getWorldName();
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
regions.add(RegionUtil
|
||||
.createRegion(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE,
|
||||
|
@ -151,7 +151,7 @@ public abstract class WorldUtil {
|
||||
int trx = top.getX() >> 9;
|
||||
int trz = top.getZ() >> 9;
|
||||
Set<BlockVector2> files =
|
||||
RegionManager.manager.getChunkChunks(bot.getWorld());
|
||||
RegionManager.manager.getChunkChunks(bot.getWorldName());
|
||||
for (BlockVector2 mca : files) {
|
||||
if (mca.getX() >= brx && mca.getX() <= trx && mca.getZ() >= brz
|
||||
&& mca.getZ() <= trz) {
|
||||
|
Loading…
Reference in New Issue
Block a user