mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Merge branch 'v6' into feature/v6/pipeline-queue
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java # Core/src/main/java/com/plotsquared/core/plot/Plot.java # Core/src/main/java/com/plotsquared/core/util/WorldUtil.java
This commit is contained in:
commit
3e84f3b3a4
@ -49,7 +49,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel,
|
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (commandSender instanceof Player) {
|
if (commandSender instanceof Player) {
|
||||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
|
return MainCommand.onCommand(BukkitUtil.adapt((Player) commandSender), args);
|
||||||
}
|
}
|
||||||
if (commandSender instanceof ConsoleCommandSender
|
if (commandSender instanceof ConsoleCommandSender
|
||||||
|| commandSender instanceof ProxiedCommandSender
|
|| commandSender instanceof ProxiedCommandSender
|
||||||
@ -65,7 +65,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (!(commandSender instanceof Player)) {
|
if (!(commandSender instanceof Player)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
PlotPlayer player = BukkitUtil.adapt((Player) commandSender);
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return Collections.singletonList("plots");
|
return Collections.singletonList("plots");
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stuff that needs to be created before the PlotSquared instance
|
// Stuff that needs to be created before the PlotSquared instance
|
||||||
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
|
PlotPlayer.registerConverter(Player.class, BukkitUtil::adapt);
|
||||||
TaskManager.setPlatformImplementation(new BukkitTaskManager(this, timeConverter));
|
TaskManager.setPlatformImplementation(new BukkitTaskManager(this, timeConverter));
|
||||||
|
|
||||||
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
||||||
@ -789,7 +789,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
case "BOAT":
|
case "BOAT":
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||||
com.plotsquared.core.location.Location location =
|
com.plotsquared.core.location.Location location =
|
||||||
BukkitUtil.getLocation(entity.getLocation());
|
BukkitUtil.adapt(entity.getLocation());
|
||||||
Plot plot = location.getPlot();
|
Plot plot = location.getPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
@ -820,7 +820,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
case "DRAGON_FIREBALL":
|
case "DRAGON_FIREBALL":
|
||||||
case "DROPPED_ITEM":
|
case "DROPPED_ITEM":
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_ITEMS && plotArea
|
if (Settings.Enabled_Components.KILL_ROAD_ITEMS && plotArea
|
||||||
.getOwnedPlotAbs(BukkitUtil.getLocation(entity.getLocation()))
|
.getOwnedPlotAbs(BukkitUtil.adapt(entity.getLocation()))
|
||||||
== null) {
|
== null) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
@ -846,10 +846,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
PlotId originalPlotId = (PlotId) meta.get(0).value();
|
PlotId originalPlotId = (PlotId) meta.get(0).value();
|
||||||
if (originalPlotId != null) {
|
if (originalPlotId != null) {
|
||||||
com.plotsquared.core.location.Location pLoc =
|
com.plotsquared.core.location.Location pLoc =
|
||||||
BukkitUtil.getLocation(entity.getLocation());
|
BukkitUtil.adapt(entity.getLocation());
|
||||||
PlotArea area = pLoc.getPlotArea();
|
PlotArea area = pLoc.getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
|
PlotId currentPlotId = area.getPlotAbs(pLoc).getId();
|
||||||
if (!originalPlotId.equals(currentPlotId) && (
|
if (!originalPlotId.equals(currentPlotId) && (
|
||||||
currentPlotId == null || !area
|
currentPlotId == null || !area
|
||||||
.getPlot(originalPlotId)
|
.getPlot(originalPlotId)
|
||||||
@ -865,10 +865,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
} else {
|
} else {
|
||||||
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
|
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
|
||||||
com.plotsquared.core.location.Location pLoc =
|
com.plotsquared.core.location.Location pLoc =
|
||||||
BukkitUtil.getLocation(entity.getLocation());
|
BukkitUtil.adapt(entity.getLocation());
|
||||||
PlotArea area = pLoc.getPlotArea();
|
PlotArea area = pLoc.getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
|
PlotId currentPlotId = area.getPlotAbs(pLoc).getId();
|
||||||
if (currentPlotId != null) {
|
if (currentPlotId != null) {
|
||||||
entity.setMetadata("shulkerPlot",
|
entity.setMetadata("shulkerPlot",
|
||||||
new FixedMetadataValue(
|
new FixedMetadataValue(
|
||||||
@ -951,7 +951,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
default: {
|
default: {
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
if (BukkitUtil.getLocation(location).isPlotRoad()) {
|
if (BukkitUtil.adapt(location).isPlotRoad()) {
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
LivingEntity livingEntity = (LivingEntity) entity;
|
||||||
if (!livingEntity.isLeashed() || !entity
|
if (!livingEntity.isLeashed() || !entity
|
||||||
@ -1057,8 +1057,8 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
"WorldEdit"));
|
"WorldEdit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void unregister(@Nonnull final PlotPlayer player) {
|
@Override public void unregister(@Nonnull final PlotPlayer<?> player) {
|
||||||
BukkitUtil.removePlayer(player.getUUID());
|
PlotSquared.platform().getPlayerManager().removePlayer(player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setGenerator(@Nonnull final String worldName) {
|
@Override public void setGenerator(@Nonnull final String worldName) {
|
||||||
@ -1116,10 +1116,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
*/
|
*/
|
||||||
@Override @Nullable public PlotPlayer<Player> wrapPlayer(final Object player) {
|
@Override @Nullable public PlotPlayer<Player> wrapPlayer(final Object player) {
|
||||||
if (player instanceof Player) {
|
if (player instanceof Player) {
|
||||||
return BukkitUtil.getPlayer((Player) player);
|
return BukkitUtil.adapt((Player) player);
|
||||||
}
|
}
|
||||||
if (player instanceof OfflinePlayer) {
|
if (player instanceof OfflinePlayer) {
|
||||||
return BukkitUtil.getPlayer((OfflinePlayer) player);
|
return BukkitUtil.adapt((OfflinePlayer) player);
|
||||||
}
|
}
|
||||||
if (player instanceof String) {
|
if (player instanceof String) {
|
||||||
return (PlotPlayer<Player>) PlotSquared.platform().getPlayerManager()
|
return (PlotPlayer<Player>) PlotSquared.platform().getPlayerManager()
|
||||||
|
@ -152,17 +152,17 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
this.stack = item.getItemStack();
|
this.stack = item.getItemStack();
|
||||||
return;
|
return;
|
||||||
case "ITEM_FRAME":
|
case "ITEM_FRAME":
|
||||||
this.x = Math.floor(this.x);
|
this.x = Math.floor(this.getX());
|
||||||
this.y = Math.floor(this.y);
|
this.y = Math.floor(this.getY());
|
||||||
this.z = Math.floor(this.z);
|
this.z = Math.floor(this.getZ());
|
||||||
ItemFrame itemFrame = (ItemFrame) entity;
|
ItemFrame itemFrame = (ItemFrame) entity;
|
||||||
this.dataByte = getOrdinal(Rotation.values(), itemFrame.getRotation());
|
this.dataByte = getOrdinal(Rotation.values(), itemFrame.getRotation());
|
||||||
this.stack = itemFrame.getItem().clone();
|
this.stack = itemFrame.getItem().clone();
|
||||||
return;
|
return;
|
||||||
case "PAINTING":
|
case "PAINTING":
|
||||||
this.x = Math.floor(this.x);
|
this.x = Math.floor(this.getX());
|
||||||
this.y = Math.floor(this.y);
|
this.y = Math.floor(this.getY());
|
||||||
this.z = Math.floor(this.z);
|
this.z = Math.floor(this.getZ());
|
||||||
Painting painting = (Painting) entity;
|
Painting painting = (Painting) entity;
|
||||||
Art art = painting.getArt();
|
Art art = painting.getArt();
|
||||||
this.dataByte = getOrdinal(BlockFace.values(), painting.getFacing());
|
this.dataByte = getOrdinal(BlockFace.values(), painting.getFacing());
|
||||||
@ -407,9 +407,9 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
this.lived.leashed = lived.isLeashed();
|
this.lived.leashed = lived.isLeashed();
|
||||||
if (this.lived.leashed) {
|
if (this.lived.leashed) {
|
||||||
Location location = lived.getLeashHolder().getLocation();
|
Location location = lived.getLeashHolder().getLocation();
|
||||||
this.lived.leashX = (short) (this.x - location.getBlockX());
|
this.lived.leashX = (short) (this.getX() - location.getBlockX());
|
||||||
this.lived.leashY = (short) (this.y - location.getBlockY());
|
this.lived.leashY = (short) (this.getY() - location.getBlockY());
|
||||||
this.lived.leashZ = (short) (this.z - location.getBlockZ());
|
this.lived.leashZ = (short) (this.getZ() - location.getBlockZ());
|
||||||
}
|
}
|
||||||
EntityEquipment equipment = lived.getEquipment();
|
EntityEquipment equipment = lived.getEquipment();
|
||||||
this.lived.equipped = equipment != null;
|
this.lived.equipped = equipment != null;
|
||||||
@ -460,7 +460,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public Entity spawn(World world, int xOffset, int zOffset) {
|
@Override public Entity spawn(World world, int xOffset, int zOffset) {
|
||||||
Location location = new Location(world, this.x + xOffset, this.y, this.z + zOffset);
|
Location location = new Location(world, this.getX() + xOffset, this.getY(), this.z + zOffset);
|
||||||
location.setYaw(this.yaw);
|
location.setYaw(this.yaw);
|
||||||
location.setPitch(this.pitch);
|
location.setPitch(this.pitch);
|
||||||
if (!this.getType().isSpawnable()) {
|
if (!this.getType().isSpawnable()) {
|
||||||
|
@ -67,9 +67,9 @@ public class TeleportEntityWrapper extends EntityWrapper {
|
|||||||
|
|
||||||
// To account for offsets in the chunk manager
|
// To account for offsets in the chunk manager
|
||||||
this.oldLocation = oldLocation.clone();
|
this.oldLocation = oldLocation.clone();
|
||||||
this.oldLocation.setX(this.x);
|
this.oldLocation.setX(this.getX());
|
||||||
this.oldLocation.setY(this.y);
|
this.oldLocation.setY(this.getY());
|
||||||
this.oldLocation.setZ(this.z);
|
this.oldLocation.setZ(this.getZ());
|
||||||
|
|
||||||
this.gravityOld = this.getEntity().hasGravity();
|
this.gravityOld = this.getEntity().hasGravity();
|
||||||
this.getEntity().setGravity(false);
|
this.getEntity().setGravity(false);
|
||||||
|
@ -126,7 +126,7 @@ public class EntitySpawnListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void creatureSpawnEvent(EntitySpawnEvent event) {
|
public void creatureSpawnEvent(EntitySpawnEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (!location.isPlotArea()) {
|
if (!location.isPlotArea()) {
|
||||||
return;
|
return;
|
||||||
|
@ -49,7 +49,7 @@ public class ForceFieldListener {
|
|||||||
for (Player nearPlayer : Iterables
|
for (Player nearPlayer : Iterables
|
||||||
.filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) {
|
.filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) {
|
||||||
PlotPlayer plotPlayer;
|
PlotPlayer plotPlayer;
|
||||||
if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot
|
if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot
|
||||||
.equals(plotPlayer.getCurrentPlot())) {
|
.equals(plotPlayer.getCurrentPlot())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class ForceFieldListener {
|
|||||||
for (Player nearPlayer : Iterables
|
for (Player nearPlayer : Iterables
|
||||||
.filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) {
|
.filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) {
|
||||||
PlotPlayer plotPlayer;
|
PlotPlayer plotPlayer;
|
||||||
if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot
|
if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot
|
||||||
.equals(plotPlayer.getCurrentPlot())) {
|
.equals(plotPlayer.getCurrentPlot())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,8 @@ public class PaperListener implements Listener {
|
|||||||
if (!Settings.Paper_Components.ENTITY_PATHING) {
|
if (!Settings.Paper_Components.ENTITY_PATHING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location toLoc = BukkitUtil.getLocation(event.getLoc());
|
Location toLoc = BukkitUtil.adapt(event.getLoc());
|
||||||
Location fromLoc = BukkitUtil.getLocation(event.getEntity().getLocation());
|
Location fromLoc = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea tarea = toLoc.getPlotArea();
|
PlotArea tarea = toLoc.getPlotArea();
|
||||||
if (tarea == null) {
|
if (tarea == null) {
|
||||||
return;
|
return;
|
||||||
@ -124,8 +124,8 @@ public class PaperListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location toLoc = BukkitUtil.getLocation(b.getLocation());
|
Location toLoc = BukkitUtil.adapt(b.getLocation());
|
||||||
Location fromLoc = BukkitUtil.getLocation(event.getEntity().getLocation());
|
Location fromLoc = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea tarea = toLoc.getPlotArea();
|
PlotArea tarea = toLoc.getPlotArea();
|
||||||
if (tarea == null) {
|
if (tarea == null) {
|
||||||
return;
|
return;
|
||||||
@ -158,7 +158,7 @@ public class PaperListener implements Listener {
|
|||||||
if (!Settings.Paper_Components.CREATURE_SPAWN) {
|
if (!Settings.Paper_Components.CREATURE_SPAWN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(event.getSpawnLocation());
|
Location location = BukkitUtil.adapt(event.getSpawnLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (!location.isPlotArea()) {
|
if (!location.isPlotArea()) {
|
||||||
return;
|
return;
|
||||||
@ -253,7 +253,7 @@ public class PaperListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerNaturallySpawnCreaturesEvent(PlayerNaturallySpawnCreaturesEvent event) {
|
public void onPlayerNaturallySpawnCreaturesEvent(PlayerNaturallySpawnCreaturesEvent event) {
|
||||||
if (Settings.Paper_Components.CANCEL_CHUNK_SPAWN) {
|
if (Settings.Paper_Components.CANCEL_CHUNK_SPAWN) {
|
||||||
Location location = BukkitUtil.getLocation(event.getPlayer().getLocation());
|
Location location = BukkitUtil.adapt(event.getPlayer().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area != null && !area.isMobSpawning()) {
|
if (area != null && !area.isMobSpawning()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -263,7 +263,7 @@ public class PaperListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler public void onPreSpawnerSpawnEvent(PreSpawnerSpawnEvent event) {
|
@EventHandler public void onPreSpawnerSpawnEvent(PreSpawnerSpawnEvent event) {
|
||||||
if (Settings.Paper_Components.SPAWNER_SPAWN) {
|
if (Settings.Paper_Components.SPAWNER_SPAWN) {
|
||||||
Location location = BukkitUtil.getLocation(event.getSpawnerLocation());
|
Location location = BukkitUtil.adapt(event.getSpawnerLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area != null && !area.isMobSpawnerSpawning()) {
|
if (area != null && !area.isMobSpawnerSpawning()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -279,14 +279,14 @@ public class PaperListener implements Listener {
|
|||||||
if (!(event.getBlock().getState(false) instanceof TileState)) {
|
if (!(event.getBlock().getState(false) instanceof TileState)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
final Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
final PlotArea plotArea = location.getPlotArea();
|
final PlotArea plotArea = location.getPlotArea();
|
||||||
if (plotArea == null) {
|
if (plotArea == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length;
|
final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length;
|
||||||
if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
|
if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
|
||||||
final PlotPlayer<?> plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
|
final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer());
|
||||||
Captions.TILE_ENTITY_CAP_REACHED.send(plotPlayer, Settings.Chunk_Processor.MAX_TILES);
|
Captions.TILE_ENTITY_CAP_REACHED.send(plotPlayer, Settings.Chunk_Processor.MAX_TILES);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setBuild(false);
|
event.setBuild(false);
|
||||||
@ -311,11 +311,11 @@ public class PaperListener implements Listener {
|
|||||||
if (!(shooter instanceof Player)) {
|
if (!(shooter instanceof Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotPlayer<?> pp = BukkitUtil.getPlayer((Player) shooter);
|
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot != null && !plot.isAdded(pp.getUUID())) {
|
if (plot != null && !plot.isAdded(pp.getUUID())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@ -347,7 +347,7 @@ public class PaperListener implements Listener {
|
|||||||
final String[] args = new String[unprocessedArgs.length - 1];
|
final String[] args = new String[unprocessedArgs.length - 1];
|
||||||
System.arraycopy(unprocessedArgs, 1, args, 0, args.length);
|
System.arraycopy(unprocessedArgs, 1, args, 0, args.length);
|
||||||
try {
|
try {
|
||||||
final PlotPlayer<?> player = BukkitUtil.getPlayer((Player) event.getSender());
|
final PlotPlayer<?> player = BukkitUtil.adapt((Player) event.getSender());
|
||||||
final Collection<Command> objects = MainCommand.getInstance().tab(player, args, buffer.endsWith(" "));
|
final Collection<Command> objects = MainCommand.getInstance().tab(player, args, buffer.endsWith(" "));
|
||||||
if (objects == null) {
|
if (objects == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -329,10 +329,10 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) {
|
@EventHandler public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) {
|
||||||
if (e.getVehicle().getType() == EntityType.BOAT) {
|
if (e.getVehicle().getType() == EntityType.BOAT) {
|
||||||
Location location = BukkitUtil.getLocation(e.getEntity());
|
Location location = BukkitUtil.adapt(e.getEntity().getLocation());
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
if (e.getEntity() instanceof Player) {
|
if (e.getEntity() instanceof Player) {
|
||||||
PlotPlayer<Player> player = BukkitUtil.getPlayer((Player) e.getEntity());
|
PlotPlayer<Player> player = BukkitUtil.adapt((Player) e.getEntity());
|
||||||
Plot plot = player.getCurrentPlot();
|
Plot plot = player.getCurrentPlot();
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (!plot.isAdded(player.getUUID())) {
|
if (!plot.isAdded(player.getUUID())) {
|
||||||
@ -354,7 +354,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) {
|
@EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -420,7 +420,7 @@ import java.util.regex.Pattern;
|
|||||||
switch (event.getChangedType()) {
|
switch (event.getChangedType()) {
|
||||||
case COMPARATOR: {
|
case COMPARATOR: {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -442,7 +442,7 @@ import java.util.regex.Pattern;
|
|||||||
case TURTLE_HELMET:
|
case TURTLE_HELMET:
|
||||||
case TURTLE_SPAWN_EGG: {
|
case TURTLE_SPAWN_EGG: {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -465,7 +465,7 @@ import java.util.regex.Pattern;
|
|||||||
case STICKY_PISTON:
|
case STICKY_PISTON:
|
||||||
org.bukkit.block.data.Directional piston =
|
org.bukkit.block.data.Directional piston =
|
||||||
(org.bukkit.block.data.Directional) block.getBlockData();
|
(org.bukkit.block.data.Directional) block.getBlockData();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -510,11 +510,11 @@ import java.util.regex.Pattern;
|
|||||||
if (!(shooter instanceof Player)) {
|
if (!(shooter instanceof Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotPlayer<Player> pp = BukkitUtil.getPlayer((Player) shooter);
|
PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter);
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot != null && !plot.isAdded(pp.getUUID())) {
|
if (plot != null && !plot.isAdded(pp.getUUID())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@ -524,7 +524,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@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.adapt(entity.getLocation());
|
||||||
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -535,7 +535,7 @@ import java.util.regex.Pattern;
|
|||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
ProjectileSource shooter = entity.getShooter();
|
ProjectileSource shooter = entity.getShooter();
|
||||||
if (shooter instanceof Player) {
|
if (shooter instanceof Player) {
|
||||||
PlotPlayer<?> pp = BukkitUtil.getPlayer((Player) shooter);
|
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_PROJECTILE_UNOWNED)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_PROJECTILE_UNOWNED)) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@ -556,7 +556,7 @@ import java.util.regex.Pattern;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location sLoc =
|
Location sLoc =
|
||||||
BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
|
BukkitUtil.adapt(((BlockProjectileSource) shooter).getBlock().getLocation());
|
||||||
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
|
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
return false;
|
return false;
|
||||||
@ -577,7 +577,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlotPlayer<Player> plotPlayer = BukkitUtil.getPlayer(player);
|
PlotPlayer<Player> plotPlayer = BukkitUtil.adapt(player);
|
||||||
Location location = plotPlayer.getLocation();
|
Location location = plotPlayer.getLocation();
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -683,8 +683,8 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onConnect(PlayerJoinEvent event) {
|
public void onConnect(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
BukkitUtil.removePlayer(player.getUniqueId());
|
PlotSquared.platform().getPlayerManager().removePlayer(player.getUniqueId());
|
||||||
final PlotPlayer<Player> pp = BukkitUtil.getPlayer(player);
|
final PlotPlayer<Player> pp = BukkitUtil.adapt(player);
|
||||||
|
|
||||||
Location location = pp.getLocation();
|
Location location = pp.getLocation();
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
@ -723,19 +723,19 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void playerRespawn(PlayerRespawnEvent event) {
|
public void playerRespawn(PlayerRespawnEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlotPlayer<Player> pp = BukkitUtil.getPlayer(player);
|
PlotPlayer<Player> pp = BukkitUtil.adapt(player);
|
||||||
this.eventDispatcher.doRespawnTask(pp);
|
this.eventDispatcher.doRespawnTask(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onTeleport(PlayerTeleportEvent event) {
|
public void onTeleport(PlayerTeleportEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT);
|
Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT);
|
||||||
org.bukkit.Location to = event.getTo();
|
org.bukkit.Location to = event.getTo();
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
if (to != null) {
|
if (to != null) {
|
||||||
Location location = BukkitUtil.getLocation(to);
|
Location location = BukkitUtil.adapt(to);
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (lastPlot != null) {
|
if (lastPlot != null) {
|
||||||
@ -753,7 +753,7 @@ import java.util.regex.Pattern;
|
|||||||
// i.e. untrusted-visit can override deny-teleport
|
// i.e. untrusted-visit can override deny-teleport
|
||||||
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
||||||
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHomeSynchronous()
|
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHomeSynchronous()
|
||||||
.equals(BukkitUtil.getLocationFull(to)))) {
|
.equals(BukkitUtil.adaptComplete(to)))) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
Captions.PERMISSION_ADMIN_ENTRY_DENIED);
|
Captions.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -816,7 +816,7 @@ import java.util.regex.Pattern;
|
|||||||
if (EntityCategories.VEHICLE.contains(entityType) && !EntityCategories.ANIMAL
|
if (EntityCategories.VEHICLE.contains(entityType) && !EntityCategories.ANIMAL
|
||||||
.contains(entityType)) {
|
.contains(entityType)) {
|
||||||
List<MetadataValue> meta = vehicle.getMetadata("plot");
|
List<MetadataValue> meta = vehicle.getMetadata("plot");
|
||||||
Plot toPlot = BukkitUtil.getLocation(to).getPlot();
|
Plot toPlot = BukkitUtil.adapt(to).getPlot();
|
||||||
if (!meta.isEmpty()) {
|
if (!meta.isEmpty()) {
|
||||||
Plot origin = (Plot) meta.get(0).value();
|
Plot origin = (Plot) meta.get(0).value();
|
||||||
if (origin != null && !origin.getBasePlot(false).equals(toPlot)) {
|
if (origin != null && !origin.getBasePlot(false).equals(toPlot)) {
|
||||||
@ -840,13 +840,13 @@ import java.util.regex.Pattern;
|
|||||||
int x2;
|
int x2;
|
||||||
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
// Cancel teleport
|
// Cancel teleport
|
||||||
if (TaskManager.removeFromTeleportQueue(pp.getName())) {
|
if (TaskManager.removeFromTeleportQueue(pp.getName())) {
|
||||||
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
|
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
|
||||||
}
|
}
|
||||||
// Set last location
|
// Set last location
|
||||||
Location location = BukkitUtil.getLocation(to);
|
Location location = BukkitUtil.adapt(to);
|
||||||
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -861,7 +861,7 @@ import java.util.regex.Pattern;
|
|||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
Captions.PERMISSION_ADMIN_EXIT_DENIED);
|
Captions.PERMISSION_ADMIN_EXIT_DENIED);
|
||||||
this.tmpTeleport = false;
|
this.tmpTeleport = false;
|
||||||
if (lastPlot.equals(BukkitUtil.getLocation(from).getPlot())) {
|
if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) {
|
||||||
player.teleport(from);
|
player.teleport(from);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
@ -902,13 +902,13 @@ import java.util.regex.Pattern;
|
|||||||
int z2;
|
int z2;
|
||||||
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
|
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
// Cancel teleport
|
// Cancel teleport
|
||||||
if (TaskManager.removeFromTeleportQueue(pp.getName())) {
|
if (TaskManager.removeFromTeleportQueue(pp.getName())) {
|
||||||
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
|
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
|
||||||
}
|
}
|
||||||
// Set last location
|
// Set last location
|
||||||
Location location = BukkitUtil.getLocation(to);
|
Location location = BukkitUtil.adapt(to);
|
||||||
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -923,7 +923,7 @@ import java.util.regex.Pattern;
|
|||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
Captions.PERMISSION_ADMIN_EXIT_DENIED);
|
Captions.PERMISSION_ADMIN_EXIT_DENIED);
|
||||||
this.tmpTeleport = false;
|
this.tmpTeleport = false;
|
||||||
if (lastPlot.equals(BukkitUtil.getLocation(from).getPlot())) {
|
if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) {
|
||||||
player.teleport(from);
|
player.teleport(from);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
@ -968,7 +968,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(event.getPlayer());
|
||||||
Location location = plotPlayer.getLocation();
|
Location location = plotPlayer.getLocation();
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -1005,7 +1005,7 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String partial = ChatColor.translateAlternateColorCodes('&',
|
String partial = ChatColor.translateAlternateColorCodes('&',
|
||||||
format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender));
|
format.replace("%plot_id%", id.getX() + ";" + id.getY()).replace("%sender%", sender));
|
||||||
if (plotPlayer.hasPermission("plots.chat.color")) {
|
if (plotPlayer.hasPermission("plots.chat.color")) {
|
||||||
message = Captions.color(message);
|
message = Captions.color(message);
|
||||||
}
|
}
|
||||||
@ -1015,7 +1015,7 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
if (!spies.isEmpty()) {
|
if (!spies.isEmpty()) {
|
||||||
String spyMessage = Captions.PLOT_CHAT_SPY_FORMAT.getTranslated()
|
String spyMessage = Captions.PLOT_CHAT_SPY_FORMAT.getTranslated()
|
||||||
.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender)
|
.replace("%plot_id%", id.getX() + ";" + id.getY()).replace("%sender%", sender)
|
||||||
.replace("%msg%", message);
|
.replace("%msg%", message);
|
||||||
for (Player player : spies) {
|
for (Player player : spies) {
|
||||||
player.sendMessage(spyMessage);
|
player.sendMessage(spyMessage);
|
||||||
@ -1027,14 +1027,14 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) {
|
@EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (event.getBlock().getY() == 0) {
|
if (event.getBlock().getY() == 0) {
|
||||||
if (!Permissions
|
if (!Permissions
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
||||||
@ -1083,7 +1083,7 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1100,7 +1100,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBigBoom(EntityExplodeEvent event) {
|
public void onBigBoom(EntityExplodeEvent event) {
|
||||||
Location location = BukkitUtil.getLocation(event.getLocation());
|
Location location = BukkitUtil.adapt(event.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
boolean plotArea = location.isPlotArea();
|
boolean plotArea = location.isPlotArea();
|
||||||
if (!plotArea) {
|
if (!plotArea) {
|
||||||
@ -1136,7 +1136,7 @@ import java.util.regex.Pattern;
|
|||||||
Iterator<Block> iterator = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Block block = iterator.next();
|
Block block = iterator.next();
|
||||||
location = BukkitUtil.getLocation(block.getLocation());
|
location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (!area.contains(location.getX(), location.getZ()) || !origin
|
if (!area.contains(location.getX(), location.getZ()) || !origin
|
||||||
.equals(area.getOwnedPlot(location))) {
|
.equals(area.getOwnedPlot(location))) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@ -1153,7 +1153,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onWorldChanged(PlayerChangedWorldEvent event) {
|
public void onWorldChanged(PlayerChangedWorldEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
// Delete last location
|
// Delete last location
|
||||||
Plot plot = (Plot) pp.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
Plot plot = (Plot) pp.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
||||||
pp.deleteMeta(PlotPlayer.META_LOCATION);
|
pp.deleteMeta(PlotPlayer.META_LOCATION);
|
||||||
@ -1184,7 +1184,7 @@ import java.util.regex.Pattern;
|
|||||||
public void onPeskyMobsChangeTheWorldLikeWTFEvent(EntityChangeBlockEvent event) {
|
public void onPeskyMobsChangeTheWorldLikeWTFEvent(EntityChangeBlockEvent event) {
|
||||||
Entity e = event.getEntity();
|
Entity e = event.getEntity();
|
||||||
if (!(e instanceof FallingBlock)) {
|
if (!(e instanceof FallingBlock)) {
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
@ -1203,7 +1203,7 @@ import java.util.regex.Pattern;
|
|||||||
if (!this.plotAreaManager.hasPlotArea(world)) {
|
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -1217,7 +1217,7 @@ import java.util.regex.Pattern;
|
|||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (plot.getFlag(IceFormFlag.class)) {
|
if (plot.getFlag(IceFormFlag.class)) {
|
||||||
plot.debug("Ice could not be formed because ice-form = false");
|
plot.debug("Ice could not be formed because ice-form = false");
|
||||||
return;
|
return;
|
||||||
@ -1225,7 +1225,7 @@ import java.util.regex.Pattern;
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||||
if (plot.getFlag(IceFormFlag.class)) {
|
if (plot.getFlag(IceFormFlag.class)) {
|
||||||
plot.debug("Ice could not be formed because ice-form = false");
|
plot.debug("Ice could not be formed because ice-form = false");
|
||||||
@ -1244,7 +1244,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockSpread(BlockSpreadEvent event) {
|
public void onBlockSpread(BlockSpreadEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (location.isPlotRoad()) {
|
if (location.isPlotRoad()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1288,7 +1288,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockForm(BlockFormEvent event) {
|
public void onBlockForm(BlockFormEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (location.isPlotRoad()) {
|
if (location.isPlotRoad()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1322,7 +1322,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -1345,7 +1345,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (Permissions
|
if (Permissions
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||||
return;
|
return;
|
||||||
@ -1353,7 +1353,7 @@ import java.util.regex.Pattern;
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||||
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
@ -1370,7 +1370,7 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1380,7 +1380,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFade(BlockFadeEvent event) {
|
public void onFade(BlockFadeEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -1442,7 +1442,7 @@ import java.util.regex.Pattern;
|
|||||||
Block from = event.getBlock();
|
Block from = event.getBlock();
|
||||||
|
|
||||||
// Check liquid flow flag inside of origin plot too
|
// Check liquid flow flag inside of origin plot too
|
||||||
final Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
final Location fLocation = BukkitUtil.adapt(from.getLocation());
|
||||||
final PlotArea fromArea = fLocation.getPlotArea();
|
final PlotArea fromArea = fLocation.getPlotArea();
|
||||||
if (fromArea != null) {
|
if (fromArea != null) {
|
||||||
final Plot plot = fromArea.getOwnedPlot(fLocation);
|
final Plot plot = fromArea.getOwnedPlot(fLocation);
|
||||||
@ -1456,7 +1456,7 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
|
|
||||||
Block to = event.getToBlock();
|
Block to = event.getToBlock();
|
||||||
Location tLocation = BukkitUtil.getLocation(to.getLocation());
|
Location tLocation = BukkitUtil.adapt(to.getLocation());
|
||||||
PlotArea area = tLocation.getPlotArea();
|
PlotArea area = tLocation.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -1501,14 +1501,14 @@ import java.util.regex.Pattern;
|
|||||||
v
|
v
|
||||||
<-----O-----> x
|
<-----O-----> x
|
||||||
*/
|
*/
|
||||||
if (BukkitUtil.getPlot(location.clone().add(-1, 0, 1) /* A */) != null
|
if (BukkitUtil.adapt(location.clone().add(-1, 0, 1) /* A */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(1, 0, 0) /* B */) != null
|
|| BukkitUtil.adapt(location.clone().add(1, 0, 0) /* B */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(1, 0, 1) /* C */) != null
|
|| BukkitUtil.adapt(location.clone().add(1, 0, 1) /* C */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(-1, 0, 0) /* D */) != null
|
|| BukkitUtil.adapt(location.clone().add(-1, 0, 0) /* D */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(1, 0, 0) /* E */) != null
|
|| BukkitUtil.adapt(location.clone().add(1, 0, 0) /* E */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(-1, 0, -1) /* F */) != null
|
|| BukkitUtil.adapt(location.clone().add(-1, 0, -1) /* F */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(0, 0, -1) /* G */) != null
|
|| BukkitUtil.adapt(location.clone().add(0, 0, -1) /* G */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(1, 0, 1) /* H */) != null) {
|
|| BukkitUtil.adapt(location.clone().add(1, 0, 1) /* H */).getPlot() != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1517,7 +1517,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onGrow(BlockGrowEvent event) {
|
public void onGrow(BlockGrowEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (location.isUnownedPlotArea()) {
|
if (location.isUnownedPlotArea()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -1526,7 +1526,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
BlockFace face = event.getDirection();
|
BlockFace face = event.getDirection();
|
||||||
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();
|
||||||
@ -1535,7 +1535,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.adapt(block1.getLocation());
|
||||||
if (bloc.isPlotArea() || bloc
|
if (bloc.isPlotArea() || bloc
|
||||||
.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
||||||
.isPlotArea()) {
|
.isPlotArea()) {
|
||||||
@ -1557,7 +1557,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.adapt(block1.getLocation());
|
||||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
||||||
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -1581,7 +1581,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
BlockFace face = event.getDirection();
|
BlockFace face = event.getDirection();
|
||||||
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();
|
||||||
@ -1590,7 +1590,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.adapt(block1.getLocation());
|
||||||
if (bloc.isPlotArea() || bloc
|
if (bloc.isPlotArea() || bloc
|
||||||
.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
||||||
.isPlotArea()) {
|
.isPlotArea()) {
|
||||||
@ -1606,7 +1606,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.adapt(block1.getLocation());
|
||||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
||||||
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -1661,7 +1661,7 @@ import java.util.regex.Pattern;
|
|||||||
BlockFace targetFace =
|
BlockFace targetFace =
|
||||||
((Directional) event.getBlock().getState().getData()).getFacing();
|
((Directional) event.getBlock().getState().getData()).getFacing();
|
||||||
Location location =
|
Location location =
|
||||||
BukkitUtil.getLocation(event.getBlock().getRelative(targetFace).getLocation());
|
BukkitUtil.adapt(event.getBlock().getRelative(targetFace).getLocation());
|
||||||
if (location.isPlotRoad()) {
|
if (location.isPlotRoad()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -1678,11 +1678,11 @@ import java.util.regex.Pattern;
|
|||||||
if (blocks.isEmpty()) {
|
if (blocks.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(blocks.get(0).getLocation());
|
Location location = BukkitUtil.adapt(blocks.get(0).getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
location = BukkitUtil.adapt(blocks.get(i).getLocation());
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
blocks.remove(i);
|
blocks.remove(i);
|
||||||
}
|
}
|
||||||
@ -1695,7 +1695,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
location = BukkitUtil.adapt(blocks.get(i).getLocation());
|
||||||
if (!area.contains(location.getX(), location.getZ())) {
|
if (!area.contains(location.getX(), location.getZ())) {
|
||||||
blocks.remove(i);
|
blocks.remove(i);
|
||||||
continue;
|
continue;
|
||||||
@ -1712,7 +1712,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
location = BukkitUtil.adapt(blocks.get(i).getLocation());
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
/*
|
/*
|
||||||
* plot → the base plot of the merged area
|
* plot → the base plot of the merged area
|
||||||
@ -1744,7 +1744,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = (Player) clicker;
|
Player player = (Player) clicker;
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp);
|
final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp);
|
||||||
if (inventory != null && event.getRawSlot() == event.getSlot()) {
|
if (inventory != null && event.getRawSlot() == event.getSlot()) {
|
||||||
if (!inventory.onClick(event.getSlot())) {
|
if (!inventory.onClick(event.getSlot())) {
|
||||||
@ -1831,7 +1831,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(state.getLocation());
|
Location location = BukkitUtil.adapt(state.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -1875,7 +1875,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
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.adapt(entity.getLocation());
|
||||||
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1890,14 +1890,14 @@ import java.util.regex.Pattern;
|
|||||||
if (!(entity instanceof ArmorStand) && !(entity instanceof ItemFrame)) {
|
if (!(entity instanceof ArmorStand) && !(entity instanceof ItemFrame)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(e.getRightClicked().getLocation());
|
Location location = BukkitUtil.adapt(e.getRightClicked().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EntitySpawnListener.testNether(entity);
|
EntitySpawnListener.testNether(entity);
|
||||||
Plot plot = location.getPlotAbs();
|
Plot plot = location.getPlotAbs();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
BukkitPlayer pp = BukkitUtil.adapt(e.getPlayer());
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions
|
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions
|
||||||
.hasPermission(pp, "plots.admin.interact.road")) {
|
.hasPermission(pp, "plots.admin.interact.road")) {
|
||||||
@ -1941,7 +1941,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
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.adapt(block.getLocation());
|
||||||
String world = location.getWorldName();
|
String world = location.getWorldName();
|
||||||
if (!this.plotAreaManager.hasPlotArea(world)) {
|
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||||
return;
|
return;
|
||||||
@ -1950,7 +1950,7 @@ import java.util.regex.Pattern;
|
|||||||
if (area == null) {
|
if (area == null) {
|
||||||
Iterator<Block> iterator = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
location = BukkitUtil.getLocation(iterator.next().getLocation());
|
location = BukkitUtil.adapt(iterator.next().getLocation());
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
@ -1965,14 +1965,14 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.blockList().removeIf(
|
event.blockList().removeIf(
|
||||||
blox -> !plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(blox.getLocation()))));
|
blox -> !plot.equals(area.getOwnedPlot(BukkitUtil.adapt(blox.getLocation()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onCancelledInteract(PlayerInteractEvent event) {
|
public void onCancelledInteract(PlayerInteractEvent event) {
|
||||||
if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) {
|
if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
PlotArea area = pp.getPlotAreaAbs();
|
PlotArea area = pp.getPlotAreaAbs();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -1994,7 +1994,7 @@ import java.util.regex.Pattern;
|
|||||||
if (type.toString().toLowerCase().endsWith("_egg")) {
|
if (type.toString().toLowerCase().endsWith("_egg")) {
|
||||||
Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY);
|
Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY);
|
||||||
if (block != null && block.getType() != Material.AIR) {
|
if (block != null && block.getType() != Material.AIR) {
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (!this.eventDispatcher
|
if (!this.eventDispatcher
|
||||||
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, null,
|
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, null,
|
||||||
true)) {
|
true)) {
|
||||||
@ -2009,7 +2009,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onInteract(PlayerInteractEvent event) {
|
public void onInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
PlotArea area = pp.getPlotAreaAbs();
|
PlotArea area = pp.getPlotAreaAbs();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -2017,7 +2017,7 @@ import java.util.regex.Pattern;
|
|||||||
PlayerBlockEventType eventType = null;
|
PlayerBlockEventType eventType = null;
|
||||||
BlockType blocktype1;
|
BlockType blocktype1;
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
outer:
|
outer:
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@ -2106,14 +2106,14 @@ import java.util.regex.Pattern;
|
|||||||
break outer;
|
break outer;
|
||||||
case ARMOR_STAND:
|
case ARMOR_STAND:
|
||||||
location = BukkitUtil
|
location = BukkitUtil
|
||||||
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
.adapt(block.getRelative(event.getBlockFace()).getLocation());
|
||||||
eventType = PlayerBlockEventType.PLACE_MISC;
|
eventType = PlayerBlockEventType.PLACE_MISC;
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LEFT_CLICK_BLOCK: {
|
case LEFT_CLICK_BLOCK: {
|
||||||
location = BukkitUtil.getLocation(block.getLocation());
|
location = BukkitUtil.adapt(block.getLocation());
|
||||||
//eventType = PlayerBlockEventType.BREAK_BLOCK;
|
//eventType = PlayerBlockEventType.BREAK_BLOCK;
|
||||||
blocktype1 = BukkitAdapter.asBlockType(block.getType());
|
blocktype1 = BukkitAdapter.asBlockType(block.getType());
|
||||||
if (block.getType() == Material.DRAGON_EGG) {
|
if (block.getType() == Material.DRAGON_EGG) {
|
||||||
@ -2142,7 +2142,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void creatureSpawnEvent(CreatureSpawnEvent event) {
|
public void creatureSpawnEvent(CreatureSpawnEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -2220,7 +2220,7 @@ import java.util.regex.Pattern;
|
|||||||
if (!this.plotAreaManager.hasPlotArea(worldName)) {
|
if (!this.plotAreaManager.hasPlotArea(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -2255,7 +2255,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockBurn(BlockBurnEvent event) {
|
public void onBlockBurn(BlockBurnEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
|
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -2278,7 +2278,7 @@ import java.util.regex.Pattern;
|
|||||||
Entity ignitingEntity = event.getIgnitingEntity();
|
Entity ignitingEntity = event.getIgnitingEntity();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
BlockIgniteEvent.IgniteCause igniteCause = event.getCause();
|
BlockIgniteEvent.IgniteCause igniteCause = event.getCause();
|
||||||
Location location1 = BukkitUtil.getLocation(block.getLocation());
|
Location location1 = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location1.getPlotArea();
|
PlotArea area = location1.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -2290,7 +2290,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
Plot plot = area.getOwnedPlot(location1);
|
Plot plot = area.getOwnedPlot(location1);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
@ -2329,11 +2329,11 @@ import java.util.regex.Pattern;
|
|||||||
Location location = null;
|
Location location = null;
|
||||||
if (fireball.getShooter() instanceof Entity) {
|
if (fireball.getShooter() instanceof Entity) {
|
||||||
Entity shooter = (Entity) fireball.getShooter();
|
Entity shooter = (Entity) fireball.getShooter();
|
||||||
location = BukkitUtil.getLocation(shooter.getLocation());
|
location = BukkitUtil.adapt(shooter.getLocation());
|
||||||
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
|
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
|
||||||
Block shooter =
|
Block shooter =
|
||||||
((BlockProjectileSource) fireball.getShooter()).getBlock();
|
((BlockProjectileSource) fireball.getShooter()).getBlock();
|
||||||
location = BukkitUtil.getLocation(shooter.getLocation());
|
location = BukkitUtil.adapt(shooter.getLocation());
|
||||||
}
|
}
|
||||||
if (location != null && !plot.equals(location.getPlot())) {
|
if (location != null && !plot.equals(location.getPlot())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -2343,7 +2343,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
} else if (event.getIgnitingBlock() != null) {
|
} else if (event.getIgnitingBlock() != null) {
|
||||||
Block ignitingBlock = event.getIgnitingBlock();
|
Block ignitingBlock = event.getIgnitingBlock();
|
||||||
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
|
Plot plotIgnited = BukkitUtil.adapt(ignitingBlock.getLocation()).getPlot();
|
||||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
|
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
|
||||||
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null || !plotIgnited
|
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null || !plotIgnited
|
||||||
.equals(plot)) || (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|
.equals(plot)) || (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|
||||||
@ -2362,12 +2362,12 @@ import java.util.regex.Pattern;
|
|||||||
Block block =
|
Block block =
|
||||||
event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ())
|
event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ())
|
||||||
.getBlock();
|
.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
BukkitPlayer pp = BukkitUtil.adapt(event.getPlayer());
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||||
@ -2413,12 +2413,12 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = (Player) closer;
|
Player player = (Player) closer;
|
||||||
PlotInventory.removePlotInventoryOpen(BukkitUtil.getPlayer(player));
|
PlotInventory.removePlotInventoryOpen(BukkitUtil.adapt(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) {
|
@EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) {
|
||||||
TaskManager.removeFromTeleportQueue(event.getPlayer().getName());
|
TaskManager.removeFromTeleportQueue(event.getPlayer().getName());
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
BukkitPlayer pp = BukkitUtil.adapt(event.getPlayer());
|
||||||
pp.unregister();
|
pp.unregister();
|
||||||
this.logout(pp.getUUID());
|
this.logout(pp.getUUID());
|
||||||
}
|
}
|
||||||
@ -2426,13 +2426,13 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBucketFill(PlayerBucketFillEvent event) {
|
public void onBucketFill(PlayerBucketFillEvent event) {
|
||||||
Block blockClicked = event.getBlockClicked();
|
Block blockClicked = event.getBlockClicked();
|
||||||
Location location = BukkitUtil.getLocation(blockClicked.getLocation());
|
Location location = BukkitUtil.adapt(blockClicked.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||||
@ -2475,7 +2475,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onVehicleCreate(VehicleCreateEvent event) {
|
public void onVehicleCreate(VehicleCreateEvent event) {
|
||||||
Vehicle entity = event.getVehicle();
|
Vehicle entity = event.getVehicle();
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -2494,7 +2494,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onHangingPlace(HangingPlaceEvent event) {
|
public void onHangingPlace(HangingPlaceEvent event) {
|
||||||
Block block = event.getBlock().getRelative(event.getBlockFace());
|
Block block = event.getBlock().getRelative(event.getBlockFace());
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -2504,7 +2504,7 @@ import java.util.regex.Pattern;
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
BukkitPlayer pp = BukkitUtil.adapt(p);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||||
@ -2543,12 +2543,12 @@ import java.util.regex.Pattern;
|
|||||||
Entity remover = event.getRemover();
|
Entity remover = event.getRemover();
|
||||||
if (remover instanceof Player) {
|
if (remover instanceof Player) {
|
||||||
Player p = (Player) remover;
|
Player p = (Player) remover;
|
||||||
Location location = BukkitUtil.getLocation(event.getEntity());
|
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
BukkitPlayer pp = BukkitUtil.adapt(p);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||||
@ -2578,13 +2578,13 @@ import java.util.regex.Pattern;
|
|||||||
Projectile p = (Projectile) remover;
|
Projectile p = (Projectile) remover;
|
||||||
if (p.getShooter() instanceof Player) {
|
if (p.getShooter() instanceof Player) {
|
||||||
Player shooter = (Player) p.getShooter();
|
Player shooter = (Player) p.getShooter();
|
||||||
Location location = BukkitUtil.getLocation(event.getEntity());
|
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer player = BukkitUtil.getPlayer(shooter);
|
BukkitPlayer player = BukkitUtil.adapt(shooter);
|
||||||
Plot plot = area.getPlot(BukkitUtil.getLocation(event.getEntity()));
|
Plot plot = area.getPlot(BukkitUtil.adapt(event.getEntity().getLocation()));
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
if (!Permissions
|
if (!Permissions
|
||||||
@ -2614,13 +2614,13 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
Location location = BukkitUtil.getLocation(event.getRightClicked().getLocation());
|
Location location = BukkitUtil.adapt(event.getRightClicked().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
BukkitPlayer pp = BukkitUtil.adapt(p);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null && !area.isRoadFlags()) {
|
if (plot == null && !area.isRoadFlags()) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
||||||
@ -2695,7 +2695,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||||
Location location = BukkitUtil.getLocation(event.getVehicle());
|
Location location = BukkitUtil.adapt(event.getVehicle().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -2703,7 +2703,7 @@ import java.util.regex.Pattern;
|
|||||||
Entity attacker = event.getAttacker();
|
Entity attacker = event.getAttacker();
|
||||||
if (attacker instanceof Player) {
|
if (attacker instanceof Player) {
|
||||||
Player p = (Player) attacker;
|
Player p = (Player) attacker;
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
BukkitPlayer pp = BukkitUtil.adapt(p);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
|
||||||
@ -2740,7 +2740,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
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.adapt(damager.getLocation());
|
||||||
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2770,7 +2770,7 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
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.adapt(damager.getLocation());
|
||||||
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2804,8 +2804,8 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
private boolean entityDamage(Entity damager, Entity victim,
|
private boolean entityDamage(Entity damager, Entity victim,
|
||||||
EntityDamageEvent.DamageCause cause) {
|
EntityDamageEvent.DamageCause cause) {
|
||||||
Location dloc = BukkitUtil.getLocation(damager);
|
Location dloc = BukkitUtil.adapt(damager.getLocation());
|
||||||
Location vloc = BukkitUtil.getLocation(victim);
|
Location vloc = BukkitUtil.adapt(victim.getLocation());
|
||||||
PlotArea dArea = dloc.getPlotArea();
|
PlotArea dArea = dloc.getPlotArea();
|
||||||
PlotArea vArea;
|
PlotArea vArea;
|
||||||
if (dArea != null && dArea.contains(vloc.getX(), vloc.getZ())) {
|
if (dArea != null && dArea.contains(vloc.getX(), vloc.getZ())) {
|
||||||
@ -2883,7 +2883,7 @@ import java.util.regex.Pattern;
|
|||||||
} else { // shooter is not player
|
} else { // shooter is not player
|
||||||
if (shooter instanceof BlockProjectileSource) {
|
if (shooter instanceof BlockProjectileSource) {
|
||||||
Location sLoc = BukkitUtil
|
Location sLoc = BukkitUtil
|
||||||
.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
|
.adapt(((BlockProjectileSource) shooter).getBlock().getLocation());
|
||||||
dplot = dArea.getPlot(sLoc);
|
dplot = dArea.getPlot(sLoc);
|
||||||
}
|
}
|
||||||
player = null;
|
player = null;
|
||||||
@ -2892,7 +2892,7 @@ import java.util.regex.Pattern;
|
|||||||
player = null;
|
player = null;
|
||||||
}
|
}
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
|
|
||||||
final com.sk89q.worldedit.world.entity.EntityType entityType;
|
final com.sk89q.worldedit.world.entity.EntityType entityType;
|
||||||
|
|
||||||
@ -3051,13 +3051,13 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||||
Location location = BukkitUtil.getLocation(event.getEgg().getLocation());
|
Location location = BukkitUtil.adapt(event.getEgg().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
|
||||||
@ -3082,13 +3082,13 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void blockCreate(BlockPlaceEvent event) {
|
public void blockCreate(BlockPlaceEvent event) {
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
|
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
|
||||||
@ -3149,7 +3149,7 @@ import java.util.regex.Pattern;
|
|||||||
if (event.getEntityType() != EntityType.PLAYER) {
|
if (event.getEntityType() != EntityType.PLAYER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(event.getEntity());
|
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -3170,7 +3170,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
Location location = pp.getLocation();
|
Location location = pp.getLocation();
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -3196,7 +3196,7 @@ import java.util.regex.Pattern;
|
|||||||
LivingEntity ent = event.getEntity();
|
LivingEntity ent = event.getEntity();
|
||||||
if (ent instanceof Player) {
|
if (ent instanceof Player) {
|
||||||
Player player = (Player) ent;
|
Player player = (Player) ent;
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
Location location = pp.getLocation();
|
Location location = pp.getLocation();
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -3219,7 +3219,7 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler public void onDeath(final PlayerDeathEvent event) {
|
@EventHandler public void onDeath(final PlayerDeathEvent event) {
|
||||||
Location location = BukkitUtil.getLocation(event.getEntity());
|
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -112,11 +112,6 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull @Override public Location getLocation() {
|
|
||||||
final Location location = super.getLocation();
|
|
||||||
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public UUID getUUID() {
|
@Nonnull @Override public UUID getUUID() {
|
||||||
if (Settings.UUID.OFFLINE) {
|
if (Settings.UUID.OFFLINE) {
|
||||||
if (Settings.UUID.FORCE_LOWERCASE) {
|
if (Settings.UUID.FORCE_LOWERCASE) {
|
||||||
@ -135,7 +130,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean canTeleport(@Nonnull final Location location) {
|
@Override public boolean canTeleport(@Nonnull final Location location) {
|
||||||
final org.bukkit.Location to = BukkitUtil.getLocation(location);
|
final org.bukkit.Location to = BukkitUtil.adapt(location);
|
||||||
final org.bukkit.Location from = player.getLocation();
|
final org.bukkit.Location from = player.getLocation();
|
||||||
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
||||||
callEvent(event);
|
callEvent(event);
|
||||||
@ -276,7 +271,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public Location getLocationFull() {
|
@Override public Location getLocationFull() {
|
||||||
return BukkitUtil.getLocationFull(this.player);
|
return BukkitUtil.adaptComplete(this.player.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setWeather(@Nonnull final PlotWeather weather) {
|
@Override public void setWeather(@Nonnull final PlotWeather weather) {
|
||||||
@ -347,7 +342,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, Material.AIR);
|
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, Material.AIR);
|
||||||
} else {
|
} else {
|
||||||
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id.to(Material.class));
|
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id.to(Material.class));
|
||||||
this.player.playSound(BukkitUtil.getLocation(location),
|
this.player.playSound(BukkitUtil.adapt(location),
|
||||||
Sound.valueOf(BukkitAdapter.adapt(id).name()), Float.MAX_VALUE, 1f);
|
Sound.valueOf(BukkitAdapter.adapt(id).name()), Float.MAX_VALUE, 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ public class BukkitRegionManager extends RegionManager {
|
|||||||
if (X > bx && X < tx && Z > bz && Z < tz) {
|
if (X > bx && X < tx && Z > bz && Z < tz) {
|
||||||
count(count, entity);
|
count(count, entity);
|
||||||
} else {
|
} else {
|
||||||
Plot other = area.getPlot(BukkitUtil.getLocation(location));
|
Plot other = area.getPlot(BukkitUtil.adapt(location));
|
||||||
if (plot.equals(other)) {
|
if (plot.equals(other)) {
|
||||||
count(count, entity);
|
count(count, entity);
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ public class BukkitRegionManager extends RegionManager {
|
|||||||
Entity[] entities1 = chunk.getEntities();
|
Entity[] entities1 = chunk.getEntities();
|
||||||
for (Entity entity : entities1) {
|
for (Entity entity : entities1) {
|
||||||
if (X == bx || X == tx || Z == bz || Z == tz) {
|
if (X == bx || X == tx || Z == bz || Z == tz) {
|
||||||
Plot other = area.getPlot(BukkitUtil.getLocation(entity));
|
Plot other = area.getPlot(BukkitUtil.adapt(entity.getLocation()));
|
||||||
if (plot.equals(other)) {
|
if (plot.equals(other)) {
|
||||||
count(count, entity);
|
count(count, entity);
|
||||||
}
|
}
|
||||||
@ -399,7 +399,15 @@ public class BukkitRegionManager extends RegionManager {
|
|||||||
|
|
||||||
@Override public void clearAllEntities(Location pos1, Location pos2) {
|
@Override public void clearAllEntities(Location pos1, Location pos2) {
|
||||||
String world = pos1.getWorldName();
|
String world = pos1.getWorldName();
|
||||||
List<Entity> entities = BukkitUtil.getEntities(world);
|
|
||||||
|
final World bukkitWorld = BukkitUtil.getWorld(world);
|
||||||
|
final List<Entity> entities;
|
||||||
|
if (bukkitWorld != null) {
|
||||||
|
entities = new ArrayList<>(bukkitWorld.getEntities());
|
||||||
|
} else {
|
||||||
|
entities = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
int bx = pos1.getX();
|
int bx = pos1.getX();
|
||||||
int bz = pos1.getZ();
|
int bz = pos1.getZ();
|
||||||
int tx = pos2.getX();
|
int tx = pos2.getX();
|
||||||
|
@ -31,12 +31,9 @@ import com.plotsquared.bukkit.BukkitPlatform;
|
|||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
|
||||||
import com.plotsquared.core.util.BlockUtil;
|
import com.plotsquared.core.util.BlockUtil;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
@ -97,12 +94,11 @@ import org.bukkit.entity.WaterMob;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnegative;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -114,30 +110,24 @@ import java.util.stream.Stream;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class BukkitUtil extends WorldUtil {
|
public class BukkitUtil extends WorldUtil {
|
||||||
|
|
||||||
private static final Logger logger =
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitUtil.class.getSimpleName());
|
||||||
LoggerFactory.getLogger("P2/" + BukkitUtil.class.getSimpleName());
|
|
||||||
|
|
||||||
private static String lastString = null;
|
|
||||||
private static World lastWorld = null;
|
|
||||||
|
|
||||||
private static Player lastPlayer = null;
|
|
||||||
private static BukkitPlayer lastPlotPlayer = null;
|
|
||||||
private final Collection<BlockType> tileEntityTypes = new HashSet<>();
|
private final Collection<BlockType> tileEntityTypes = new HashSet<>();
|
||||||
|
|
||||||
@Inject public BukkitUtil(@Nonnull final RegionManager regionManager) {
|
@Inject public BukkitUtil(@Nonnull final RegionManager regionManager) {
|
||||||
super(regionManager);
|
super(regionManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removePlayer(UUID uuid) {
|
/**
|
||||||
lastPlayer = null;
|
* Get a {@link PlotPlayer} from an {@link OfflinePlayer}. If the player is
|
||||||
lastPlotPlayer = null;
|
* online, it returns a complete player. If the player is offline, it creates
|
||||||
// Make sure that it's removed internally
|
* a fake player
|
||||||
PlotSquared.platform().getPlayerManager().removePlayer(uuid);
|
*
|
||||||
}
|
* @param op Offline player
|
||||||
|
* @return Plot player instance
|
||||||
public static PlotPlayer<Player> getPlayer(@Nonnull final OfflinePlayer op) {
|
*/
|
||||||
|
@Nonnull public static PlotPlayer<Player> adapt(@Nonnull final OfflinePlayer op) {
|
||||||
if (op.isOnline()) {
|
if (op.isOnline()) {
|
||||||
return getPlayer(op.getPlayer());
|
return adapt(Objects.requireNonNull(op.getPlayer()));
|
||||||
}
|
}
|
||||||
final Player player = OfflinePlayerUtil.loadPlayer(op);
|
final Player player = OfflinePlayerUtil.loadPlayer(op);
|
||||||
player.loadData();
|
player.loadData();
|
||||||
@ -147,204 +137,82 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a plot based on the location.
|
* Turn a Bukkit {@link Player} into a PlotSquared {@link PlotPlayer}
|
||||||
*
|
*
|
||||||
* @param location the location to check
|
* @param player Bukkit player
|
||||||
* @return plot if found, otherwise it creates a temporary plot
|
* @return PlotSquared player
|
||||||
* @see Plot
|
|
||||||
*/
|
*/
|
||||||
public static Plot getPlot(org.bukkit.Location location) {
|
@Nonnull public static BukkitPlayer adapt(@Nonnull final Player player) {
|
||||||
if (location == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getLocation(location).getPlot();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a plot based on the player location.
|
|
||||||
*
|
|
||||||
* @param player the player to check
|
|
||||||
* @return plot if found, otherwise it creates a temporary plot
|
|
||||||
* @see #getPlot(org.bukkit.Location)
|
|
||||||
* @see Plot
|
|
||||||
*/
|
|
||||||
public static Plot getPlot(Player player) {
|
|
||||||
return getPlot(player.getLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the PlotPlayer for an offline player.
|
|
||||||
*
|
|
||||||
* <p>Note that this will work if the player is offline, however not all
|
|
||||||
* functionality will work.
|
|
||||||
*
|
|
||||||
* @param player the player to wrap
|
|
||||||
* @return a {@code PlotPlayer}
|
|
||||||
* @see PlotPlayer#wrap(Object)
|
|
||||||
*/
|
|
||||||
public static PlotPlayer<?> wrapPlayer(OfflinePlayer player) {
|
|
||||||
return PlotPlayer.wrap(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the PlotPlayer for a player. The PlotPlayer is usually cached and
|
|
||||||
* will provide useful functions relating to players.
|
|
||||||
*
|
|
||||||
* @param player the player to wrap
|
|
||||||
* @return a {@code PlotPlayer}
|
|
||||||
* @see PlotPlayer#wrap(Object)
|
|
||||||
*/
|
|
||||||
public static PlotPlayer<?> wrapPlayer(Player player) {
|
|
||||||
return PlotPlayer.wrap(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the number of plots, which the player is able to build in.
|
|
||||||
*
|
|
||||||
* @param player player, for whom we're getting the plots
|
|
||||||
* @return the number of allowed plots
|
|
||||||
*/
|
|
||||||
public static int getAllowedPlots(Player player) {
|
|
||||||
PlotPlayer<?> plotPlayer = PlotPlayer.wrap(player);
|
|
||||||
return plotPlayer.getAllowedPlots();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether or not a player is in a plot.
|
|
||||||
*
|
|
||||||
* @param player who we're checking for
|
|
||||||
* @return true if the player is in a plot, false if not-
|
|
||||||
*/
|
|
||||||
public static boolean isInPlot(Player player) {
|
|
||||||
return getPlot(player) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a collection containing the players plots.
|
|
||||||
*
|
|
||||||
* @param world Specify the world we want to select the plots from
|
|
||||||
* @param player Player, for whom we're getting the plots
|
|
||||||
* @return a set containing the players plots
|
|
||||||
* @see Plot
|
|
||||||
*/
|
|
||||||
public static Set<Plot> getPlayerPlots(String world, Player player) {
|
|
||||||
if (world == null) {
|
|
||||||
return new HashSet<>();
|
|
||||||
}
|
|
||||||
return BukkitPlayer.wrap(player).getPlots(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a message to a player. The message supports color codes.
|
|
||||||
*
|
|
||||||
* @param player the recipient of the message
|
|
||||||
* @param string the message
|
|
||||||
* @see MainUtil#sendMessage(PlotPlayer, String)
|
|
||||||
*/
|
|
||||||
public static void sendMessage(Player player, String string) {
|
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the player plot count.
|
|
||||||
*
|
|
||||||
* @param world Specify the world we want to select the plots from
|
|
||||||
* @param player Player, for whom we're getting the plot count
|
|
||||||
* @return the number of plots the player has
|
|
||||||
*/
|
|
||||||
public static int getPlayerPlotCount(String world, Player player) {
|
|
||||||
if (world == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return BukkitUtil.getPlayer(player).getPlotCount(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a message to a player.
|
|
||||||
*
|
|
||||||
* @param player the recipient of the message
|
|
||||||
* @param caption the message
|
|
||||||
*/
|
|
||||||
public static void sendMessage(Player player, Captions caption) {
|
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BukkitPlayer getPlayer(@Nonnull final Player player) {
|
|
||||||
if (player == lastPlayer) {
|
|
||||||
return lastPlotPlayer;
|
|
||||||
}
|
|
||||||
final PlayerManager<?, ?> playerManager = PlotSquared.platform().getPlayerManager();
|
final PlayerManager<?, ?> playerManager = PlotSquared.platform().getPlayerManager();
|
||||||
return ((BukkitPlayerManager) playerManager).getPlayer(player);
|
return ((BukkitPlayerManager) playerManager).getPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getLocation(final org.bukkit.Location location) {
|
/**
|
||||||
|
* Turn a Bukkit {@link org.bukkit.Location} into a PlotSquared {@link Location}.
|
||||||
|
* This only copies the 4-tuple (world,x,y,z) and does not include the yaw and the pitch
|
||||||
|
*
|
||||||
|
* @param location Bukkit location
|
||||||
|
* @return PlotSquared location
|
||||||
|
*/
|
||||||
|
@Nonnull public static Location adapt(@Nonnull final org.bukkit.Location location) {
|
||||||
return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
|
return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
|
||||||
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()),
|
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()));
|
||||||
MathMan.roundInt(location.getZ()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getLocationFull(final org.bukkit.Location location) {
|
/**
|
||||||
|
* Turn a Bukkit {@link org.bukkit.Location} into a PlotSquared {@link Location}.
|
||||||
|
* This copies the entire 6-tuple (world,x,y,z,yaw,pitch).
|
||||||
|
*
|
||||||
|
* @param location Bukkit location
|
||||||
|
* @return PlotSquared location
|
||||||
|
*/
|
||||||
|
@Nonnull public static Location adaptComplete(@Nonnull final org.bukkit.Location location) {
|
||||||
return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
|
return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
|
||||||
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()),
|
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
|
||||||
MathMan.roundInt(location.getZ()), location.getYaw(), location.getPitch());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static org.bukkit.Location getLocation(@Nonnull final Location location) {
|
|
||||||
return new org.bukkit.Location((World) location.getWorld().getPlatformWorld(),
|
|
||||||
location.getX(), location.getY(), location.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static World getWorld(@Nonnull final String string) {
|
|
||||||
return Bukkit.getWorld(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getWorld(@Nonnull final Entity entity) {
|
|
||||||
return entity.getWorld().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Entity> getEntities(@Nonnull final String worldName) {
|
|
||||||
World world = getWorld(worldName);
|
|
||||||
if (world != null) {
|
|
||||||
return world.getEntities();
|
|
||||||
} else {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Location getLocation(@Nonnull final Entity entity) {
|
|
||||||
final org.bukkit.Location location = entity.getLocation();
|
|
||||||
String world = location.getWorld().getName();
|
|
||||||
return Location.at(world, location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull public static Location getLocationFull(@Nonnull final Entity entity) {
|
|
||||||
final org.bukkit.Location location = entity.getLocation();
|
|
||||||
return Location.at(location.getWorld().getName(), MathMan.roundInt(location.getX()),
|
|
||||||
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
|
|
||||||
location.getPitch());
|
location.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Material getMaterial(@Nonnull final BlockState plotBlock) {
|
/**
|
||||||
return BukkitAdapter.adapt(plotBlock.getBlockType());
|
* Turn a PlotSquared {@link Location} into a Bukkit {@link org.bukkit.Location}.
|
||||||
|
* This only copies the 4-tuple (world,x,y,z) and does not include the yaw and the pitch
|
||||||
|
*
|
||||||
|
* @param location PlotSquared location
|
||||||
|
* @return Bukkit location
|
||||||
|
*/
|
||||||
|
@Nonnull public static org.bukkit.Location adapt(@Nonnull final Location location) {
|
||||||
|
return new org.bukkit.Location((World) location.getWorld().getPlatformWorld(), location.getX(),
|
||||||
|
location.getY(), location.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ensureLoaded(final String world, final int x, final int z,
|
/**
|
||||||
final Consumer<Chunk> chunkConsumer) {
|
* Get a Bukkit {@link World} from its name
|
||||||
PaperLib.getChunkAtAsync(getWorld(world), x >> 4, z >> 4, true)
|
*
|
||||||
|
* @param string World name
|
||||||
|
* @return World if it exists, or {@code null}
|
||||||
|
*/
|
||||||
|
@Nullable public static World getWorld(@Nonnull final String string) {
|
||||||
|
return Bukkit.getWorld(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ensureLoaded(@Nonnull final String world, final int x, final int z,
|
||||||
|
@Nonnull final Consumer<Chunk> chunkConsumer) {
|
||||||
|
PaperLib.getChunkAtAsync(Objects.requireNonNull(getWorld(world)),
|
||||||
|
x >> 4, z >> 4, true)
|
||||||
.thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
|
.thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ensureLoaded(final Location location, final Consumer<Chunk> chunkConsumer) {
|
private static void ensureLoaded(@Nonnull final Location location, @Nonnull final Consumer<Chunk> chunkConsumer) {
|
||||||
PaperLib.getChunkAtAsync(getLocation(location), true)
|
PaperLib.getChunkAtAsync(adapt(location), true)
|
||||||
.thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
|
.thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void ensureMainThread(final Consumer<T> consumer, final T value) {
|
private static <T> void ensureMainThread(@Nonnull final Consumer<T> consumer,
|
||||||
|
@Nonnull final T value) {
|
||||||
if (Bukkit.isPrimaryThread()) {
|
if (Bukkit.isPrimaryThread()) {
|
||||||
consumer.accept(value);
|
consumer.accept(value);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTask(BukkitPlatform.getPlugin(BukkitPlatform.class),
|
Bukkit.getScheduler()
|
||||||
() -> consumer.accept(value));
|
.runTask(BukkitPlatform.getPlugin(BukkitPlatform.class), () -> consumer.accept(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,15 +224,17 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
* @return a {@code PlotPlayer}
|
* @return a {@code PlotPlayer}
|
||||||
* @see PlotPlayer#wrap(Object)
|
* @see PlotPlayer#wrap(Object)
|
||||||
*/
|
*/
|
||||||
@Override public PlotPlayer<?> wrapPlayer(UUID uuid) {
|
@Override @Nonnull public PlotPlayer<?> getPlayer(@Nonnull final UUID uuid) {
|
||||||
return PlotPlayer.wrap(Bukkit.getOfflinePlayer(uuid));
|
return PlotPlayer.wrap(Bukkit.getOfflinePlayer(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean isBlockSame(BlockState block1, BlockState block2) {
|
@Override public boolean isBlockSame(@Nonnull final BlockState block1,
|
||||||
|
@Nonnull final BlockState block2) {
|
||||||
if (block1.equals(block2)) {
|
if (block1.equals(block2)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Material mat1 = getMaterial(block1), mat2 = getMaterial(block2);
|
final Material mat1 = BukkitAdapter.adapt(block1.getBlockType());
|
||||||
|
final Material mat2 = BukkitAdapter.adapt(block2.getBlockType());
|
||||||
return mat1 == mat2;
|
return mat1 == mat2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,19 +242,22 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return getWorld(worldName) != null;
|
return getWorld(worldName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void getBiome(String world, int x, int z, final Consumer<BiomeType> result) {
|
@Override public void getBiome(@Nonnull final String world, final int x,
|
||||||
|
final int z, @Nonnull final Consumer<BiomeType> result) {
|
||||||
ensureLoaded(world, x, z,
|
ensureLoaded(world, x, z,
|
||||||
chunk -> result.accept(BukkitAdapter.adapt(getWorld(world).getBiome(x, z))));
|
chunk -> result.accept(BukkitAdapter.adapt(getWorld(world).getBiome(x, z))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public BiomeType getBiomeSynchronous(String world, int x, int z) {
|
@Override @Nonnull public BiomeType getBiomeSynchronous(@Nonnull final String world,
|
||||||
return BukkitAdapter.adapt(getWorld(world).getBiome(x, z));
|
final int x, final int z) {
|
||||||
|
return BukkitAdapter.adapt(Objects.requireNonNull(getWorld(world)).getBiome(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void getHighestBlock(@Nonnull final String world, final int x, final int z,
|
@Override
|
||||||
final IntConsumer result) {
|
public void getHighestBlock(@Nonnull final String world, final int x, final int z,
|
||||||
|
@Nonnull final IntConsumer result) {
|
||||||
ensureLoaded(world, x, z, chunk -> {
|
ensureLoaded(world, x, z, chunk -> {
|
||||||
final World bukkitWorld = getWorld(world);
|
final World bukkitWorld = Objects.requireNonNull(getWorld(world));
|
||||||
// Skip top and bottom block
|
// Skip top and bottom block
|
||||||
int air = 1;
|
int air = 1;
|
||||||
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
|
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
|
||||||
@ -408,8 +281,10 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getHighestBlockSynchronous(String world, int x, int z) {
|
@Override @Nonnegative
|
||||||
final World bukkitWorld = getWorld(world);
|
public int getHighestBlockSynchronous(@Nonnull final String world,
|
||||||
|
final int x, final int z) {
|
||||||
|
final World bukkitWorld = Objects.requireNonNull(getWorld(world));
|
||||||
// Skip top and bottom block
|
// Skip top and bottom block
|
||||||
int air = 1;
|
int air = 1;
|
||||||
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
|
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
|
||||||
@ -430,19 +305,9 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return bukkitWorld.getMaxHeight() - 1;
|
return bukkitWorld.getMaxHeight() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override @Nonnull
|
||||||
public void getSign(@Nonnull final Location location, final Consumer<String[]> result) {
|
public String[] getSignSynchronous(@Nonnull final Location location) {
|
||||||
ensureLoaded(location, chunk -> {
|
Block block = Objects.requireNonNull(getWorld(location.getWorldName()))
|
||||||
final Block block = chunk.getWorld().getBlockAt(getLocation(location));
|
|
||||||
if (block.getState() instanceof Sign) {
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
result.accept(sign.getLines());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @Nullable public String[] getSignSynchronous(@Nonnull final Location location) {
|
|
||||||
Block block = getWorld(location.getWorldName())
|
|
||||||
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
try {
|
try {
|
||||||
return TaskManager.getPlatformImplementation().sync(() -> {
|
return TaskManager.getPlatformImplementation().sync(() -> {
|
||||||
@ -458,7 +323,8 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Location getSpawn(@Nonnull final String world) {
|
@Override @Nonnull
|
||||||
|
public Location getSpawn(@Nonnull final String world) {
|
||||||
final org.bukkit.Location temp = getWorld(world).getSpawnLocation();
|
final org.bukkit.Location temp = getWorld(world).getSpawnLocation();
|
||||||
return Location
|
return Location
|
||||||
.at(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(), temp.getYaw(),
|
.at(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(), temp.getYaw(),
|
||||||
@ -519,27 +385,16 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean isBlockSolid(@Nonnull final BlockState block) {
|
@Override @Nonnull
|
||||||
return block.getBlockType().getMaterial().isSolid();
|
public StringComparison<BlockState>.ComparisonResult getClosestBlock(@Nonnull String name) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getClosestMatchingName(@Nonnull final BlockState block) {
|
|
||||||
try {
|
|
||||||
return getMaterial(block).name();
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @Nullable
|
|
||||||
public StringComparison<BlockState>.ComparisonResult getClosestBlock(String name) {
|
|
||||||
BlockState state = BlockUtil.get(name);
|
BlockState state = BlockUtil.get(name);
|
||||||
return new StringComparison<BlockState>().new ComparisonResult(1, state);
|
return new StringComparison<BlockState>().new ComparisonResult(1, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBiomes(@Nonnull final String worldName, @Nonnull final CuboidRegion region,
|
public void setBiomes(@Nonnull final String worldName,
|
||||||
@Nonnull final BiomeType biomeType) {
|
@Nonnull final CuboidRegion region,
|
||||||
|
@Nonnull final BiomeType biomeType) {
|
||||||
final World world = getWorld(worldName);
|
final World world = getWorld(worldName);
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
logger.warn("[P2] An error occured while setting the biome because the world was null",
|
logger.warn("[P2] An error occured while setting the biome because the world was null",
|
||||||
@ -557,7 +412,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public com.sk89q.worldedit.world.World getWeWorld(String world) {
|
@Override @Nonnull public com.sk89q.worldedit.world.World getWeWorld(@Nonnull final String world) {
|
||||||
return new BukkitWorld(Bukkit.getWorld(world));
|
return new BukkitWorld(Bukkit.getWorld(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,42 +421,49 @@ 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,
|
||||||
|
@Nonnull final Consumer<BlockState> result) {
|
||||||
ensureLoaded(location, chunk -> {
|
ensureLoaded(location, chunk -> {
|
||||||
final World world = getWorld(location.getWorldName());
|
final World world = getWorld(location.getWorldName());
|
||||||
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
final Block block = Objects.requireNonNull(world)
|
||||||
result.accept(BukkitAdapter.asBlockType(block.getType()).getDefaultState());
|
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
|
result.accept(Objects.requireNonNull(BukkitAdapter
|
||||||
|
.asBlockType(block.getType())).getDefaultState());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public BlockState getBlockSynchronous(@Nonnull final Location location) {
|
@Override @Nonnull public BlockState getBlockSynchronous(@Nonnull final Location location) {
|
||||||
final World world = getWorld(location.getWorldName());
|
final World world = getWorld(location.getWorldName());
|
||||||
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
final Block block = Objects.requireNonNull(world)
|
||||||
return BukkitAdapter.asBlockType(block.getType()).getDefaultState();
|
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
|
return Objects.requireNonNull(BukkitAdapter
|
||||||
|
.asBlockType(block.getType())).getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getMainWorld() {
|
@Override @Nonnegative public double getHealth(@Nonnull final PlotPlayer player) {
|
||||||
return Bukkit.getWorlds().get(0).getName();
|
return Objects.requireNonNull(Bukkit
|
||||||
|
.getPlayer(player.getUUID())).getHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public double getHealth(PlotPlayer player) {
|
@Override @Nonnegative public int getFoodLevel(@Nonnull final PlotPlayer<?> player) {
|
||||||
return Bukkit.getPlayer(player.getUUID()).getHealth();
|
return Objects.requireNonNull(Bukkit.getPlayer(player.getUUID()))
|
||||||
|
.getFoodLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getFoodLevel(PlotPlayer player) {
|
@Override public void setHealth(@Nonnull final PlotPlayer<?> player,
|
||||||
return Bukkit.getPlayer(player.getUUID()).getFoodLevel();
|
@Nonnegative final double health) {
|
||||||
|
Objects.requireNonNull(Bukkit.getPlayer(player.getUUID()))
|
||||||
|
.setHealth(health);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setHealth(PlotPlayer player, double health) {
|
@Override public void setFoodLevel(@Nonnull final PlotPlayer<?> player,
|
||||||
Bukkit.getPlayer(player.getUUID()).setHealth(health);
|
@Nonnegative final int foodLevel) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void setFoodLevel(PlotPlayer player, int foodLevel) {
|
|
||||||
Bukkit.getPlayer(player.getUUID()).setFoodLevel(foodLevel);
|
Bukkit.getPlayer(player.getUUID()).setFoodLevel(foodLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Set<com.sk89q.worldedit.world.entity.EntityType> getTypesInCategory(
|
@Override @Nonnull
|
||||||
final String category) {
|
public Set<com.sk89q.worldedit.world.entity.EntityType> getTypesInCategory(
|
||||||
|
@Nonnull final String category) {
|
||||||
final Collection<Class<?>> allowedInterfaces = new HashSet<>();
|
final Collection<Class<?>> allowedInterfaces = new HashSet<>();
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case "animal": {
|
case "animal": {
|
||||||
@ -681,7 +543,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Collection<BlockType> getTileEntityTypes() {
|
@Override @Nonnull public Collection<BlockType> getTileEntityTypes() {
|
||||||
if (this.tileEntityTypes.isEmpty()) {
|
if (this.tileEntityTypes.isEmpty()) {
|
||||||
// Categories
|
// Categories
|
||||||
tileEntityTypes.addAll(BlockCategories.BANNERS.getAll());
|
tileEntityTypes.addAll(BlockCategories.BANNERS.getAll());
|
||||||
@ -704,8 +566,11 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return this.tileEntityTypes;
|
return this.tileEntityTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getTileEntityCount(String world, BlockVector2 chunk) {
|
@Override @Nonnegative
|
||||||
return Bukkit.getWorld(world).getChunkAt(chunk.getBlockX(), chunk.getBlockZ())
|
public int getTileEntityCount(@Nonnull final String world,
|
||||||
|
@Nonnull final BlockVector2 chunk) {
|
||||||
|
return Objects.requireNonNull(getWorld(world)).
|
||||||
|
getChunkAt(chunk.getBlockX(), chunk.getBlockZ())
|
||||||
.getTileEntities().length;
|
.getTileEntities().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class ContentMap {
|
|||||||
|
|
||||||
void saveEntitiesOut(Chunk chunk, CuboidRegion region) {
|
void saveEntitiesOut(Chunk chunk, CuboidRegion region) {
|
||||||
for (Entity entity : chunk.getEntities()) {
|
for (Entity entity : chunk.getEntities()) {
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
int x = location.getX();
|
int x = location.getX();
|
||||||
int z = location.getZ();
|
int z = location.getZ();
|
||||||
if (BukkitChunkManager.isIn(region, x, z)) {
|
if (BukkitChunkManager.isIn(region, x, z)) {
|
||||||
@ -99,7 +99,7 @@ public class ContentMap {
|
|||||||
void saveEntitiesIn(Chunk chunk, CuboidRegion region, int offsetX, int offsetZ,
|
void saveEntitiesIn(Chunk chunk, CuboidRegion region, int offsetX, int offsetZ,
|
||||||
boolean delete) {
|
boolean delete) {
|
||||||
for (Entity entity : chunk.getEntities()) {
|
for (Entity entity : chunk.getEntities()) {
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
int x = location.getX();
|
int x = location.getX();
|
||||||
int z = location.getZ();
|
int z = location.getZ();
|
||||||
if (!BukkitChunkManager.isIn(region, x, z)) {
|
if (!BukkitChunkManager.isIn(region, x, z)) {
|
||||||
|
@ -137,7 +137,7 @@ public interface PlotPlatform<P> extends ILogger {
|
|||||||
*
|
*
|
||||||
* @param player the player to remove
|
* @param player the player to remove
|
||||||
*/
|
*/
|
||||||
void unregister(PlotPlayer player);
|
void unregister(PlotPlayer<?> player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the generator wrapper for a world (world) and generator (name).
|
* Gets the generator wrapper for a world (world) and generator (name).
|
||||||
|
@ -503,7 +503,7 @@ public class PlotSquared {
|
|||||||
} else {
|
} else {
|
||||||
extra.add(plot);
|
extra.add(plot);
|
||||||
}
|
}
|
||||||
} else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) {
|
} else if (Math.abs(plot.getId().getX()) > 15446 || Math.abs(plot.getId().getY()) > 15446) {
|
||||||
extra.add(plot);
|
extra.add(plot);
|
||||||
} else {
|
} else {
|
||||||
overflow.add(plot);
|
overflow.add(plot);
|
||||||
@ -578,7 +578,7 @@ public class PlotSquared {
|
|||||||
} else {
|
} else {
|
||||||
extra.add(plot);
|
extra.add(plot);
|
||||||
}
|
}
|
||||||
} else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) {
|
} else if (Math.abs(plot.getId().getX()) > 15446 || Math.abs(plot.getId().getY()) > 15446) {
|
||||||
extra.add(plot);
|
extra.add(plot);
|
||||||
} else {
|
} else {
|
||||||
overflow.add(plot);
|
overflow.add(plot);
|
||||||
@ -718,8 +718,8 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
if (plot.getArea().removePlot(plot.getId())) {
|
if (plot.getArea().removePlot(plot.getId())) {
|
||||||
PlotId last = (PlotId) plot.getArea().getMeta("lastPlot");
|
PlotId last = (PlotId) plot.getArea().getMeta("lastPlot");
|
||||||
int last_max = Math.max(Math.abs(last.x), Math.abs(last.y));
|
int last_max = Math.max(Math.abs(last.getX()), Math.abs(last.getY()));
|
||||||
int this_max = Math.max(Math.abs(plot.getId().x), Math.abs(plot.getId().y));
|
int this_max = Math.max(Math.abs(plot.getId().getX()), Math.abs(plot.getId().getY()));
|
||||||
if (this_max < last_max) {
|
if (this_max < last_max) {
|
||||||
plot.getArea().setMeta("lastPlot", plot.getId());
|
plot.getArea().setMeta("lastPlot", plot.getId());
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ public class Area extends SubCommand {
|
|||||||
BlockVector3.at(playerSelectionMin.getX(), 0, playerSelectionMin.getZ()),
|
BlockVector3.at(playerSelectionMin.getX(), 0, playerSelectionMin.getZ()),
|
||||||
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 = PlotId.of(1, 1);
|
||||||
final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory.create(player.getLocation().getWorldName(), args[1],
|
final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory.create(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
|
||||||
@ -315,8 +315,8 @@ public class Area extends SubCommand {
|
|||||||
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area)
|
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area)
|
||||||
.plotManager(PlotSquared.platform().getPluginName())
|
.plotManager(PlotSquared.platform().getPluginName())
|
||||||
.generatorName(PlotSquared.platform().getPluginName())
|
.generatorName(PlotSquared.platform().getPluginName())
|
||||||
.minimumId(new PlotId(1, 1))
|
.minimumId(PlotId.of(1, 1))
|
||||||
.maximumId(new PlotId(numX, numZ));
|
.maximumId(PlotId.of(numX, numZ));
|
||||||
final String path =
|
final String path =
|
||||||
"worlds." + area.getWorldName() + ".areas." + area.getId() + '-'
|
"worlds." + area.getWorldName() + ".areas." + area.getId() + '-'
|
||||||
+ builder.minimumId() + '-' + builder.maximumId();
|
+ builder.minimumId() + '-' + builder.maximumId();
|
||||||
@ -542,7 +542,7 @@ public class Area extends SubCommand {
|
|||||||
PlotId min = area.getMin();
|
PlotId min = area.getMin();
|
||||||
PlotId max = area.getMax();
|
PlotId max = area.getMax();
|
||||||
name = area.getWorldName() + ';' + area.getId() + ';' + min + ';' + max;
|
name = area.getWorldName() + ';' + area.getId() + ';' + min + ';' + max;
|
||||||
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
|
int size = (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1);
|
||||||
percent = claimed == 0 ? 0 : size / (double) claimed;
|
percent = claimed == 0 ? 0 : size / (double) claimed;
|
||||||
region = area.getRegion().toString();
|
region = area.getRegion().toString();
|
||||||
} else {
|
} else {
|
||||||
@ -595,7 +595,7 @@ public class Area extends SubCommand {
|
|||||||
PlotId max = area.getMax();
|
PlotId max = area.getMax();
|
||||||
name = area.getWorldName() + ';' + area.getId() + ';' + min + ';'
|
name = area.getWorldName() + ';' + area.getId() + ';' + min + ';'
|
||||||
+ max;
|
+ max;
|
||||||
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
|
int size = (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1);
|
||||||
percent = claimed == 0 ? 0 : size / (double) claimed;
|
percent = claimed == 0 ? 0 : size / (double) claimed;
|
||||||
region = area.getRegion().toString();
|
region = area.getRegion().toString();
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +64,7 @@ public abstract class Argument<T> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Argument<PlotId> PlotID =
|
public static final Argument<PlotId> PlotID =
|
||||||
new Argument<PlotId>("PlotID", new PlotId(-6, 3)) {
|
new Argument<PlotId>("PlotID", PlotId.of(-6, 3)) {
|
||||||
@Override public PlotId parse(String in) {
|
@Override public PlotId parse(String in) {
|
||||||
return PlotId.fromString(in);
|
return PlotId.fromString(in);
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,6 @@ public class Auto extends SubCommand {
|
|||||||
this.eventDispatcher = eventDispatcher;
|
this.eventDispatcher = eventDispatcher;
|
||||||
this.econHandler = econHandler;
|
this.econHandler = econHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
|
|
||||||
return id.getNextId(step);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean checkAllowedPlots(PlotPlayer player, PlotArea plotarea,
|
public static boolean checkAllowedPlots(PlotPlayer player, PlotArea plotarea,
|
||||||
@Nullable Integer allowedPlots, int sizeX, int sizeZ) {
|
@Nullable Integer allowedPlots, int sizeX, int sizeZ) {
|
||||||
@ -298,20 +294,19 @@ public class Auto extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
PlotId start = plotarea.getMeta("lastPlot", new PlotId(0, 0)).getNextId(1);
|
PlotId start = plotarea.getMeta("lastPlot", PlotId.of(0, 0)).getNextId();
|
||||||
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
|
PlotId end = PlotId.of(start.getX() + size_x - 1, start.getY() + size_z - 1);
|
||||||
if (plotarea.canClaim(player, start, end)) {
|
if (plotarea.canClaim(player, start, end)) {
|
||||||
plotarea.setMeta("lastPlot", start);
|
plotarea.setMeta("lastPlot", start);
|
||||||
for (int i = start.x; i <= end.x; i++) {
|
|
||||||
for (int j = start.y; j <= end.y; j++) {
|
for (final PlotId plotId : PlotId.PlotRangeIterator.range(start, end)) {
|
||||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
final Plot plot = plotarea.getPlot(plotId);
|
||||||
boolean teleport = i == end.x && j == end.y;
|
if (plot == null) {
|
||||||
if (plot == null) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
plot.claim(player, teleport, null);
|
|
||||||
}
|
}
|
||||||
|
plot.claim(player, plotId.equals(end), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<PlotId> plotIds = MainUtil.getPlotSelectionIds(start, end);
|
ArrayList<PlotId> plotIds = MainUtil.getPlotSelectionIds(start, end);
|
||||||
final PlotId pos1 = plotIds.get(0);
|
final PlotId pos1 = plotIds.get(0);
|
||||||
final PlotAutoMergeEvent mergeEvent = this.eventDispatcher
|
final PlotAutoMergeEvent mergeEvent = this.eventDispatcher
|
||||||
|
@ -137,9 +137,9 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.ALIAS_IS_TAKEN);
|
MainUtil.sendMessage(player, Captions.ALIAS_IS_TAKEN);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pos2.x < pos1.x || pos2.y < pos1.y) {
|
if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) {
|
||||||
PlotId tmp = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y));
|
PlotId tmp = PlotId.of(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()));
|
||||||
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
|
pos2 = PlotId.of(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()));
|
||||||
pos1 = tmp;
|
pos1 = tmp;
|
||||||
}
|
}
|
||||||
//check if overlap
|
//check if overlap
|
||||||
@ -265,9 +265,9 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pos2.x < pos1.x || pos2.y < pos1.y) {
|
if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) {
|
||||||
pos1 = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y));
|
pos1 = PlotId.of(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()));
|
||||||
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
|
pos2 = PlotId.of(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()));
|
||||||
}
|
}
|
||||||
// check if in cluster
|
// check if in cluster
|
||||||
PlotArea area = player.getApplicablePlotArea();
|
PlotArea area = player.getApplicablePlotArea();
|
||||||
@ -326,7 +326,7 @@ public class Cluster extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
current = player.getPlayerClusterCount(player.getLocation().getWorldName());
|
current = player.getPlayerClusterCount(player.getLocation().getWorldName());
|
||||||
}
|
}
|
||||||
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
current -= cluster.getArea() + (1 + pos2.getX() - pos1.getX()) * (1 + pos2.getY() - pos1.getY());
|
||||||
int allowed = Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER,
|
int allowed = Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER,
|
||||||
Settings.Limit.MAX_PLOTS);
|
Settings.Limit.MAX_PLOTS);
|
||||||
if (current + cluster.getArea() > allowed) {
|
if (current + cluster.getArea() > allowed) {
|
||||||
@ -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()
|
||||||
.getWorldName()).ownedBy(uuid).asCollection()) {
|
.getWorldName()).ownedBy(uuid)) {
|
||||||
PlotCluster current = plot.getCluster();
|
PlotCluster current = plot.getCluster();
|
||||||
if (current != null && current.equals(cluster)) {
|
if (current != null && current.equals(cluster)) {
|
||||||
plot.unclaim();
|
plot.unclaim();
|
||||||
@ -513,7 +513,7 @@ public class Cluster extends SubCommand {
|
|||||||
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().getWorldName())
|
for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorldName())
|
||||||
.ownedBy(uuid).asCollection()) {
|
.ownedBy(uuid)) {
|
||||||
PlotCluster current = plot.getCluster();
|
PlotCluster current = plot.getCluster();
|
||||||
if (current != null && current.equals(cluster)) {
|
if (current != null && current.equals(cluster)) {
|
||||||
plot.unclaim();
|
plot.unclaim();
|
||||||
@ -648,8 +648,8 @@ public class Cluster extends SubCommand {
|
|||||||
owner = username;
|
owner = username;
|
||||||
}
|
}
|
||||||
String name = cluster.getName();
|
String name = cluster.getName();
|
||||||
String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (
|
String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + (
|
||||||
cluster.getP2().y - cluster.getP1().y + 1);
|
cluster.getP2().getY() - cluster.getP1().getY() + 1);
|
||||||
String rights = cluster.isAdded(player.getUUID()) + "";
|
String rights = cluster.isAdded(player.getUUID()) + "";
|
||||||
String message = Captions.CLUSTER_INFO.getTranslated();
|
String message = Captions.CLUSTER_INFO.getTranslated();
|
||||||
message = message.replaceAll("%id%", id);
|
message = message.replaceAll("%id%", id);
|
||||||
|
@ -138,13 +138,13 @@ public class Condense extends SubCommand {
|
|||||||
}
|
}
|
||||||
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
|
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
|
||||||
final List<PlotId> free = new ArrayList<>();
|
final List<PlotId> free = new ArrayList<>();
|
||||||
PlotId start = new PlotId(0, 0);
|
PlotId start = PlotId.of(0, 0);
|
||||||
while (start.x <= minimumRadius && start.y <= minimumRadius) {
|
while (start.getX() <= minimumRadius && start.getY() <= minimumRadius) {
|
||||||
Plot plot = area.getPlotAbs(start);
|
Plot plot = area.getPlotAbs(start);
|
||||||
if (plot != null && !plot.hasOwner()) {
|
if (plot != null && !plot.hasOwner()) {
|
||||||
free.add(plot.getId());
|
free.add(plot.getId());
|
||||||
}
|
}
|
||||||
start = Auto.getNextPlotId(start, 1);
|
start = start.getNextId();
|
||||||
}
|
}
|
||||||
if (free.isEmpty() || toMove.isEmpty()) {
|
if (free.isEmpty() || toMove.isEmpty()) {
|
||||||
MainUtil.sendMessage(player, "NO FREE PLOTS FOUND");
|
MainUtil.sendMessage(player, "NO FREE PLOTS FOUND");
|
||||||
@ -249,8 +249,8 @@ public class Condense extends SubCommand {
|
|||||||
public Set<PlotId> getPlots(Collection<Plot> plots, int radius) {
|
public Set<PlotId> getPlots(Collection<Plot> plots, int radius) {
|
||||||
HashSet<PlotId> outside = new HashSet<>();
|
HashSet<PlotId> outside = new HashSet<>();
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
if (plot.getId().x > radius || plot.getId().x < -radius || plot.getId().y > radius
|
if (plot.getId().getX() > radius || plot.getId().getX() < -radius || plot.getId().getY() > radius
|
||||||
|| plot.getId().y < -radius) {
|
|| plot.getId().getY() < -radius) {
|
||||||
outside.add(plot.getId());
|
outside.add(plot.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,9 +158,7 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
newId.toCommaSeparatedString());
|
newId.toCommaSeparatedString());
|
||||||
worldFile.renameTo(newFile);
|
worldFile.renameTo(newFile);
|
||||||
}
|
}
|
||||||
id.x = newId.x;
|
plot.setId(newId.copy());
|
||||||
id.y = newId.y;
|
|
||||||
id.recalculateHash();
|
|
||||||
plot.setArea(pa);
|
plot.setArea(pa);
|
||||||
plots.add(plot);
|
plots.add(plot);
|
||||||
continue;
|
continue;
|
||||||
|
@ -70,7 +70,7 @@ public class DebugImportWorlds extends Command {
|
|||||||
return CompletableFuture.completedFuture(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
|
SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
|
||||||
PlotId id = new PlotId(0, 0);
|
PlotId id = PlotId.of(0, 0);
|
||||||
File container = PlotSquared.platform().getWorldContainer();
|
File container = PlotSquared.platform().getWorldContainer();
|
||||||
if (container.equals(new File("."))) {
|
if (container.equals(new File("."))) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
@ -92,7 +92,7 @@ public class DebugImportWorlds extends Command {
|
|||||||
UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
while (new File(container, id.toCommaSeparatedString()).exists()) {
|
while (new File(container, id.toCommaSeparatedString()).exists()) {
|
||||||
id = Auto.getNextPlotId(id, 1);
|
id = id.getNextId();
|
||||||
}
|
}
|
||||||
File newDir = new File(container, id.toCommaSeparatedString());
|
File newDir = new File(container, id.toCommaSeparatedString());
|
||||||
if (folder.renameTo(newDir)) {
|
if (folder.renameTo(newDir)) {
|
||||||
|
@ -118,7 +118,7 @@ public class Info extends SubCommand {
|
|||||||
// Unclaimed?
|
// Unclaimed?
|
||||||
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
||||||
MainUtil.sendMessage(player, Captions.PLOT_INFO_UNCLAIMED,
|
MainUtil.sendMessage(player, Captions.PLOT_INFO_UNCLAIMED,
|
||||||
plot.getId().x + ";" + plot.getId().y);
|
plot.getId().getX() + ";" + plot.getId().getY());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String info = Captions.PLOT_INFO_FORMAT.getTranslated();
|
String info = Captions.PLOT_INFO_FORMAT.getTranslated();
|
||||||
|
@ -94,7 +94,7 @@ public class Save extends SubCommand {
|
|||||||
PlotId id = plot.getId();
|
PlotId id = plot.getId();
|
||||||
String world1 = plot.getArea().toString().replaceAll(";", "-")
|
String world1 = plot.getArea().toString().replaceAll(";", "-")
|
||||||
.replaceAll("[^A-Za-z0-9]", "");
|
.replaceAll("[^A-Za-z0-9]", "");
|
||||||
final String file = time + '_' + world1 + '_' + id.x + '_' + id.y + '_' + size;
|
final String file = time + '_' + world1 + '_' + id.getX() + '_' + id.getY() + '_' + size;
|
||||||
UUID uuid = player.getUUID();
|
UUID uuid = player.getUUID();
|
||||||
schematicHandler.upload(value, uuid, file, new RunnableVal<URL>() {
|
schematicHandler.upload(value, uuid, file, new RunnableVal<URL>() {
|
||||||
@Override public void run(URL url) {
|
@Override public void run(URL url) {
|
||||||
|
@ -58,7 +58,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.getWorldName()).asCollection()) {
|
for (Plot plot : PlotQuery.newQuery().inWorld(location.getWorldName())) {
|
||||||
double current = plot.getCenterSynchronous().getEuclideanDistanceSquared(location);
|
double current = plot.getCenterSynchronous().getEuclideanDistanceSquared(location);
|
||||||
if (current < distance) {
|
if (current < distance) {
|
||||||
distance = (int) current;
|
distance = (int) current;
|
||||||
|
@ -173,7 +173,7 @@ public class Trim extends SubCommand {
|
|||||||
int bz = cbz << 4;
|
int bz = cbz << 4;
|
||||||
CuboidRegion region =
|
CuboidRegion region =
|
||||||
RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
|
RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
|
||||||
for (Plot plot : PlotQuery.newQuery().inWorld(world).asCollection()) {
|
for (Plot plot : PlotQuery.newQuery().inWorld(world)) {
|
||||||
Location bot = plot.getBottomAbs();
|
Location bot = plot.getBottomAbs();
|
||||||
Location top = plot.getExtendedTopAbs();
|
Location top = plot.getExtendedTopAbs();
|
||||||
CuboidRegion plotReg = RegionUtil
|
CuboidRegion plotReg = RegionUtil
|
||||||
|
@ -573,8 +573,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
addPlotTask(plot, new UniqueStatement("setOwner") {
|
addPlotTask(plot, new UniqueStatement("setOwner") {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, uuid.toString());
|
statement.setString(1, uuid.toString());
|
||||||
statement.setInt(2, plot.getId().x);
|
statement.setInt(2, plot.getId().getX());
|
||||||
statement.setInt(3, plot.getId().y);
|
statement.setInt(3, plot.getId().getY());
|
||||||
statement.setString(4, plot.getArea().toString());
|
statement.setString(4, plot.getArea().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,7 +610,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
int id = result.getInt("id");
|
int id = result.getInt("id");
|
||||||
int x = result.getInt("plot_id_x");
|
int x = result.getInt("plot_id_x");
|
||||||
int y = result.getInt("plot_id_z");
|
int y = result.getInt("plot_id_z");
|
||||||
PlotId plotId = new PlotId(x, y);
|
PlotId plotId = PlotId.of(x, y);
|
||||||
Plot plot = plotMap.get(plotId);
|
Plot plot = plotMap.get(plotId);
|
||||||
idMap.put(plotId, id);
|
idMap.put(plotId, id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
@ -759,8 +759,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override public void setMySQL(PreparedStatement stmt, int i, Plot plot)
|
@Override public void setMySQL(PreparedStatement stmt, int i, Plot plot)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
stmt.setInt(i * 5 + 1, plot.getId().x);
|
stmt.setInt(i * 5 + 1, plot.getId().getX());
|
||||||
stmt.setInt(i * 5 + 2, plot.getId().y);
|
stmt.setInt(i * 5 + 2, plot.getId().getY());
|
||||||
try {
|
try {
|
||||||
stmt.setString(i * 5 + 3, plot.getOwnerAbs().toString());
|
stmt.setString(i * 5 + 3, plot.getOwnerAbs().toString());
|
||||||
} catch (SQLException ignored) {
|
} catch (SQLException ignored) {
|
||||||
@ -773,8 +773,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override public void setSQLite(PreparedStatement stmt, int i, Plot plot)
|
@Override public void setSQLite(PreparedStatement stmt, int i, Plot plot)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
stmt.setNull(i * 6 + 1, 4);
|
stmt.setNull(i * 6 + 1, 4);
|
||||||
stmt.setInt(i * 6 + 2, plot.getId().x);
|
stmt.setInt(i * 6 + 2, plot.getId().getX());
|
||||||
stmt.setInt(i * 6 + 3, plot.getId().y);
|
stmt.setInt(i * 6 + 3, plot.getId().getY());
|
||||||
try {
|
try {
|
||||||
stmt.setString(i * 6 + 4, plot.getOwnerAbs().toString());
|
stmt.setString(i * 6 + 4, plot.getOwnerAbs().toString());
|
||||||
} catch (SQLException ignored) {
|
} catch (SQLException ignored) {
|
||||||
@ -785,8 +785,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException {
|
@Override public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException {
|
||||||
stmt.setInt(1, plot.getId().x);
|
stmt.setInt(1, plot.getId().getX());
|
||||||
stmt.setInt(2, plot.getId().y);
|
stmt.setInt(2, plot.getId().getY());
|
||||||
stmt.setString(3, plot.getOwnerAbs().toString());
|
stmt.setString(3, plot.getOwnerAbs().toString());
|
||||||
stmt.setString(4, plot.getArea().toString());
|
stmt.setString(4, plot.getArea().toString());
|
||||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
@ -1016,14 +1016,14 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure) {
|
public void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure) {
|
||||||
addPlotTask(plot, new UniqueStatement("createPlotSafe_" + plot.hashCode()) {
|
addPlotTask(plot, new UniqueStatement("createPlotSafe_" + plot.hashCode()) {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, plot.getId().x);
|
statement.setInt(1, plot.getId().getX());
|
||||||
statement.setInt(2, plot.getId().y);
|
statement.setInt(2, plot.getId().getY());
|
||||||
statement.setString(3, plot.getOwnerAbs().toString());
|
statement.setString(3, plot.getOwnerAbs().toString());
|
||||||
statement.setString(4, plot.getArea().toString());
|
statement.setString(4, plot.getArea().toString());
|
||||||
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
statement.setString(6, plot.getArea().toString());
|
statement.setString(6, plot.getArea().toString());
|
||||||
statement.setInt(7, plot.getId().x);
|
statement.setInt(7, plot.getId().getX());
|
||||||
statement.setInt(8, plot.getId().y);
|
statement.setInt(8, plot.getId().getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1085,8 +1085,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override public void createPlotAndSettings(final Plot plot, Runnable whenDone) {
|
@Override public void createPlotAndSettings(final Plot plot, Runnable whenDone) {
|
||||||
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
|
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, plot.getId().x);
|
statement.setInt(1, plot.getId().getX());
|
||||||
statement.setInt(2, plot.getId().y);
|
statement.setInt(2, plot.getId().getY());
|
||||||
statement.setString(3, plot.getOwnerAbs().toString());
|
statement.setString(3, plot.getOwnerAbs().toString());
|
||||||
statement.setString(4, plot.getArea().toString());
|
statement.setString(4, plot.getArea().toString());
|
||||||
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
@ -1436,10 +1436,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
try (PreparedStatement stmt = this.connection.prepareStatement(
|
try (PreparedStatement stmt = this.connection.prepareStatement(
|
||||||
"SELECT `id` FROM `" + this.prefix
|
"SELECT `id` FROM `" + this.prefix
|
||||||
+ "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC")) {
|
+ "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC")) {
|
||||||
stmt.setInt(1, cluster.getP1().x);
|
stmt.setInt(1, cluster.getP1().getX());
|
||||||
stmt.setInt(2, cluster.getP1().y);
|
stmt.setInt(2, cluster.getP1().getY());
|
||||||
stmt.setInt(3, cluster.getP2().x);
|
stmt.setInt(3, cluster.getP2().getX());
|
||||||
stmt.setInt(4, cluster.getP2().y);
|
stmt.setInt(4, cluster.getP2().getY());
|
||||||
stmt.setString(5, cluster.area.toString());
|
stmt.setString(5, cluster.area.toString());
|
||||||
try (ResultSet resultSet = stmt.executeQuery()) {
|
try (ResultSet resultSet = stmt.executeQuery()) {
|
||||||
c_id = Integer.MAX_VALUE;
|
c_id = Integer.MAX_VALUE;
|
||||||
@ -1475,8 +1475,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
try (PreparedStatement statement = this.connection.prepareStatement(
|
try (PreparedStatement statement = this.connection.prepareStatement(
|
||||||
"SELECT `id` FROM `" + this.prefix
|
"SELECT `id` FROM `" + this.prefix
|
||||||
+ "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC")) {
|
+ "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC")) {
|
||||||
statement.setInt(1, plot.getId().x);
|
statement.setInt(1, plot.getId().getX());
|
||||||
statement.setInt(2, plot.getId().y);
|
statement.setInt(2, plot.getId().getY());
|
||||||
statement.setString(3, plot.getArea().toString());
|
statement.setString(3, plot.getArea().toString());
|
||||||
try (ResultSet resultSet = statement.executeQuery()) {
|
try (ResultSet resultSet = statement.executeQuery()) {
|
||||||
id = Integer.MAX_VALUE;
|
id = Integer.MAX_VALUE;
|
||||||
@ -1745,7 +1745,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ this.prefix + "plot`")) {
|
+ this.prefix + "plot`")) {
|
||||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
PlotId plot_id = new PlotId(resultSet.getInt("plot_id_x"),
|
PlotId plot_id = PlotId.of(resultSet.getInt("plot_id_x"),
|
||||||
resultSet.getInt("plot_id_z"));
|
resultSet.getInt("plot_id_z"));
|
||||||
id = resultSet.getInt("id");
|
id = resultSet.getInt("id");
|
||||||
String areaID = resultSet.getString("world");
|
String areaID = resultSet.getString("world");
|
||||||
@ -2094,8 +2094,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override public void movePlot(final Plot original, final Plot newPlot) {
|
@Override public void movePlot(final Plot original, final Plot newPlot) {
|
||||||
addPlotTask(original, new UniqueStatement("movePlot") {
|
addPlotTask(original, new UniqueStatement("movePlot") {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, newPlot.getId().x);
|
statement.setInt(1, newPlot.getId().getX());
|
||||||
statement.setInt(2, newPlot.getId().y);
|
statement.setInt(2, newPlot.getId().getY());
|
||||||
statement.setString(3, newPlot.getArea().toString());
|
statement.setString(3, newPlot.getArea().toString());
|
||||||
statement.setInt(4, getId(original));
|
statement.setInt(4, getId(original));
|
||||||
}
|
}
|
||||||
@ -2245,7 +2245,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try (ResultSet r = stmt.executeQuery()) {
|
try (ResultSet r = stmt.executeQuery()) {
|
||||||
ids = new HashSet<>();
|
ids = new HashSet<>();
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
PlotId plot_id = PlotId.of(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||||
if (plots.contains(plot_id)) {
|
if (plots.contains(plot_id)) {
|
||||||
ids.add(r.getInt("id"));
|
ids.add(r.getInt("id"));
|
||||||
}
|
}
|
||||||
@ -2259,7 +2259,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
for (Iterator<PlotId> iterator = plots.iterator(); iterator.hasNext(); ) {
|
for (Iterator<PlotId> iterator = plots.iterator(); iterator.hasNext(); ) {
|
||||||
PlotId plotId = iterator.next();
|
PlotId plotId = iterator.next();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
PlotId id = new PlotId(plotId.x, plotId.y);
|
PlotId id = PlotId.of(plotId.getX(), plotId.getY());
|
||||||
area.removePlot(id);
|
area.removePlot(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2695,9 +2695,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
int id;
|
int id;
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
PlotId pos1 =
|
PlotId pos1 =
|
||||||
new PlotId(resultSet.getInt("pos1_x"), resultSet.getInt("pos1_z"));
|
PlotId.of(resultSet.getInt("pos1_x"), resultSet.getInt("pos1_z"));
|
||||||
PlotId pos2 =
|
PlotId pos2 =
|
||||||
new PlotId(resultSet.getInt("pos2_x"), resultSet.getInt("pos2_z"));
|
PlotId.of(resultSet.getInt("pos2_x"), resultSet.getInt("pos2_z"));
|
||||||
id = resultSet.getInt("id");
|
id = resultSet.getInt("id");
|
||||||
String areaid = resultSet.getString("world");
|
String areaid = resultSet.getString("world");
|
||||||
if (!areas.contains(areaid)) {
|
if (!areas.contains(areaid)) {
|
||||||
@ -2854,10 +2854,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override public void createCluster(final PlotCluster cluster) {
|
@Override public void createCluster(final PlotCluster cluster) {
|
||||||
addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
|
addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, cluster.getP1().x);
|
statement.setInt(1, cluster.getP1().getX());
|
||||||
statement.setInt(2, cluster.getP1().y);
|
statement.setInt(2, cluster.getP1().getY());
|
||||||
statement.setInt(3, cluster.getP2().x);
|
statement.setInt(3, cluster.getP2().getX());
|
||||||
statement.setInt(4, cluster.getP2().y);
|
statement.setInt(4, cluster.getP2().getY());
|
||||||
statement.setString(5, cluster.owner.toString());
|
statement.setString(5, cluster.owner.toString());
|
||||||
statement.setString(6, cluster.area.toString());
|
statement.setString(6, cluster.area.toString());
|
||||||
}
|
}
|
||||||
@ -2895,17 +2895,17 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void resizeCluster(final PlotCluster current, PlotId min, PlotId max) {
|
@Override public void resizeCluster(final PlotCluster current, PlotId min, PlotId max) {
|
||||||
final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y);
|
final PlotId pos1 = PlotId.of(current.getP1().getX(), current.getP1().getY());
|
||||||
final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y);
|
final PlotId pos2 = PlotId.of(current.getP2().getX(), current.getP2().getY());
|
||||||
current.setP1(min);
|
current.setP1(min);
|
||||||
current.setP2(max);
|
current.setP2(max);
|
||||||
|
|
||||||
addClusterTask(current, new UniqueStatement("resizeCluster") {
|
addClusterTask(current, new UniqueStatement("resizeCluster") {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, pos1.x);
|
statement.setInt(1, pos1.getX());
|
||||||
statement.setInt(2, pos1.y);
|
statement.setInt(2, pos1.getY());
|
||||||
statement.setInt(3, pos2.x);
|
statement.setInt(3, pos2.getX());
|
||||||
statement.setInt(4, pos2.y);
|
statement.setInt(4, pos2.getY());
|
||||||
statement.setInt(5, getClusterId(current));
|
statement.setInt(5, getClusterId(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3141,10 +3141,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) {
|
+ "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) {
|
||||||
stmt.setString(1, newWorld);
|
stmt.setString(1, newWorld);
|
||||||
stmt.setString(2, oldWorld);
|
stmt.setString(2, oldWorld);
|
||||||
stmt.setInt(3, min.x);
|
stmt.setInt(3, min.getX());
|
||||||
stmt.setInt(4, max.x);
|
stmt.setInt(4, max.getX());
|
||||||
stmt.setInt(5, min.y);
|
stmt.setInt(5, min.getY());
|
||||||
stmt.setInt(6, max.y);
|
stmt.setInt(6, max.getY());
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -3154,10 +3154,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ "cluster` SET `world` = ? WHERE `world` = ? AND `pos1_x` <= ? AND `pos1_z` <= ? AND `pos2_x` >= ? AND `pos2_z` >= ?")) {
|
+ "cluster` SET `world` = ? WHERE `world` = ? AND `pos1_x` <= ? AND `pos1_z` <= ? AND `pos2_x` >= ? AND `pos2_z` >= ?")) {
|
||||||
stmt.setString(1, newWorld);
|
stmt.setString(1, newWorld);
|
||||||
stmt.setString(2, oldWorld);
|
stmt.setString(2, oldWorld);
|
||||||
stmt.setInt(3, max.x);
|
stmt.setInt(3, max.getX());
|
||||||
stmt.setInt(4, max.y);
|
stmt.setInt(4, max.getY());
|
||||||
stmt.setInt(5, min.x);
|
stmt.setInt(5, min.getX());
|
||||||
stmt.setInt(6, min.y);
|
stmt.setInt(6, min.getY());
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -103,7 +103,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
@Override public boolean createRoadEast(Plot plot) {
|
@Override public boolean createRoadEast(Plot plot) {
|
||||||
super.createRoadEast(plot);
|
super.createRoadEast(plot);
|
||||||
PlotId id = plot.getId();
|
PlotId id = plot.getId();
|
||||||
PlotId id2 = new PlotId(id.x + 1, id.y);
|
PlotId id2 = PlotId.of(id.getX() + 1, id.getY());
|
||||||
Location bot = getPlotBottomLocAbs(id2);
|
Location bot = getPlotBottomLocAbs(id2);
|
||||||
Location top = getPlotTopLocAbs(id);
|
Location top = getPlotTopLocAbs(id);
|
||||||
Location pos1 =
|
Location pos1 =
|
||||||
@ -166,7 +166,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
@Override public boolean createRoadSouth(Plot plot) {
|
@Override public boolean createRoadSouth(Plot plot) {
|
||||||
super.createRoadSouth(plot);
|
super.createRoadSouth(plot);
|
||||||
PlotId id = plot.getId();
|
PlotId id = plot.getId();
|
||||||
PlotId id2 = new PlotId(id.x, id.y + 1);
|
PlotId id2 = PlotId.of(id.getX(), id.getY() + 1);
|
||||||
Location bot = getPlotBottomLocAbs(id2);
|
Location bot = getPlotBottomLocAbs(id2);
|
||||||
Location top = getPlotTopLocAbs(id);
|
Location top = getPlotTopLocAbs(id);
|
||||||
Location pos1 =
|
Location pos1 =
|
||||||
@ -187,7 +187,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
@Override public boolean createRoadSouthEast(Plot plot) {
|
@Override public boolean createRoadSouthEast(Plot plot) {
|
||||||
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 = PlotId.of(id.getX() + 1, id.getY() + 1);
|
||||||
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
|
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
|
||||||
Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
|
Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
|
||||||
QueueCoordinator queue = hybridPlotWorld.getQueue();
|
QueueCoordinator queue = hybridPlotWorld.getQueue();
|
||||||
|
@ -82,8 +82,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public Location getPlotTopLocAbs(PlotId plotId) {
|
@Override public Location getPlotTopLocAbs(PlotId plotId) {
|
||||||
int px = plotId.x;
|
int px = plotId.getX();
|
||||||
int pz = plotId.y;
|
int pz = plotId.getY();
|
||||||
int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (squarePlotWorld.ROAD_WIDTH
|
int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (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;
|
||||||
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
|
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
|
||||||
@ -131,7 +131,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
if (z <= pathWidthLower || z > end || x <= pathWidthLower || x > end) {
|
if (z <= pathWidthLower || z > end || x <= pathWidthLower || x > end) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return new PlotId(idx, idz);
|
return PlotId.of(idx, idz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
} else {
|
} else {
|
||||||
idz = (z / size) + 1;
|
idz = (z / size) + 1;
|
||||||
}
|
}
|
||||||
return new PlotId(idx, idz);
|
return PlotId.of(idx, idz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PlotId getPlotId(int x, int y, int z) {
|
@Override public PlotId getPlotId(int x, int y, int z) {
|
||||||
@ -195,7 +195,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
dz = (z / size) + 1;
|
dz = (z / size) + 1;
|
||||||
rz = z % size;
|
rz = z % size;
|
||||||
}
|
}
|
||||||
PlotId id = new PlotId(dx, dz);
|
PlotId id = PlotId.of(dx, dz);
|
||||||
boolean[] merged =
|
boolean[] merged =
|
||||||
new boolean[] {rz <= pathWidthLower, rx > end, rz > end, rx <= pathWidthLower};
|
new boolean[] {rz <= pathWidthLower, rx > end, rz > end, rx <= pathWidthLower};
|
||||||
int hash = MainUtil.hash(merged);
|
int hash = MainUtil.hash(merged);
|
||||||
@ -245,8 +245,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
* Get the bottom plot loc (some basic math).
|
* Get the bottom plot loc (some basic math).
|
||||||
*/
|
*/
|
||||||
@Override public Location getPlotBottomLocAbs(PlotId plotId) {
|
@Override public Location getPlotBottomLocAbs(PlotId plotId) {
|
||||||
int px = plotId.x;
|
int px = plotId.getX();
|
||||||
int pz = plotId.y;
|
int pz = plotId.getY();
|
||||||
int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (squarePlotWorld.ROAD_WIDTH
|
int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (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);
|
||||||
|
@ -114,7 +114,7 @@ public class PlotListener {
|
|||||||
++value.count;
|
++value.count;
|
||||||
if (value.count == value.interval) {
|
if (value.count == value.interval) {
|
||||||
value.count = 0;
|
value.count = 0;
|
||||||
PlotPlayer<?> player = PlotSquared.platform().getWorldUtil().wrapPlayer(entry.getKey());
|
PlotPlayer<?> player = PlotSquared.platform().getWorldUtil().getPlayer(entry.getKey());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
@ -266,8 +266,8 @@ public class PlotListener {
|
|||||||
Plot lastPlot = player.getMeta(PlotPlayer.META_LAST_PLOT);
|
Plot lastPlot = player.getMeta(PlotPlayer.META_LAST_PLOT);
|
||||||
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
||||||
Map<String, String> replacements = new HashMap<>();
|
Map<String, String> replacements = new HashMap<>();
|
||||||
replacements.put("%x%", String.valueOf(lastPlot.getId().x));
|
replacements.put("%x%", String.valueOf(lastPlot.getId().getX()));
|
||||||
replacements.put("%z%", lastPlot.getId().y + "");
|
replacements.put("%z%", lastPlot.getId().getY() + "");
|
||||||
replacements.put("%world%", plot.getArea().toString());
|
replacements.put("%world%", plot.getArea().toString());
|
||||||
replacements.put("%greeting%", greeting);
|
replacements.put("%greeting%", greeting);
|
||||||
replacements.put("%alias", plot.toString());
|
replacements.put("%alias", plot.toString());
|
||||||
|
@ -117,4 +117,5 @@ public class BlockLoc {
|
|||||||
public float getPitch() {
|
public float getPitch() {
|
||||||
return pitch;
|
return pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.location;
|
package com.plotsquared.core.location;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.khelekore.prtree.MBR;
|
import org.khelekore.prtree.MBR;
|
||||||
import org.khelekore.prtree.SimpleMBR;
|
import org.khelekore.prtree.SimpleMBR;
|
||||||
@ -42,8 +42,7 @@ import javax.annotation.Nullable;
|
|||||||
/**
|
/**
|
||||||
* An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
|
* An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode @SuppressWarnings("unused")
|
public final class Location extends BlockLoc 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;
|
||||||
@ -52,6 +51,7 @@ public final class Location implements Comparable<Location> {
|
|||||||
|
|
||||||
private Location(@Nonnull final World<?> world, @Nonnull final BlockVector3 blockVector3,
|
private Location(@Nonnull final World<?> world, @Nonnull final BlockVector3 blockVector3,
|
||||||
final float yaw, final float pitch) {
|
final float yaw, final float pitch) {
|
||||||
|
super(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), yaw, pitch);
|
||||||
this.world = Preconditions.checkNotNull(world, "World may not be null");
|
this.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");
|
||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
@ -60,6 +60,7 @@ public final class Location implements Comparable<Location> {
|
|||||||
|
|
||||||
private Location(@Nonnull final String worldName, @Nonnull final BlockVector3 blockVector3,
|
private Location(@Nonnull final String worldName, @Nonnull final BlockVector3 blockVector3,
|
||||||
final float yaw, final float pitch) {
|
final float yaw, final float pitch) {
|
||||||
|
super(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), yaw, pitch);
|
||||||
Preconditions.checkNotNull(worldName, "World name may not be null");
|
Preconditions.checkNotNull(worldName, "World name may not be null");
|
||||||
if (worldName.isEmpty()) {
|
if (worldName.isEmpty()) {
|
||||||
this.world = World.nullWorld();
|
this.world = World.nullWorld();
|
||||||
@ -446,6 +447,28 @@ public final class Location implements Comparable<Location> {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean equals(final Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Location location = (Location) o;
|
||||||
|
return Float.compare(location.getYaw(), getYaw()) == 0
|
||||||
|
&& Float.compare(location.getPitch(), getPitch()) == 0 && Objects
|
||||||
|
.equal(getBlockVector3(), location.getBlockVector3()) && Objects
|
||||||
|
.equal(getWorld(), location.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int hashCode() {
|
||||||
|
return Objects
|
||||||
|
.hashCode(super.hashCode(), getYaw(), getPitch(), getBlockVector3(), getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
@Override public String toString() {
|
@Override public String toString() {
|
||||||
return "\"plotsquaredlocation\":{\"x\":" + this.getX() + ",\"y\":" + this.getY() + ",\"z\":"
|
return "\"plotsquaredlocation\":{\"x\":" + this.getX() + ",\"y\":" + this.getY() + ",\"z\":"
|
||||||
+ this.getZ() + ",\"yaw\":" + this.yaw + ",\"pitch\":" + this.pitch + ",\"world\":\""
|
+ this.getZ() + ",\"yaw\":" + this.yaw + ",\"pitch\":" + this.pitch + ",\"world\":\""
|
||||||
|
@ -76,11 +76,11 @@ public final class PlotLoc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return this.x;
|
return this.getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getY() {
|
public int getY() {
|
||||||
return this.y;
|
return this.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getZ() {
|
public int getZ() {
|
||||||
@ -90,14 +90,14 @@ public final class PlotLoc {
|
|||||||
@Override public int hashCode() {
|
@Override public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = (prime * result) + this.x;
|
result = (prime * result) + this.getX();
|
||||||
result = (prime * result) + this.y;
|
result = (prime * result) + this.getY();
|
||||||
result = (prime * result) + this.z;
|
result = (prime * result) + this.getZ();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String toString() {
|
@Override public String toString() {
|
||||||
if (this.y == -1) {
|
if (this.getY() == -1) {
|
||||||
return String.format("%d,%d", x, z);
|
return String.format("%d,%d", x, z);
|
||||||
}
|
}
|
||||||
return String.format("%d,%d,%d", x, y, z);
|
return String.format("%d,%d,%d", x, y, z);
|
||||||
@ -111,6 +111,7 @@ public final class PlotLoc {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotLoc other = (PlotLoc) obj;
|
final PlotLoc other = (PlotLoc) obj;
|
||||||
return (this.x == other.x) && (this.y == other.y) && (this.z == other.z);
|
return (this.getX() == other.getX()) && (this.getY() ==
|
||||||
|
other.getY()) && (this.getZ() == other.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,8 +576,8 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
if (plot != null && Settings.Enabled_Components.PERSISTENT_META && plot
|
if (plot != null && Settings.Enabled_Components.PERSISTENT_META && plot
|
||||||
.getArea() instanceof SinglePlotArea) {
|
.getArea() instanceof SinglePlotArea) {
|
||||||
PlotId id = plot.getId();
|
PlotId id = plot.getId();
|
||||||
int x = id.x;
|
int x = id.getX();
|
||||||
int z = id.y;
|
int z = id.getY();
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(13);
|
ByteBuffer buffer = ByteBuffer.allocate(13);
|
||||||
buffer.putShort((short) x);
|
buffer.putShort((short) x);
|
||||||
buffer.putShort((short) z);
|
buffer.putShort((short) z);
|
||||||
@ -677,7 +677,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
ByteBuffer quitWorld = ByteBuffer.wrap(arr);
|
ByteBuffer quitWorld = ByteBuffer.wrap(arr);
|
||||||
final int plotX = quitWorld.getShort();
|
final int plotX = quitWorld.getShort();
|
||||||
final int plotZ = quitWorld.getShort();
|
final int plotZ = quitWorld.getShort();
|
||||||
PlotId id = new PlotId(plotX, plotZ);
|
PlotId id = PlotId.of(plotX, plotZ);
|
||||||
int x = quitWorld.getInt();
|
int x = quitWorld.getInt();
|
||||||
int y = quitWorld.get() & 0xFF;
|
int y = quitWorld.get() & 0xFF;
|
||||||
int z = quitWorld.getInt();
|
int z = quitWorld.getInt();
|
||||||
|
@ -130,7 +130,17 @@ public class Plot {
|
|||||||
private static Set<Plot> connected_cache;
|
private static Set<Plot> connected_cache;
|
||||||
private static Set<CuboidRegion> regions_cache;
|
private static Set<CuboidRegion> regions_cache;
|
||||||
|
|
||||||
@Nonnull private final PlotId id;
|
@Nonnull private PlotId id;
|
||||||
|
|
||||||
|
// These will be injected
|
||||||
|
@Inject private EventDispatcher eventDispatcher;
|
||||||
|
@Inject private PlotListener plotListener;
|
||||||
|
@Inject private RegionManager regionManager;
|
||||||
|
@Inject private GlobalBlockQueue blockQueue;
|
||||||
|
@Inject private WorldUtil worldUtil;
|
||||||
|
@Inject private SchematicHandler schematicHandler;
|
||||||
|
@Inject @ImpromptuPipeline private UUIDPipeline impromptuPipeline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot flag container
|
* Plot flag container
|
||||||
*/
|
*/
|
||||||
@ -147,14 +157,6 @@ public class Plot {
|
|||||||
* @deprecated magical
|
* @deprecated magical
|
||||||
*/
|
*/
|
||||||
@Deprecated public int temp;
|
@Deprecated public int temp;
|
||||||
// These will be injected
|
|
||||||
@Inject private EventDispatcher eventDispatcher;
|
|
||||||
@Inject private PlotListener plotListener;
|
|
||||||
@Inject private RegionManager regionManager;
|
|
||||||
@Inject private GlobalBlockQueue blockQueue;
|
|
||||||
@Inject private WorldUtil worldUtil;
|
|
||||||
@Inject private SchematicHandler schematicHandler;
|
|
||||||
@Inject @ImpromptuPipeline private UUIDPipeline impromptuPipeline;
|
|
||||||
/**
|
/**
|
||||||
* plot owner
|
* plot owner
|
||||||
* (Merged plots can have multiple owners)
|
* (Merged plots can have multiple owners)
|
||||||
@ -660,7 +662,7 @@ public class Plot {
|
|||||||
this.origin = this;
|
this.origin = this;
|
||||||
PlotId min = this.id;
|
PlotId min = this.id;
|
||||||
for (Plot plot : this.getConnectedPlots()) {
|
for (Plot plot : this.getConnectedPlots()) {
|
||||||
if (plot.id.y < min.y || plot.id.y == min.y && plot.id.x < min.x) {
|
if (plot.id.getY() < min.getY() || plot.id.getY() == min.getY() && plot.id.getX() < min.getX()) {
|
||||||
this.origin = plot;
|
this.origin = plot;
|
||||||
min = plot.id;
|
min = plot.id;
|
||||||
}
|
}
|
||||||
@ -729,8 +731,10 @@ public class Plot {
|
|||||||
int i2 = 0;
|
int i2 = 0;
|
||||||
if (this.getSettings().getMerged(i2)) {
|
if (this.getSettings().getMerged(i2)) {
|
||||||
if (this.getSettings().getMerged(i)) {
|
if (this.getSettings().getMerged(i)) {
|
||||||
if (this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)) {
|
if (this.area.getPlotAbs(this.id.getRelative(Direction.getFromIndex(i)))
|
||||||
return this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
|
.getMerged(i2)) {
|
||||||
|
return this.area.getPlotAbs(this.id.getRelative(Direction.getFromIndex(i2)))
|
||||||
|
.getMerged(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -741,8 +745,9 @@ public class Plot {
|
|||||||
i = dir - 4;
|
i = dir - 4;
|
||||||
i2 = dir - 3;
|
i2 = dir - 3;
|
||||||
return this.getSettings().getMerged(i2) && this.getSettings().getMerged(i)
|
return this.getSettings().getMerged(i2) && this.getSettings().getMerged(i)
|
||||||
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2) && this.area
|
&& this.area.getPlotAbs(this.id.getRelative(Direction.getFromIndex(i)))
|
||||||
.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
|
.getMerged(i2) && this.area
|
||||||
|
.getPlotAbs(this.id.getRelative(Direction.getFromIndex(i2))).getMerged(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1832,7 +1837,7 @@ public class Plot {
|
|||||||
DBFunc.createPlotAndSettings(this, () -> {
|
DBFunc.createPlotAndSettings(this, () -> {
|
||||||
PlotArea plotworld = Plot.this.area;
|
PlotArea plotworld = Plot.this.area;
|
||||||
if (notify && plotworld.isAutoMerge()) {
|
if (notify && plotworld.isAutoMerge()) {
|
||||||
PlotPlayer player = this.worldUtil.wrapPlayer(uuid);
|
PlotPlayer player = this.worldUtil.getPlayer(uuid);
|
||||||
PlotMergeEvent event = this.eventDispatcher
|
PlotMergeEvent event = this.eventDispatcher
|
||||||
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
|
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
@ -1916,15 +1921,11 @@ public class Plot {
|
|||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
}
|
}
|
||||||
// Swap cached
|
// Swap cached
|
||||||
PlotId temp = new PlotId(this.getId().x, this.getId().y);
|
final PlotId temp = PlotId.of(this.getId().getX(), this.getId().getY());
|
||||||
this.getId().x = plot.getId().x;
|
this.id = plot.getId().copy();
|
||||||
this.getId().y = plot.getId().y;
|
plot.id = temp.copy();
|
||||||
plot.getId().x = temp.x;
|
|
||||||
plot.getId().y = temp.y;
|
|
||||||
this.area.removePlot(this.getId());
|
this.area.removePlot(this.getId());
|
||||||
plot.area.removePlot(plot.getId());
|
plot.area.removePlot(plot.getId());
|
||||||
this.getId().recalculateHash();
|
|
||||||
plot.getId().recalculateHash();
|
|
||||||
this.area.addPlotAbs(this);
|
this.area.addPlotAbs(this);
|
||||||
plot.area.addPlotAbs(plot);
|
plot.area.addPlotAbs(plot);
|
||||||
// Swap database
|
// Swap database
|
||||||
@ -1948,9 +1949,7 @@ public class Plot {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.area.removePlot(this.id);
|
this.area.removePlot(this.id);
|
||||||
this.getId().x = plot.getId().x;
|
this.id = plot.getId().copy();
|
||||||
this.getId().y = plot.getId().y;
|
|
||||||
this.getId().recalculateHash();
|
|
||||||
this.area.addPlotAbs(this);
|
this.area.addPlotAbs(this);
|
||||||
DBFunc.movePlot(this, plot);
|
DBFunc.movePlot(this, plot);
|
||||||
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
|
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
|
||||||
@ -2084,7 +2083,7 @@ public class Plot {
|
|||||||
if (this.settings != null && this.settings.getAlias().length() > 1) {
|
if (this.settings != null && this.settings.getAlias().length() > 1) {
|
||||||
return this.settings.getAlias();
|
return this.settings.getAlias();
|
||||||
}
|
}
|
||||||
return this.area + ";" + this.id.x + ";" + this.id.y;
|
return this.area + ";" + this.id.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2299,8 +2298,8 @@ public class Plot {
|
|||||||
if (value) {
|
if (value) {
|
||||||
Plot other = this.getRelative(direction).getBasePlot(false);
|
Plot other = this.getRelative(direction).getBasePlot(false);
|
||||||
if (!other.equals(this.getBasePlot(false))) {
|
if (!other.equals(this.getBasePlot(false))) {
|
||||||
Plot base = other.id.y < this.id.y
|
Plot base = other.id.getY() < this.id.getY()
|
||||||
|| other.id.y == this.id.y && other.id.x < this.id.x ? other : this.origin;
|
|| other.id.getY() == this.id.getY() && other.id.getX() < this.id.getX() ? other : this.origin;
|
||||||
this.origin.origin = base;
|
this.origin.origin = base;
|
||||||
other.origin = base;
|
other.origin = base;
|
||||||
this.origin = base;
|
this.origin = base;
|
||||||
@ -2589,36 +2588,21 @@ public class Plot {
|
|||||||
* @return Plot
|
* @return Plot
|
||||||
*/
|
*/
|
||||||
public Plot getRelative(int x, int y) {
|
public Plot getRelative(int x, int y) {
|
||||||
return this.area.getPlotAbs(this.id.getRelative(x, y));
|
return this.area.getPlotAbs(PlotId.of(this.id.getX() + x, this.id.getY() + y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plot getRelative(PlotArea area, int x, int y) {
|
public Plot getRelative(PlotArea area, int x, int y) {
|
||||||
return area.getPlotAbs(this.id.getRelative(x, y));
|
return area.getPlotAbs(PlotId.of(this.id.getX() + x, this.id.getY() + y));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the plot in a relative direction<br>
|
|
||||||
* 0 = north<br>
|
|
||||||
* 1 = east<br>
|
|
||||||
* 2 = south<br>
|
|
||||||
* 3 = west<br>
|
|
||||||
* Note: May be null if the partial plot area does not include the relative location
|
|
||||||
*
|
|
||||||
* @param direction
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Deprecated public Plot getRelative(int direction) {
|
|
||||||
return this.area.getPlotAbs(this.id.getRelative(direction));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the plot in a relative direction
|
* Gets the plot in a relative direction
|
||||||
* Note: May be null if the partial plot area does not include the relative location
|
* Note: May be null if the partial plot area does not include the relative location
|
||||||
*
|
*
|
||||||
* @param direction
|
* @param direction Direction
|
||||||
* @return the plot relative to this one
|
* @return the plot relative to this one
|
||||||
*/
|
*/
|
||||||
public Plot getRelative(Direction direction) {
|
@Nullable public Plot getRelative(@Nonnull Direction direction) {
|
||||||
return this.area.getPlotAbs(this.id.getRelative(direction));
|
return this.area.getPlotAbs(this.id.getRelative(direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2774,12 +2758,12 @@ public class Plot {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean merge = true;
|
boolean merge = true;
|
||||||
PlotId bot = new PlotId(current.getId().x, current.getId().y);
|
PlotId bot = PlotId.of(current.getId().getX(), current.getId().getY());
|
||||||
PlotId top = new PlotId(current.getId().x, current.getId().y);
|
PlotId top = PlotId.of(current.getId().getX(), current.getId().getY());
|
||||||
while (merge) {
|
while (merge) {
|
||||||
merge = false;
|
merge = false;
|
||||||
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(new PlotId(bot.x, bot.y - 1),
|
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(PlotId.of(bot.getX(), bot.getY() - 1),
|
||||||
new PlotId(top.x, bot.y - 1));
|
PlotId.of(top.getX(), bot.getY() - 1));
|
||||||
boolean tmp = true;
|
boolean tmp = true;
|
||||||
for (PlotId id : ids) {
|
for (PlotId id : ids) {
|
||||||
Plot plot = this.area.getPlotAbs(id);
|
Plot plot = this.area.getPlotAbs(id);
|
||||||
@ -2790,10 +2774,10 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
merge = true;
|
merge = true;
|
||||||
bot.y--;
|
bot = PlotId.of(bot.getX(), bot.getY() - 1);
|
||||||
}
|
}
|
||||||
ids = MainUtil.getPlotSelectionIds(new PlotId(top.x + 1, bot.y),
|
ids = MainUtil.getPlotSelectionIds(PlotId.of(top.getX() + 1, bot.getY()),
|
||||||
new PlotId(top.x + 1, top.y));
|
PlotId.of(top.getX() + 1, top.getY()));
|
||||||
tmp = true;
|
tmp = true;
|
||||||
for (PlotId id : ids) {
|
for (PlotId id : ids) {
|
||||||
Plot plot = this.area.getPlotAbs(id);
|
Plot plot = this.area.getPlotAbs(id);
|
||||||
@ -2804,10 +2788,10 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
merge = true;
|
merge = true;
|
||||||
top.x++;
|
top = PlotId.of(top.getX() + 1, top.getY());
|
||||||
}
|
}
|
||||||
ids = MainUtil.getPlotSelectionIds(new PlotId(bot.x, top.y + 1),
|
ids = MainUtil.getPlotSelectionIds(PlotId.of(bot.getX(), top.getY() + 1),
|
||||||
new PlotId(top.x, top.y + 1));
|
PlotId.of(top.getX(), top.getY() + 1));
|
||||||
tmp = true;
|
tmp = true;
|
||||||
for (PlotId id : ids) {
|
for (PlotId id : ids) {
|
||||||
Plot plot = this.area.getPlotAbs(id);
|
Plot plot = this.area.getPlotAbs(id);
|
||||||
@ -2818,10 +2802,10 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
merge = true;
|
merge = true;
|
||||||
top.y++;
|
top = PlotId.of(top.getX(), top.getY() + 1);
|
||||||
}
|
}
|
||||||
ids = MainUtil.getPlotSelectionIds(new PlotId(bot.x - 1, bot.y),
|
ids = MainUtil.getPlotSelectionIds(PlotId.of(bot.getX() - 1, bot.getY()),
|
||||||
new PlotId(bot.x - 1, top.y));
|
PlotId.of(bot.getX() - 1, top.getY()));
|
||||||
tmp = true;
|
tmp = true;
|
||||||
for (PlotId id : ids) {
|
for (PlotId id : ids) {
|
||||||
Plot plot = this.area.getPlotAbs(id);
|
Plot plot = this.area.getPlotAbs(id);
|
||||||
@ -2832,14 +2816,14 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
merge = true;
|
merge = true;
|
||||||
bot.x--;
|
bot = PlotId.of(bot.getX() - 1, bot.getX());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Location gtopabs = this.area.getPlotAbs(top).getTopAbs();
|
Location gtopabs = this.area.getPlotAbs(top).getTopAbs();
|
||||||
Location gbotabs = this.area.getPlotAbs(bot).getBottomAbs();
|
Location gbotabs = this.area.getPlotAbs(bot).getBottomAbs();
|
||||||
visited.addAll(MainUtil.getPlotSelectionIds(bot, top));
|
visited.addAll(MainUtil.getPlotSelectionIds(bot, top));
|
||||||
for (int x = bot.x; x <= top.x; x++) {
|
for (int x = bot.getX(); x <= top.getX(); x++) {
|
||||||
Plot plot = this.area.getPlotAbs(new PlotId(x, top.y));
|
Plot plot = this.area.getPlotAbs(PlotId.of(x, top.getY()));
|
||||||
if (plot.getMerged(Direction.SOUTH)) {
|
if (plot.getMerged(Direction.SOUTH)) {
|
||||||
// south wedge
|
// south wedge
|
||||||
Location toploc = plot.getExtendedTopAbs();
|
Location toploc = plot.getExtendedTopAbs();
|
||||||
@ -2858,8 +2842,8 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = bot.y; y <= top.y; y++) {
|
for (int y = bot.getY(); y <= top.getY(); y++) {
|
||||||
Plot plot = this.area.getPlotAbs(new PlotId(top.x, y));
|
Plot plot = this.area.getPlotAbs(PlotId.of(top.getX(), y));
|
||||||
if (plot.getMerged(Direction.EAST)) {
|
if (plot.getMerged(Direction.EAST)) {
|
||||||
// east wedge
|
// east wedge
|
||||||
Location toploc = plot.getExtendedTopAbs();
|
Location toploc = plot.getExtendedTopAbs();
|
||||||
@ -3093,8 +3077,8 @@ public class Plot {
|
|||||||
public void mergePlot(Plot lesserPlot, boolean removeRoads) {
|
public void mergePlot(Plot lesserPlot, boolean removeRoads) {
|
||||||
Plot greaterPlot = this;
|
Plot greaterPlot = this;
|
||||||
lesserPlot.removeSign();
|
lesserPlot.removeSign();
|
||||||
if (lesserPlot.getId().x == greaterPlot.getId().x) {
|
if (lesserPlot.getId().getX() == greaterPlot.getId().getX()) {
|
||||||
if (lesserPlot.getId().y > greaterPlot.getId().y) {
|
if (lesserPlot.getId().getY() > greaterPlot.getId().getY()) {
|
||||||
Plot tmp = lesserPlot;
|
Plot tmp = lesserPlot;
|
||||||
lesserPlot = greaterPlot;
|
lesserPlot = greaterPlot;
|
||||||
greaterPlot = tmp;
|
greaterPlot = tmp;
|
||||||
@ -3119,7 +3103,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lesserPlot.getId().x > greaterPlot.getId().x) {
|
if (lesserPlot.getId().getX() > greaterPlot.getId().getX()) {
|
||||||
Plot tmp = lesserPlot;
|
Plot tmp = lesserPlot;
|
||||||
lesserPlot = greaterPlot;
|
lesserPlot = greaterPlot;
|
||||||
greaterPlot = tmp;
|
greaterPlot = tmp;
|
||||||
@ -3157,8 +3141,8 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public CompletableFuture<Boolean> move(final Plot destination, final Runnable whenDone,
|
public CompletableFuture<Boolean> move(final Plot destination, final Runnable whenDone,
|
||||||
boolean allowSwap) {
|
boolean allowSwap) {
|
||||||
final PlotId offset = new PlotId(destination.getId().x - this.getId().x,
|
final PlotId offset = PlotId.of(destination.getId().getX() - this.getId().getX(),
|
||||||
destination.getId().y - this.getId().y);
|
destination.getId().getY() - this.getId().getY());
|
||||||
Location db = destination.getBottomAbs();
|
Location db = destination.getBottomAbs();
|
||||||
Location ob = this.getBottomAbs();
|
Location ob = this.getBottomAbs();
|
||||||
final int offsetX = db.getX() - ob.getX();
|
final int offsetX = db.getX() - ob.getX();
|
||||||
@ -3170,7 +3154,7 @@ public class Plot {
|
|||||||
AtomicBoolean occupied = new AtomicBoolean(false);
|
AtomicBoolean occupied = new AtomicBoolean(false);
|
||||||
Set<Plot> plots = this.getConnectedPlots();
|
Set<Plot> plots = this.getConnectedPlots();
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
Plot other = plot.getRelative(destination.getArea(), offset.getX(), offset.getY());
|
||||||
if (other.hasOwner()) {
|
if (other.hasOwner()) {
|
||||||
if (!allowSwap) {
|
if (!allowSwap) {
|
||||||
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
|
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
|
||||||
@ -3193,7 +3177,7 @@ public class Plot {
|
|||||||
if (plotIterator.hasNext()) {
|
if (plotIterator.hasNext()) {
|
||||||
while (plotIterator.hasNext()) {
|
while (plotIterator.hasNext()) {
|
||||||
final Plot plot = plotIterator.next();
|
final Plot plot = plotIterator.next();
|
||||||
final Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
final Plot other = plot.getRelative(destination.getArea(), offset.getX(), offset.getY());
|
||||||
final CompletableFuture<Boolean> swapResult = plot.swapData(other);
|
final CompletableFuture<Boolean> swapResult = plot.swapData(other);
|
||||||
if (future == null) {
|
if (future == null) {
|
||||||
future = swapResult;
|
future = swapResult;
|
||||||
@ -3238,7 +3222,7 @@ public class Plot {
|
|||||||
if (regions.isEmpty()) {
|
if (regions.isEmpty()) {
|
||||||
Plot plot = destination.getRelative(0, 0);
|
Plot plot = destination.getRelative(0, 0);
|
||||||
Plot originPlot = originArea
|
Plot originPlot = originArea
|
||||||
.getPlotAbs(new PlotId(plot.id.x - offset.x, plot.id.y - offset.y));
|
.getPlotAbs(PlotId.of(plot.id.getX() - offset.getX(), plot.id.getY() - offset.getY()));
|
||||||
final Runnable clearDone = () -> {
|
final Runnable clearDone = () -> {
|
||||||
for (final Plot current : plot.getConnectedPlots()) {
|
for (final Plot current : plot.getConnectedPlots()) {
|
||||||
getManager().claimPlot(current);
|
getManager().claimPlot(current);
|
||||||
@ -3276,8 +3260,8 @@ public class Plot {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean copy(final Plot destination, final Runnable whenDone) {
|
public boolean copy(final Plot destination, final Runnable whenDone) {
|
||||||
PlotId offset = new PlotId(destination.getId().x - this.getId().x,
|
PlotId offset = PlotId.of(destination.getId().getX() - this.getId().getX(),
|
||||||
destination.getId().y - this.getId().y);
|
destination.getId().getY() - this.getId().getY());
|
||||||
Location db = destination.getBottomAbs();
|
Location db = destination.getBottomAbs();
|
||||||
Location ob = this.getBottomAbs();
|
Location ob = this.getBottomAbs();
|
||||||
final int offsetX = db.getX() - ob.getX();
|
final int offsetX = db.getX() - ob.getX();
|
||||||
@ -3288,7 +3272,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
Set<Plot> plots = this.getConnectedPlots();
|
Set<Plot> plots = this.getConnectedPlots();
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
Plot other = plot.getRelative(destination.getArea(), offset.getX(), offset.getY());
|
||||||
if (other.hasOwner()) {
|
if (other.hasOwner()) {
|
||||||
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
|
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
|
||||||
return false;
|
return false;
|
||||||
@ -3298,7 +3282,7 @@ public class Plot {
|
|||||||
destination.updateWorldBorder();
|
destination.updateWorldBorder();
|
||||||
// copy data
|
// copy data
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
Plot other = plot.getRelative(destination.getArea(), offset.getX(), offset.getY());
|
||||||
other.create(plot.getOwner(), false);
|
other.create(plot.getOwner(), false);
|
||||||
if (!plot.getFlagContainer().getFlagMap().isEmpty()) {
|
if (!plot.getFlagContainer().getFlagMap().isEmpty()) {
|
||||||
final Collection<PlotFlag<?, ?>> existingFlags = other.getFlags();
|
final Collection<PlotFlag<?, ?>> existingFlags = other.getFlags();
|
||||||
@ -3412,4 +3396,13 @@ public class Plot {
|
|||||||
return FlagContainer.<T, V>castUnsafe(flagInstance).getValue();
|
return FlagContainer.<T, V>castUnsafe(flagInstance).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the plot ID
|
||||||
|
*
|
||||||
|
* @param id new plot ID
|
||||||
|
*/
|
||||||
|
public void setId(@Nonnull final PlotId id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ package com.plotsquared.core.plot;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.collection.QuadMap;
|
import com.plotsquared.core.collection.QuadMap;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
@ -66,11 +65,11 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -215,8 +214,8 @@ public abstract class PlotArea {
|
|||||||
*
|
*
|
||||||
* @return the minimum value for a {@link PlotId}
|
* @return the minimum value for a {@link PlotId}
|
||||||
*/
|
*/
|
||||||
public PlotId getMin() {
|
@Nonnull public PlotId getMin() {
|
||||||
return this.min == null ? new PlotId(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min;
|
return this.min == null ? PlotId.of(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -224,8 +223,8 @@ public abstract class PlotArea {
|
|||||||
*
|
*
|
||||||
* @return the maximum value for a {@link PlotId}
|
* @return the maximum value for a {@link PlotId}
|
||||||
*/
|
*/
|
||||||
public PlotId getMax() {
|
@Nonnull public PlotId getMax() {
|
||||||
return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
|
return this.max == null ? PlotId.of(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean equals(Object obj) {
|
@Override public boolean equals(Object obj) {
|
||||||
@ -596,8 +595,8 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(@Nonnull final PlotId id) {
|
public boolean contains(@Nonnull final PlotId id) {
|
||||||
return this.min == null || (id.x >= this.min.x && id.x <= this.max.x && id.y >= this.min.y
|
return this.min == null || (id.getX() >= this.min.getX() && id.getX() <= this.max.getX() &&
|
||||||
&& id.y <= this.max.y);
|
id.getY() >= this.min.getY() && id.getY() <= this.max.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(@Nonnull final Location location) {
|
public boolean contains(@Nonnull final Location location) {
|
||||||
@ -661,8 +660,8 @@ public abstract class PlotArea {
|
|||||||
@Nullable public Plot getPlotAbs(@Nonnull final PlotId id) {
|
@Nullable public Plot getPlotAbs(@Nonnull final PlotId id) {
|
||||||
Plot plot = getOwnedPlotAbs(id);
|
Plot plot = getOwnedPlotAbs(id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (this.min != null && (id.x < this.min.x || id.x > this.max.x || id.y < this.min.y
|
if (this.min != null && (id.getX() < this.min.getX() || id.getX() > this.max.getX() || id.getY() < this.min.getY()
|
||||||
|| id.y > this.max.y)) {
|
|| id.getY() > this.max.getY())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Plot(this, id);
|
return new Plot(this, id);
|
||||||
@ -673,8 +672,8 @@ public abstract class PlotArea {
|
|||||||
@Nullable public Plot getPlot(@Nonnull final PlotId id) {
|
@Nullable public Plot getPlot(@Nonnull final PlotId id) {
|
||||||
final Plot plot = getOwnedPlotAbs(id);
|
final Plot plot = getOwnedPlotAbs(id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (this.min != null && (id.x < this.min.x || id.x > this.max.x || id.y < this.min.y
|
if (this.min != null && (id.getX() < this.min.getX() || id.getX() > this.max.getX() || id.getY() < this.min.getY()
|
||||||
|| id.y > this.max.y)) {
|
|| id.getY() > this.max.getY())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Plot(this, id);
|
return new Plot(this, id);
|
||||||
@ -696,7 +695,7 @@ public abstract class PlotArea {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.clusters != null ? this.clusters.get(plot.getId().x, plot.getId().y) : null;
|
return this.clusters != null ? this.clusters.get(plot.getId().getX(), plot.getId().getY()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -714,7 +713,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable PlotCluster getCluster(@Nonnull final PlotId id) {
|
@Nullable PlotCluster getCluster(@Nonnull final PlotId id) {
|
||||||
return this.clusters != null ? this.clusters.get(id.x, id.y) : null;
|
return this.clusters != null ? this.clusters.get(id.getX(), id.getY()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -800,22 +799,22 @@ public abstract class PlotArea {
|
|||||||
PlotId min = getMin();
|
PlotId min = getMin();
|
||||||
PlotId max = getMax();
|
PlotId max = getMax();
|
||||||
if (getType() == PlotAreaType.PARTIAL) {
|
if (getType() == PlotAreaType.PARTIAL) {
|
||||||
center = new PlotId(MathMan.average(min.x, max.x), MathMan.average(min.y, max.y));
|
center = PlotId.of(MathMan.average(min.getX(), max.getX()), MathMan.average(min.getY(), max.getY()));
|
||||||
plots = Math.max(max.x - min.x + 1, max.y - min.y + 1) + 1;
|
plots = Math.max(max.getX() - min.getX() + 1, max.getY() - min.getY() + 1) + 1;
|
||||||
if (start != null) {
|
if (start != null) {
|
||||||
start = new PlotId(start.x - center.x, start.y - center.y);
|
start = PlotId.of(start.getX() - center.getX(), start.getY() - center.getY());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
center = new PlotId(0, 0);
|
center = PlotId.of(0, 0);
|
||||||
plots = Integer.MAX_VALUE;
|
plots = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < plots; i++) {
|
for (int i = 0; i < plots; i++) {
|
||||||
if (start == null) {
|
if (start == null) {
|
||||||
start = getMeta("lastPlot", new PlotId(0, 0));
|
start = getMeta("lastPlot", PlotId.of(0, 0));
|
||||||
} else {
|
} else {
|
||||||
start = start.getNextId(1);
|
start = start.getNextId();
|
||||||
}
|
}
|
||||||
PlotId currentId = new PlotId(center.x + start.x, center.y + start.y);
|
PlotId currentId = PlotId.of(center.getX() + start.getX(), center.getY() + start.getY());
|
||||||
Plot plot = getPlotAbs(currentId);
|
Plot plot = getPlotAbs(currentId);
|
||||||
if (plot != null && plot.canClaim(player)) {
|
if (plot != null && plot.canClaim(player)) {
|
||||||
setMeta("lastPlot", start);
|
setMeta("lastPlot", start);
|
||||||
@ -888,7 +887,7 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
public boolean canClaim(@Nullable final PlotPlayer player, @Nonnull final PlotId pos1,
|
public boolean canClaim(@Nullable final PlotPlayer player, @Nonnull final PlotId pos1,
|
||||||
@Nonnull final PlotId pos2) {
|
@Nonnull final PlotId pos2) {
|
||||||
if (pos1.x == pos2.x && pos1.y == pos2.y) {
|
if (pos1.getX() == pos2.getX() && pos1.getY() == pos2.getY()) {
|
||||||
if (getOwnedPlot(pos1) != null) {
|
if (getOwnedPlot(pos1) != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -898,9 +897,9 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
return plot.canClaim(player);
|
return plot.canClaim(player);
|
||||||
}
|
}
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
|
||||||
final PlotId id = new PlotId(x, y);
|
final PlotId id = PlotId.of(x, y);
|
||||||
final Plot plot = getPlotAbs(id);
|
final Plot plot = getPlotAbs(id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -930,9 +929,9 @@ public abstract class PlotArea {
|
|||||||
final Set<UUID> trusted = new HashSet<>();
|
final Set<UUID> trusted = new HashSet<>();
|
||||||
final Set<UUID> members = new HashSet<>();
|
final Set<UUID> members = new HashSet<>();
|
||||||
final Set<UUID> denied = new HashSet<>();
|
final Set<UUID> denied = new HashSet<>();
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
|
||||||
PlotId id = new PlotId(x, y);
|
PlotId id = PlotId.of(x, y);
|
||||||
Plot plot = getPlotAbs(id);
|
Plot plot = getPlotAbs(id);
|
||||||
trusted.addAll(plot.getTrusted());
|
trusted.addAll(plot.getTrusted());
|
||||||
members.addAll(plot.getMembers());
|
members.addAll(plot.getMembers());
|
||||||
@ -945,11 +944,11 @@ public abstract class PlotArea {
|
|||||||
members.removeAll(trusted);
|
members.removeAll(trusted);
|
||||||
denied.removeAll(trusted);
|
denied.removeAll(trusted);
|
||||||
denied.removeAll(members);
|
denied.removeAll(members);
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
|
||||||
final boolean lx = x < pos2.x;
|
final boolean lx = x < pos2.getX();
|
||||||
final boolean ly = y < pos2.y;
|
final boolean ly = y < pos2.getY();
|
||||||
final PlotId id = new PlotId(x, y);
|
final PlotId id = PlotId.of(x, y);
|
||||||
final Plot plot = getPlotAbs(id);
|
final Plot plot = getPlotAbs(id);
|
||||||
|
|
||||||
plot.setTrusted(trusted);
|
plot.setTrusted(trusted);
|
||||||
@ -991,22 +990,22 @@ public abstract class PlotArea {
|
|||||||
* @return the plots in the selection which are owned
|
* @return the plots in the selection which are owned
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlotSelectionOwned(@Nonnull final PlotId pos1, @Nonnull final PlotId pos2) {
|
public Set<Plot> getPlotSelectionOwned(@Nonnull final PlotId pos1, @Nonnull final PlotId pos2) {
|
||||||
final int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
final int size = (1 + pos2.getX() - pos1.getX()) * (1 + pos2.getY() - pos1.getY());
|
||||||
final Set<Plot> result = new HashSet<>();
|
final Set<Plot> result = new HashSet<>();
|
||||||
if (size < 16 || size < getPlotCount()) {
|
if (size < 16 || size < getPlotCount()) {
|
||||||
for (final PlotId pid : MainUtil.getPlotSelectionIds(pos1, pos2)) {
|
for (final PlotId pid : MainUtil.getPlotSelectionIds(pos1, pos2)) {
|
||||||
final Plot plot = getPlotAbs(pid);
|
final Plot plot = getPlotAbs(pid);
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (plot.getId().x > pos1.x || plot.getId().y > pos1.y
|
if (plot.getId().getX() > pos1.getX() || plot.getId().getY() > pos1.getY()
|
||||||
|| plot.getId().x < pos2.x || plot.getId().y < pos2.y) {
|
|| plot.getId().getX() < pos2.getX() || plot.getId().getY() < pos2.getY()) {
|
||||||
result.add(plot);
|
result.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (final Plot plot : getPlots()) {
|
for (final Plot plot : getPlots()) {
|
||||||
if (plot.getId().x > pos1.x || plot.getId().y > pos1.y || plot.getId().x < pos2.x
|
if (plot.getId().getX() > pos1.getX() || plot.getId().getY() > pos1.getY() || plot.getId().getX() < pos2.getX()
|
||||||
|| plot.getId().y < pos2.y) {
|
|| plot.getId().getY() < pos2.getY()) {
|
||||||
result.add(plot);
|
result.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1026,8 +1025,8 @@ public abstract class PlotArea {
|
|||||||
if (this.clusters == null) {
|
if (this.clusters == null) {
|
||||||
this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) {
|
this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) {
|
||||||
@Override public CuboidRegion getRegion(PlotCluster value) {
|
@Override public CuboidRegion getRegion(PlotCluster value) {
|
||||||
BlockVector2 pos1 = BlockVector2.at(value.getP1().x, value.getP1().y);
|
BlockVector2 pos1 = BlockVector2.at(value.getP1().getX(), value.getP1().getY());
|
||||||
BlockVector2 pos2 = BlockVector2.at(value.getP2().x, value.getP2().y);
|
BlockVector2 pos2 = BlockVector2.at(value.getP2().getX(), value.getP2().getY());
|
||||||
return new CuboidRegion(pos1.toBlockVector3(),
|
return new CuboidRegion(pos1.toBlockVector3(),
|
||||||
pos2.toBlockVector3(Plot.MAX_HEIGHT - 1));
|
pos2.toBlockVector3(Plot.MAX_HEIGHT - 1));
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ 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 javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -87,7 +88,8 @@ public class PlotCluster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setRegion() {
|
private void setRegion() {
|
||||||
this.region = RegionUtil.createRegion(this.pos1.x, this.pos2.x, this.pos1.y, this.pos2.y);
|
this.region = RegionUtil.createRegion(this.pos1.getX(), this.pos2.getX(),
|
||||||
|
this.pos1.getY(), this.pos2.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CuboidRegion getRegion() {
|
public CuboidRegion getRegion() {
|
||||||
@ -117,7 +119,7 @@ public class PlotCluster {
|
|||||||
* Get the area (in plots).
|
* Get the area (in plots).
|
||||||
*/
|
*/
|
||||||
public int getArea() {
|
public int getArea() {
|
||||||
return (1 + this.pos2.x - this.pos1.x) * (1 + this.pos2.y - this.pos1.y);
|
return (1 + this.pos2.getX() - this.pos1.getX()) * (1 + this.pos2.getY() - this.pos1.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArea(PlotArea plotArea) {
|
public void setArea(PlotArea plotArea) {
|
||||||
@ -148,8 +150,7 @@ public class PlotCluster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public String toString() {
|
@Override public String toString() {
|
||||||
return this.area + ";" + this.pos1.x + ";" + this.pos1.y + ";" + this.pos2.x + ";"
|
return this.area + ";" + this.pos1.toString() + ";" + this.pos2.toString();
|
||||||
+ this.pos2.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getHome(@Nonnull final Consumer<Location> result) {
|
public void getHome(@Nonnull final Consumer<Location> result) {
|
||||||
@ -180,13 +181,13 @@ public class PlotCluster {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotId getCenterPlotId() {
|
@Nonnull public PlotId getCenterPlotId() {
|
||||||
PlotId bot = getP1();
|
final PlotId bot = getP1();
|
||||||
PlotId top = getP2();
|
final PlotId top = getP2();
|
||||||
return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
return PlotId.of((bot.getX() + top.getX()) / 2, (bot.getY() + top.getY()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plot getCenterPlot() {
|
@Nullable public Plot getCenterPlot() {
|
||||||
return this.area.getPlotAbs(getCenterPlotId());
|
return this.area.getPlotAbs(getCenterPlotId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,12 +202,12 @@ public class PlotCluster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean intersects(PlotId pos1, PlotId pos2) {
|
public boolean intersects(PlotId pos1, PlotId pos2) {
|
||||||
return pos1.x <= this.pos2.x && pos2.x >= this.pos1.x && pos1.y <= this.pos2.y
|
return pos1.getX() <= this.pos2.getX() && pos2.getX() >= this.pos1.getX() &&
|
||||||
&& pos2.y >= this.pos1.y;
|
pos1.getY() <= this.pos2.getY() && pos2.getY() >= this.pos1.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(PlotId id) {
|
public boolean contains(PlotId id) {
|
||||||
return this.pos1.x <= id.x && this.pos1.y <= id.y && this.pos2.x >= id.x
|
return this.pos1.getX() <= id.getX() && this.pos1.getY() <= id.getY() &&
|
||||||
&& this.pos2.y >= id.y;
|
this.pos2.getX() >= id.getX() && this.pos2.getY() >= id.getY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,21 @@
|
|||||||
package com.plotsquared.core.plot;
|
package com.plotsquared.core.plot;
|
||||||
|
|
||||||
import com.plotsquared.core.location.Direction;
|
import com.plotsquared.core.location.Direction;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plot (X,Y) tuples for plot locations
|
||||||
|
* within a plot area
|
||||||
|
*/
|
||||||
public class PlotId {
|
public class PlotId {
|
||||||
|
|
||||||
@Deprecated public int x;
|
private final int x;
|
||||||
@Deprecated public int y;
|
private final int y;
|
||||||
private int hash;
|
private final int hash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotId class (PlotId x,y values do not correspond to Block locations)
|
* PlotId class (PlotId x,y values do not correspond to Block locations)
|
||||||
@ -41,9 +48,20 @@ public class PlotId {
|
|||||||
* @param x The plot x coordinate
|
* @param x The plot x coordinate
|
||||||
* @param y The plot y coordinate
|
* @param y The plot y coordinate
|
||||||
*/
|
*/
|
||||||
public PlotId(int x, int y) {
|
private PlotId(int x, int y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
this.hash = (this.getX() << 16) | (this.getY() & 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plot ID instance
|
||||||
|
*
|
||||||
|
* @param x The plot x coordinate
|
||||||
|
* @param y The plot y coordinate
|
||||||
|
*/
|
||||||
|
@Nonnull public static PlotId of(final int x, final int y) {
|
||||||
|
return PlotId.of(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,6 +78,12 @@ public class PlotId {
|
|||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to parse a plot ID from a string
|
||||||
|
*
|
||||||
|
* @param string ID string
|
||||||
|
* @return Plot ID, or {@code null} if none could be parsed
|
||||||
|
*/
|
||||||
@Nullable public static PlotId fromStringOrNull(@Nonnull String string) {
|
@Nullable public static PlotId fromStringOrNull(@Nonnull String string) {
|
||||||
String[] parts = string.split("[;,.]");
|
String[] parts = string.split("[;,.]");
|
||||||
if (parts.length < 2) {
|
if (parts.length < 2) {
|
||||||
@ -73,101 +97,102 @@ public class PlotId {
|
|||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new PlotId(x, y);
|
return of(x, y);
|
||||||
}
|
|
||||||
|
|
||||||
public static PlotId of(@Nullable Plot plot) {
|
|
||||||
return plot != null ? plot.getId() : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the PlotId from the HashCode<br>
|
* Gets the PlotId from the HashCode<br>
|
||||||
* Note: Only accurate for small x,z values (short)
|
* Note: Only accurate for small x,z values (short)
|
||||||
*
|
*
|
||||||
* @param hash
|
* @param hash ID hash
|
||||||
* @return
|
* @return Plot ID
|
||||||
*/
|
*/
|
||||||
public static PlotId unpair(int hash) {
|
@Nonnull public static PlotId unpair(final int hash) {
|
||||||
return new PlotId(hash >> 16, hash & 0xFFFF);
|
return PlotId.of(hash >> 16, hash & 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a copy of the plot ID
|
||||||
|
*
|
||||||
|
* @return Plot ID copy
|
||||||
|
*/
|
||||||
|
@NotNull public PlotId copy() {
|
||||||
|
return of(this.getX(), this.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ID X component
|
||||||
|
*
|
||||||
|
* @return X component
|
||||||
|
*/
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return x;
|
return this.getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ID Y component
|
||||||
|
*
|
||||||
|
* @return Y component
|
||||||
|
*/
|
||||||
public int getY() {
|
public int getY() {
|
||||||
return y;
|
return this.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotId getNextId(int step) {
|
/**
|
||||||
|
* Get the next plot ID for claiming purposes
|
||||||
|
*
|
||||||
|
* @return Next plot ID
|
||||||
|
*/
|
||||||
|
@Nonnull public PlotId getNextId() {
|
||||||
int absX = Math.abs(x);
|
int absX = Math.abs(x);
|
||||||
int absY = Math.abs(y);
|
int absY = Math.abs(y);
|
||||||
if (absX > absY) {
|
if (absX > absY) {
|
||||||
if (x > 0) {
|
if (x > 0) {
|
||||||
return new PlotId(x, y + 1);
|
return PlotId.of(x, y + 1);
|
||||||
} else {
|
} else {
|
||||||
return new PlotId(x, y - 1);
|
return PlotId.of(x, y - 1);
|
||||||
}
|
}
|
||||||
} else if (absY > absX) {
|
} else if (absY > absX) {
|
||||||
if (y > 0) {
|
if (y > 0) {
|
||||||
return new PlotId(x - 1, y);
|
return PlotId.of(x - 1, y);
|
||||||
} else {
|
} else {
|
||||||
return new PlotId(x + 1, y);
|
return PlotId.of(x + 1, y);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (x == y && x > 0) {
|
if (x == y && x > 0) {
|
||||||
return new PlotId(x, y + step);
|
return PlotId.of(x, y + 1);
|
||||||
}
|
}
|
||||||
if (x == absX) {
|
if (x == absX) {
|
||||||
return new PlotId(x, y + 1);
|
return PlotId.of(x, y + 1);
|
||||||
}
|
}
|
||||||
if (y == absY) {
|
if (y == absY) {
|
||||||
return new PlotId(x, y - 1);
|
return PlotId.of(x, y - 1);
|
||||||
}
|
}
|
||||||
return new PlotId(x + 1, y);
|
return PlotId.of(x + 1, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotId getRelative(Direction direction) {
|
|
||||||
return getRelative(direction.getIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PlotId in a relative direction
|
* Get the PlotId in a relative direction
|
||||||
* 0 = north<br>
|
|
||||||
* 1 = east<br>
|
|
||||||
* 2 = south<br>
|
|
||||||
* 3 = west<br>
|
|
||||||
*
|
*
|
||||||
* @param direction
|
* @param direction Direction
|
||||||
* @return PlotId
|
* @return Relative plot ID
|
||||||
*/
|
*/
|
||||||
public PlotId getRelative(int direction) {
|
@Nonnull public PlotId getRelative(@Nonnull final Direction direction) {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 0:
|
case NORTH:
|
||||||
return new PlotId(this.x, this.y - 1);
|
return PlotId.of(this.getX(), this.getY() - 1);
|
||||||
case 1:
|
case EAST:
|
||||||
return new PlotId(this.x + 1, this.y);
|
return PlotId.of(this.getX() + 1, this.getY());
|
||||||
case 2:
|
case SOUTH:
|
||||||
return new PlotId(this.x, this.y + 1);
|
return PlotId.of(this.getX(), this.getY() + 1);
|
||||||
case 3:
|
case WEST:
|
||||||
return new PlotId(this.x - 1, this.y);
|
return PlotId.of(this.getX() - 1, this.getY());
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override public boolean equals(final Object obj) {
|
||||||
* Get the PlotId in a relative location
|
|
||||||
*
|
|
||||||
* @param x
|
|
||||||
* @param y
|
|
||||||
* @return PlotId
|
|
||||||
*/
|
|
||||||
public PlotId getRelative(int x, int y) {
|
|
||||||
return new PlotId(this.x + x, this.y + y);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -180,42 +205,91 @@ public class PlotId {
|
|||||||
if (getClass() != obj.getClass()) {
|
if (getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotId other = (PlotId) obj;
|
final PlotId other = (PlotId) obj;
|
||||||
return this.x == other.x && this.y == other.y;
|
return this.getX() == other.getX() && this.getY() == other.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e.g.
|
* Get a String representation of the plot ID where the
|
||||||
* 5;-6
|
* components are separated by ";"
|
||||||
*
|
*
|
||||||
* @return
|
* @return {@code x + ";" + y}
|
||||||
*/
|
*/
|
||||||
@Override public String toString() {
|
@Override @Nonnull public String toString() {
|
||||||
return this.x + ";" + this.y;
|
return this.getX() + ";" + this.getY();
|
||||||
}
|
|
||||||
|
|
||||||
public String toCommaSeparatedString() {
|
|
||||||
return this.x + "," + this.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toDashSeparatedString() {
|
|
||||||
return this.x + "-" + this.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PlotId object caches the hashcode for faster mapping/fetching/sorting<br>
|
* Get a String representation of the plot ID where the
|
||||||
* - Recalculation is required if the x/y values change
|
* components are separated by ","
|
||||||
* TODO maybe make x/y values private and add this to the mutators
|
*
|
||||||
|
* @return {@code x + "," + y}
|
||||||
*/
|
*/
|
||||||
public void recalculateHash() {
|
@Nonnull public String toCommaSeparatedString() {
|
||||||
this.hash = 0;
|
return this.getX() + "," + this.getY();
|
||||||
hashCode();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a String representation of the plot ID where the
|
||||||
|
* components are separated by "-"
|
||||||
|
*
|
||||||
|
* @return {@code x + "-" + y}
|
||||||
|
*/
|
||||||
|
@Nonnull public String toDashSeparatedString() {
|
||||||
|
return this.getX() + "-" + this.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int hashCode() {
|
@Override public int hashCode() {
|
||||||
if (this.hash == 0) {
|
|
||||||
this.hash = (this.x << 16) | (this.y & 0xFFFF);
|
|
||||||
}
|
|
||||||
return this.hash;
|
return this.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final class PlotRangeIterator implements Iterator<PlotId>, Iterable<PlotId> {
|
||||||
|
|
||||||
|
private final PlotId start;
|
||||||
|
private final PlotId end;
|
||||||
|
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
|
||||||
|
private PlotRangeIterator(@Nonnull final PlotId start, @Nonnull final PlotId end) {
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
this.x = this.start.getX();
|
||||||
|
this.y = this.start.getY();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlotRangeIterator range(@Nonnull final PlotId start, @Nonnull final PlotId end) {
|
||||||
|
return new PlotRangeIterator(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean hasNext() {
|
||||||
|
if (this.x < this.end.getX()) {
|
||||||
|
return true;
|
||||||
|
} else if (this.x == this.end.getX()) {
|
||||||
|
return this.y < this.end.getY();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotId next() {
|
||||||
|
if (!hasNext()) {
|
||||||
|
throw new IndexOutOfBoundsException("The iterator has no more entries");
|
||||||
|
}
|
||||||
|
if (this.y == this.end.getY()) {
|
||||||
|
this.x++;
|
||||||
|
this.y = 0;
|
||||||
|
} else {
|
||||||
|
this.y++;
|
||||||
|
}
|
||||||
|
return PlotId.of(this.start.getX() + this.x, this.start.getY() + this.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull @Override public Iterator<PlotId> iterator() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* _____ _ _ _____ _
|
|
||||||
* | __ \| | | | / ____| | |
|
|
||||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
||||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
||||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
||||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
||||||
* | |
|
|
||||||
* |_|
|
|
||||||
* PlotSquared plot management system for Minecraft
|
|
||||||
* Copyright (C) 2020 IntellectualSites
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.plotsquared.core.plot.schematic;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
|
||||||
|
|
||||||
public class PlotItem {
|
|
||||||
|
|
||||||
public final int x;
|
|
||||||
public final int y;
|
|
||||||
public final int z;
|
|
||||||
// public final short[] id;
|
|
||||||
// public final byte[] data;
|
|
||||||
public final ItemType[] types;
|
|
||||||
public final byte[] amount;
|
|
||||||
|
|
||||||
public PlotItem(short x, short y, short z, ItemType[] types, byte[] amount) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.types = types;
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
}
|
|
@ -48,11 +48,11 @@ public class SinglePlotManager extends PlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public PlotId getPlotIdAbs(int x, int y, int z) {
|
@Override public PlotId getPlotIdAbs(int x, int y, int z) {
|
||||||
return new PlotId(0, 0);
|
return PlotId.of(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PlotId getPlotId(int x, int y, int z) {
|
@Override public PlotId getPlotId(int x, int y, int z) {
|
||||||
return new PlotId(0, 0);
|
return PlotId.of(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Location getPlotBottomLocAbs(@Nonnull final PlotId plotId) {
|
@Override public Location getPlotBottomLocAbs(@Nonnull final PlotId plotId) {
|
||||||
|
@ -250,7 +250,7 @@ public class EventDispatcher {
|
|||||||
}));
|
}));
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated())
|
CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated())
|
||||||
+ " (on-login) " + "(" + plot.getId().x + ";" + plot.getId().y + ")");
|
+ " (on-login) " + "(" + plot.getId().getX() + ";" + plot.getId().getY() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,11 +55,11 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -154,8 +154,9 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void upload(UUID uuid, String file, String extension,
|
public static void upload(@Nullable UUID uuid, @Nullable final String file,
|
||||||
final RunnableVal<OutputStream> writeTask, final RunnableVal<URL> whenDone) {
|
@Nonnull final String extension, @Nullable final RunnableVal<OutputStream> writeTask,
|
||||||
|
@Nonnull final RunnableVal<URL> whenDone) {
|
||||||
if (writeTask == null) {
|
if (writeTask == null) {
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return;
|
return;
|
||||||
@ -362,9 +363,9 @@ public class MainUtil {
|
|||||||
*/
|
*/
|
||||||
public static ArrayList<PlotId> getPlotSelectionIds(PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getPlotSelectionIds(PlotId pos1, PlotId pos2) {
|
||||||
ArrayList<PlotId> myPlots = new ArrayList<>();
|
ArrayList<PlotId> myPlots = new ArrayList<>();
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
|
||||||
myPlots.add(new PlotId(x, y));
|
myPlots.add(PlotId.of(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return myPlots;
|
return myPlots;
|
||||||
@ -492,7 +493,7 @@ public class MainUtil {
|
|||||||
|
|
||||||
PlotArea area = null;
|
PlotArea area = null;
|
||||||
String alias = null;
|
String alias = null;
|
||||||
for (Plot plot : PlotQuery.newQuery().allPlots().asList()) {
|
for (Plot plot : PlotQuery.newQuery().allPlots()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (!uuids.isEmpty()) {
|
if (!uuids.isEmpty()) {
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
|
@ -138,11 +138,11 @@ public abstract class SchematicHandler {
|
|||||||
final String name;
|
final String name;
|
||||||
if (namingScheme == null) {
|
if (namingScheme == null) {
|
||||||
name =
|
name =
|
||||||
plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + owner;
|
plot.getId().getX() + ";" + plot.getId().getY() + ',' + plot.getArea() + ',' + owner;
|
||||||
} else {
|
} else {
|
||||||
name = namingScheme.replaceAll("%id%", plot.getId().toString())
|
name = namingScheme.replaceAll("%id%", plot.getId().toString())
|
||||||
.replaceAll("%idx%", plot.getId().x + "")
|
.replaceAll("%idx%", plot.getId().getX() + "")
|
||||||
.replaceAll("%idy%", plot.getId().y + "")
|
.replaceAll("%idy%", plot.getId().getY() + "")
|
||||||
.replaceAll("%world%", plot.getArea().toString());
|
.replaceAll("%world%", plot.getArea().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,10 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnegative;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -68,60 +70,158 @@ public abstract class WorldUtil {
|
|||||||
this.regionManager = regionManager;
|
this.regionManager = regionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getMainWorld();
|
/**
|
||||||
|
* Check if a given world name corresponds to a real world
|
||||||
public abstract boolean isWorld(String worldName);
|
*
|
||||||
|
* @param worldName World name
|
||||||
public abstract void getSign(Location location, Consumer<String[]> result);
|
* @return {@code true} if there exists a world with the given world name,
|
||||||
|
* {@code false} if not
|
||||||
|
*/
|
||||||
|
public abstract boolean isWorld(@Nonnull String worldName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param location Sign location
|
||||||
|
* @return Sign content (or an empty string array if the block is not a sign)
|
||||||
* @deprecated May result in synchronous chunk loading
|
* @deprecated May result in synchronous chunk loading
|
||||||
*/
|
*/
|
||||||
@Deprecated public abstract String[] getSignSynchronous(Location location);
|
@Deprecated @Nonnull public abstract String[] getSignSynchronous(@Nonnull Location location);
|
||||||
|
|
||||||
public abstract Location getSpawn(String world);
|
|
||||||
|
|
||||||
public abstract void setSpawn(Location location);
|
|
||||||
|
|
||||||
public abstract void saveWorld(String world);
|
|
||||||
|
|
||||||
public abstract String getClosestMatchingName(BlockState plotBlock);
|
|
||||||
|
|
||||||
public abstract boolean isBlockSolid(BlockState block);
|
|
||||||
|
|
||||||
public abstract StringComparison<BlockState>.ComparisonResult getClosestBlock(String name);
|
|
||||||
|
|
||||||
public abstract void getBiome(String world, int x, int z, Consumer<BiomeType> result);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated May result in synchronous chunk loading
|
* Get the world spawn location
|
||||||
|
*
|
||||||
|
* @param world World name
|
||||||
|
* @return World spawn location
|
||||||
*/
|
*/
|
||||||
@Deprecated public abstract BiomeType getBiomeSynchronous(String world, int x, int z);
|
@Nonnull public abstract Location getSpawn(@Nonnull String world);
|
||||||
|
|
||||||
public abstract void getBlock(Location location, Consumer<BlockState> result);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated May result in synchronous chunk loading
|
* Set the world spawn location
|
||||||
|
*
|
||||||
|
* @param location New spawn
|
||||||
*/
|
*/
|
||||||
@Deprecated public abstract BlockState getBlockSynchronous(Location location);
|
public abstract void setSpawn(@Nonnull Location location);
|
||||||
|
|
||||||
public abstract void getHighestBlock(String world, int x, int z, final IntConsumer result);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated May result in synchronous chunk loading
|
* Save a world
|
||||||
|
*
|
||||||
|
* @param world World name
|
||||||
*/
|
*/
|
||||||
@Deprecated public abstract int getHighestBlockSynchronous(String world, int x, int z);
|
public abstract void saveWorld(@Nonnull String world);
|
||||||
|
|
||||||
public abstract void setSign(String world, int x, int y, int z, String[] lines);
|
/**
|
||||||
|
* Get a string comparison with the closets block state matching a given string
|
||||||
|
*
|
||||||
|
* @param name Block name
|
||||||
|
* @return Comparison result containing the closets matching block
|
||||||
|
*/
|
||||||
|
@Nonnull public abstract StringComparison<BlockState>.ComparisonResult getClosestBlock(
|
||||||
|
@Nonnull String name);
|
||||||
|
|
||||||
public abstract void setBiomes(String world, CuboidRegion region, BiomeType biome);
|
/**
|
||||||
|
* Get the biome in a given chunk, asynchronously
|
||||||
|
*
|
||||||
|
* @param world World
|
||||||
|
* @param x Chunk X coordinate
|
||||||
|
* @param z Chunk Z coordinate
|
||||||
|
* @param result Result consumer
|
||||||
|
*/
|
||||||
|
public abstract void getBiome(@Nonnull String world, int x, int z,
|
||||||
|
@Nonnull Consumer<BiomeType> result);
|
||||||
|
|
||||||
public abstract com.sk89q.worldedit.world.World getWeWorld(String world);
|
/**
|
||||||
|
* Get the biome in a given chunk, asynchronously
|
||||||
|
*
|
||||||
|
* @param world World
|
||||||
|
* @param x Chunk X coordinate
|
||||||
|
* @param z Chunk Z coordinate
|
||||||
|
* @return Biome
|
||||||
|
* @deprecated Use {@link #getBiome(String, int, int, Consumer)}
|
||||||
|
*/
|
||||||
|
@Deprecated @Nonnull public abstract BiomeType getBiomeSynchronous(@Nonnull String world, int x,
|
||||||
|
int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block at a given location (asynchronously)
|
||||||
|
*
|
||||||
|
* @param location Block location
|
||||||
|
* @param result Result consumer
|
||||||
|
*/
|
||||||
|
public abstract void getBlock(@Nonnull Location location, @Nonnull Consumer<BlockState> result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block at a given location (synchronously)
|
||||||
|
*
|
||||||
|
* @param location Block location
|
||||||
|
* @return Result
|
||||||
|
* @deprecated Use {@link #getBlock(Location, Consumer)}
|
||||||
|
*/
|
||||||
|
@Deprecated @Nonnull public abstract BlockState getBlockSynchronous(@Nonnull Location location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Y coordinate of the highest non-air block in the world, asynchronously
|
||||||
|
*
|
||||||
|
* @param world World name
|
||||||
|
* @param x X coordinate
|
||||||
|
* @param z Z coordinate
|
||||||
|
* @param result Result consumer
|
||||||
|
*/
|
||||||
|
public abstract void getHighestBlock(@Nonnull String world, int x, int z,
|
||||||
|
@Nonnull IntConsumer result);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Y coordinate of the highest non-air block in the world, synchronously
|
||||||
|
*
|
||||||
|
* @param world World name
|
||||||
|
* @param x X coordinate
|
||||||
|
* @param z Z coordinate
|
||||||
|
* @return Result
|
||||||
|
* @deprecated Use {@link #getHighestBlock(String, int, int, IntConsumer)}
|
||||||
|
*/
|
||||||
|
@Deprecated @Nonnegative
|
||||||
|
public abstract int getHighestBlockSynchronous(@Nonnull String world, int x, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the text in a sign
|
||||||
|
*
|
||||||
|
* @param world World name
|
||||||
|
* @param x X coordinate
|
||||||
|
* @param y Y coordinate
|
||||||
|
* @param z Z coordinate
|
||||||
|
* @param lines Sign text
|
||||||
|
*/
|
||||||
|
public abstract void setSign(@Nonnull String world, int x, int y, int z,
|
||||||
|
@Nonnull String[] lines);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the biome in a region
|
||||||
|
*
|
||||||
|
* @param world World name
|
||||||
|
* @param region Region
|
||||||
|
* @param biome New biome
|
||||||
|
*/
|
||||||
|
public abstract void setBiomes(@Nonnull String world, @Nonnull CuboidRegion region,
|
||||||
|
@Nonnull BiomeType biome);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the WorldEdit {@link com.sk89q.worldedit.world.World} corresponding to a world name
|
||||||
|
*
|
||||||
|
* @param world World name
|
||||||
|
* @return World object
|
||||||
|
*/
|
||||||
|
@Nonnull public abstract com.sk89q.worldedit.world.World getWeWorld(@Nonnull String world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh (resend) chunk to player. Usually after setting the biome
|
||||||
|
*
|
||||||
|
* @param x Chunk x location
|
||||||
|
* @param z Chunk z location
|
||||||
|
* @param world World of the chunk
|
||||||
|
*/
|
||||||
public abstract void refreshChunk(int x, int z, String world);
|
public abstract void refreshChunk(int x, int z, String world);
|
||||||
|
|
||||||
public void upload(@Nonnull final Plot plot, UUID uuid, String file,
|
public void upload(@Nonnull final Plot plot, @Nullable final UUID uuid,
|
||||||
RunnableVal<URL> whenDone) {
|
@Nullable final String file, @Nonnull final RunnableVal<URL> whenDone) {
|
||||||
plot.getHome(home -> MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
|
plot.getHome(home -> MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
|
||||||
@Override public void run(OutputStream output) {
|
@Override public void run(OutputStream output) {
|
||||||
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
||||||
@ -191,7 +291,7 @@ public abstract class WorldUtil {
|
|||||||
}, whenDone));
|
}, whenDone));
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getDat(String world) {
|
@Nullable final File getDat(@Nonnull final String world) {
|
||||||
File file = new File(
|
File file = new File(
|
||||||
PlotSquared.platform().getWorldContainer() + File.separator + world + File.separator
|
PlotSquared.platform().getWorldContainer() + File.separator + world + File.separator
|
||||||
+ "level.dat");
|
+ "level.dat");
|
||||||
@ -201,8 +301,8 @@ public abstract class WorldUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getMcr(String world, int x, int z) {
|
@Nullable private File getMcr(@Nonnull final String world, final int x, final int z) {
|
||||||
File file = new File(PlotSquared.platform().getWorldContainer(),
|
final File file = new File(PlotSquared.platform().getWorldContainer(),
|
||||||
world + File.separator + "region" + File.separator + "r." + x + '.' + z + ".mca");
|
world + File.separator + "region" + File.separator + "r." + x + '.' + z + ".mca");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
return file;
|
return file;
|
||||||
@ -210,22 +310,78 @@ public abstract class WorldUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean isBlockSame(BlockState block1, BlockState block2);
|
/**
|
||||||
|
* Check if two blocks are the same type)
|
||||||
|
*
|
||||||
|
* @param block1 First block
|
||||||
|
* @param block2 Second block
|
||||||
|
* @return {@code true} if the blocks have the same type, {@code false} if not
|
||||||
|
*/
|
||||||
|
public abstract boolean isBlockSame(@Nonnull BlockState block1, @Nonnull BlockState block2);
|
||||||
|
|
||||||
public abstract PlotPlayer wrapPlayer(UUID uuid);
|
/**
|
||||||
|
* Get a player object for the player with the given UUID
|
||||||
|
*
|
||||||
|
* @param uuid Player UUID
|
||||||
|
* @return Player object
|
||||||
|
*/
|
||||||
|
@Nonnull public abstract PlotPlayer<?> getPlayer(@Nonnull UUID uuid);
|
||||||
|
|
||||||
public abstract double getHealth(PlotPlayer player);
|
/**
|
||||||
|
* Get the player health
|
||||||
|
*
|
||||||
|
* @param player Player
|
||||||
|
* @return Non-negative health
|
||||||
|
*/
|
||||||
|
@Nonnegative public abstract double getHealth(@Nonnull PlotPlayer<?> player);
|
||||||
|
|
||||||
public abstract void setHealth(PlotPlayer player, double health);
|
/**
|
||||||
|
* Set the player health
|
||||||
|
*
|
||||||
|
* @param player Player health
|
||||||
|
* @param health Non-negative health
|
||||||
|
*/
|
||||||
|
public abstract void setHealth(@Nonnull PlotPlayer<?> player, @Nonnegative double health);
|
||||||
|
|
||||||
public abstract int getFoodLevel(PlotPlayer player);
|
/**
|
||||||
|
* Get the player food level
|
||||||
|
*
|
||||||
|
* @param player Player
|
||||||
|
* @return Non-negative food level
|
||||||
|
*/
|
||||||
|
@Nonnegative public abstract int getFoodLevel(@Nonnull PlotPlayer<?> player);
|
||||||
|
|
||||||
public abstract void setFoodLevel(PlotPlayer player, int foodLevel);
|
/**
|
||||||
|
* Set the player food level
|
||||||
|
*
|
||||||
|
* @param player Player food level
|
||||||
|
* @param foodLevel Non-negative food level
|
||||||
|
*/
|
||||||
|
public abstract void setFoodLevel(@Nonnull PlotPlayer<?> player, @Nonnegative int foodLevel);
|
||||||
|
|
||||||
public abstract Set<EntityType> getTypesInCategory(final String category);
|
/**
|
||||||
|
* Get all entity types belonging to an entity category
|
||||||
|
*
|
||||||
|
* @param category Entity category
|
||||||
|
* @return Set containing all entities belonging to the given category
|
||||||
|
*/
|
||||||
|
@Nonnull public abstract Set<EntityType> getTypesInCategory(@Nonnull String category);
|
||||||
|
|
||||||
public abstract Collection<BlockType> getTileEntityTypes();
|
/**
|
||||||
|
* Get all recognized tile entity types
|
||||||
|
*
|
||||||
|
* @return Collection containing all known tile entity types
|
||||||
|
*/
|
||||||
|
@Nonnull public abstract Collection<BlockType> getTileEntityTypes();
|
||||||
|
|
||||||
public abstract int getTileEntityCount(String world, BlockVector2 chunk);
|
/**
|
||||||
|
* Get the tile entity count in a chunk
|
||||||
|
*
|
||||||
|
* @param world World
|
||||||
|
* @param chunk Chunk coordinates
|
||||||
|
* @return Tile entity count
|
||||||
|
*/
|
||||||
|
@Nonnegative public abstract int getTileEntityCount(@Nonnull String world,
|
||||||
|
@Nonnull BlockVector2 chunk);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,19 +34,20 @@ import com.plotsquared.core.plot.Rating;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import javax.annotation.Nonnull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ import java.util.stream.Stream;
|
|||||||
* The queries can be reused as no results are stored
|
* The queries can be reused as no results are stored
|
||||||
* in the query itself
|
* in the query itself
|
||||||
*/
|
*/
|
||||||
public final class PlotQuery {
|
public final class PlotQuery implements Iterable<Plot> {
|
||||||
|
|
||||||
private final Collection<PlotFilter> filters = new LinkedList<>();
|
private final Collection<PlotFilter> filters = new LinkedList<>();
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
@ -381,16 +382,6 @@ public final class PlotQuery {
|
|||||||
return this.asList();
|
return this.asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform an action on each plot returned by the query
|
|
||||||
*
|
|
||||||
* @param consumer Plot consumer
|
|
||||||
*/
|
|
||||||
public void forEach(@Nonnull final Consumer<Plot> consumer) {
|
|
||||||
Preconditions.checkNotNull(consumer, "Consumer may not be null");
|
|
||||||
this.asCollection().forEach(consumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of plots contained in the query result
|
* Get the amount of plots contained in the query result
|
||||||
*
|
*
|
||||||
@ -429,5 +420,8 @@ public final class PlotQuery {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public Iterator<Plot> iterator() {
|
||||||
|
return this.asCollection().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,20 +34,20 @@ if (PS.hasPlotArea("%s0")) {
|
|||||||
var maxplot;
|
var maxplot;
|
||||||
for (var i in plots) {
|
for (var i in plots) {
|
||||||
var plot = plots[i];
|
var plot = plots[i];
|
||||||
if (plot.x > max) {
|
if (plot.getX() > max) {
|
||||||
max = plot.x;
|
max = plot.getX();
|
||||||
maxplot = plot;
|
maxplot = plot;
|
||||||
}
|
}
|
||||||
if (plot.y > max) {
|
if (plot.getY() > max) {
|
||||||
max = plot.y;
|
max = plot.getY();
|
||||||
maxplot = plot;
|
maxplot = plot;
|
||||||
}
|
}
|
||||||
if (-plot.x > max) {
|
if (-plot.getX() > max) {
|
||||||
max = -plot.x;
|
max = -plot.getX();
|
||||||
maxplot = plot;
|
maxplot = plot;
|
||||||
}
|
}
|
||||||
if (-plot.y > max) {
|
if (-plot.getY() > max) {
|
||||||
max = -plot.y;
|
max = -plot.getY();
|
||||||
maxplot = plot;
|
maxplot = plot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class FlagTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Test public void flagTest() throws Exception {
|
// @Test public void flagTest() throws Exception {
|
||||||
// Plot plot = new Plot(null, new PlotId(0, 0));
|
// Plot plot = new Plot(null, PlotId.of(0, 0));
|
||||||
// plot.owner = UUID.fromString("84499644-ad72-454b-a19d-f28c28df382b");
|
// plot.owner = UUID.fromString("84499644-ad72-454b-a19d-f28c28df382b");
|
||||||
// //plot.setFlag(use, use.parseValue("33,33:1,6:4")); //TODO fix this so FlagTest will run during compile
|
// //plot.setFlag(use, use.parseValue("33,33:1,6:4")); //TODO fix this so FlagTest will run during compile
|
||||||
// Optional<? extends Collection> flag = plot.getFlag(use);
|
// Optional<? extends Collection> flag = plot.getFlag(use);
|
||||||
|
Loading…
Reference in New Issue
Block a user