diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 7e4b9605d..4fc4d9619 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -1010,7 +1010,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl } map.put(plotAreaType.name().toLowerCase(), terrainTypes); } - for (final PlotArea plotArea : PlotSquared.get().getPlotAreas()) { + for (final PlotArea plotArea : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) { final Map terrainTypeMap = map.get(plotArea.getType().name().toLowerCase()); terrainTypeMap.put(plotArea.getTerrain().name().toLowerCase(), @@ -1071,7 +1071,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl world = Bukkit.getWorld(worldName); } else { try { - if (!PlotSquared.get().hasPlotArea(worldName)) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(worldName)) { SetGenCB.setGenerator(BukkitUtil.getWorld(worldName)); } } catch (Exception e) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java index a89588598..8359d1e61 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java @@ -54,7 +54,10 @@ final class BlockStatePopulator extends BlockPopulator { if (this.queue == null) { this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false); } - final PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null); + final PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(world.getName(), null); + if (area == null) { + return; + } final ChunkWrapper wrap = new ChunkWrapper(area.getWorldName(), source.getX(), source.getZ()); final ScopedLocalBlockQueue chunk = this.queue.getForChunk(wrap.x, wrap.z); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index 6f886904f..70688f4c7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -108,7 +108,7 @@ public class BukkitPlotGenerator extends ChunkGenerator if (!this.loaded) { String name = world.getName(); PlotSquared.get().loadWorld(name, this); - Set areas = PlotSquared.get().getPlotAreas(name); + final Set areas = PlotSquared.get().getPlotAreaManager().getPlotAreasSet(name); if (!areas.isEmpty()) { PlotArea area = areas.iterator().next(); if (!area.isMobSpawning()) { @@ -198,8 +198,8 @@ public class BukkitPlotGenerator extends ChunkGenerator if (ChunkManager.preProcessChunk(loc, result)) { return; } - PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null); - if (area == null && (area = PlotSquared.get().getPlotArea(this.levelName, null)) == null) { + PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(world.getName(), null); + if (area == null && (area = PlotSquared.get().getPlotAreaManager().getPlotArea(this.levelName, null)) == null) { throw new IllegalStateException( "Cannot regenerate chunk that does not belong to a plot area." + " Location: " + loc + ", world: " + world); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java index 19a892c43..3ace06fd9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java @@ -90,7 +90,7 @@ public class ChunkListener implements Listener { HashSet toUnload = new HashSet<>(); for (World world : Bukkit.getWorlds()) { String worldName = world.getName(); - if (!PlotSquared.get().hasPlotArea(worldName)) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(worldName)) { continue; } Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world); @@ -177,7 +177,7 @@ public class ChunkListener implements Listener { Chunk chunk = event.getChunk(); if (Settings.Chunk_Processor.AUTO_TRIM) { String world = chunk.getWorld().getName(); - if (PlotSquared.get().hasPlotArea(world)) { + if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { if (unloadChunk(world, chunk, true)) { return; } @@ -200,7 +200,7 @@ public class ChunkListener implements Listener { event.setCancelled(true); return; } - if (!PlotSquared.get().hasPlotArea(chunk.getWorld().getName())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(chunk.getWorld().getName())) { return; } Entity[] entities = chunk.getEntities(); @@ -230,7 +230,7 @@ public class ChunkListener implements Listener { event.setCancelled(true); return; } - if (!PlotSquared.get().hasPlotArea(chunk.getWorld().getName())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(chunk.getWorld().getName())) { return; } Entity[] entities = chunk.getEntities(); @@ -281,7 +281,7 @@ public class ChunkListener implements Listener { } public boolean processChunk(Chunk chunk, boolean unload) { - if (!PlotSquared.get().hasPlotArea(chunk.getWorld().getName())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(chunk.getWorld().getName())) { return false; } Entity[] entities = chunk.getEntities(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java index 8b70143b1..b122b51d1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java @@ -78,7 +78,7 @@ public class EntitySpawnListener implements Listener { if (areaName == world.getName()) { } else { areaName = world.getName(); - hasPlotArea = PlotSquared.get().hasPlotArea(areaName); + hasPlotArea = PlotSquared.get().getPlotAreaManager().hasPlotArea(areaName); } if (!hasPlotArea) { return; @@ -90,7 +90,7 @@ public class EntitySpawnListener implements Listener { @NotNull World world = entity.getWorld(); List meta = entity.getMetadata(KEY); if (meta.isEmpty()) { - if (PlotSquared.get().hasPlotArea(world.getName())) { + if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world.getName())) { entity.setMetadata(KEY, new FixedMetadataValue((Plugin) PlotSquared.platform(), entity.getLocation())); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index a512189f7..9816709e3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -305,7 +305,7 @@ public class PaperListener implements Listener { return; } Location location = BukkitUtil.getLocation(entity); - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return; } PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index b10370cfc..13e22685d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -483,7 +483,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } Location location = BukkitUtil.getLocation(entity); - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return; } PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); @@ -497,7 +497,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler public boolean onProjectileHit(ProjectileHitEvent event) { Projectile entity = event.getEntity(); Location location = BukkitUtil.getLocation(entity); - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return true; } PlotArea area = location.getPlotArea(); @@ -1069,7 +1069,7 @@ public class PlayerEvents extends PlotListener implements Listener { PlotArea area = location.getPlotArea(); boolean plotArea = location.isPlotArea(); if (!plotArea) { - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return; } return; @@ -1165,7 +1165,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityBlockForm(EntityBlockFormEvent event) { String world = event.getBlock().getWorld().getName(); - if (!PlotSquared.get().hasPlotArea(world)) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { return; } Location location = BukkitUtil.getLocation(event.getBlock().getLocation()); @@ -1495,7 +1495,7 @@ public class PlayerEvents extends PlotListener implements Listener { Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ()); PlotArea area = location.getPlotArea(); if (area == null) { - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return; } for (Block block1 : event.getBlocks()) { @@ -1532,7 +1532,7 @@ public class PlayerEvents extends PlotListener implements Listener { Location location = BukkitUtil.getLocation(block.getLocation()); PlotArea area = location.getPlotArea(); if (area == null) { - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return; } if (this.pistonBlocks) { @@ -1625,7 +1625,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onStructureGrow(StructureGrowEvent event) { - if (!PlotSquared.get().hasPlotArea(event.getWorld().getName())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(event.getWorld().getName())) { return; } List blocks = event.getBlocks(); @@ -1688,7 +1688,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; }*/ HumanEntity entity = event.getWhoClicked(); - if (!(entity instanceof Player) || !PlotSquared.get() + if (!(entity instanceof Player) || !PlotSquared.get().getPlotAreaManager() .hasPlotArea(entity.getWorld().getName())) { return; } @@ -1819,7 +1819,7 @@ public class PlayerEvents extends PlotListener implements Listener { public void onPotionSplash(LingeringPotionSplashEvent event) { Projectile entity = event.getEntity(); Location location = BukkitUtil.getLocation(entity); - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return; } if (!this.onProjectileHit(event)) { @@ -1884,7 +1884,7 @@ public class PlayerEvents extends PlotListener implements Listener { Block block = event.getBlock(); Location location = BukkitUtil.getLocation(block.getLocation()); String world = location.getWorld(); - if (!PlotSquared.get().hasPlotArea(world)) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { return; } PlotArea area = location.getPlotArea(); @@ -2158,7 +2158,7 @@ public class PlayerEvents extends PlotListener implements Listener { Block block = event.getBlock(); World world = block.getWorld(); String worldName = world.getName(); - if (!PlotSquared.get().hasPlotArea(worldName)) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(worldName)) { return; } Location location = BukkitUtil.getLocation(block.getLocation()); @@ -2669,7 +2669,7 @@ public class PlayerEvents extends PlotListener implements Listener { public void onPotionSplash(PotionSplashEvent event) { ThrownPotion damager = event.getPotion(); Location location = BukkitUtil.getLocation(damager); - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return; } int count = 0; @@ -2699,7 +2699,7 @@ public class PlayerEvents extends PlotListener implements Listener { public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) { Entity damager = event.getDamager(); Location location = BukkitUtil.getLocation(damager); - if (!PlotSquared.get().hasPlotArea(location.getWorld())) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorld())) { return; } Entity victim = event.getEntity(); diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 20a74ac94..0371613b8 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -87,7 +87,6 @@ import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.uuid.UUIDPipeline; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.regions.CuboidRegion; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @@ -387,11 +386,17 @@ public class PlotSquared

{ return PlotSquared.instance; } + + /** + * Get the platform specific implementation of PlotSquared + * + * @return Platform implementation + */ @NotNull public static PlotPlatform platform() { if (instance != null && instance.platform != null) { return instance.platform; } - throw new IllegalStateException("Plot main implementation is missing"); + throw new IllegalStateException("Plot platform implementation is missing"); } /** @@ -480,9 +485,12 @@ public class PlotSquared

{ return plot.getArea().getPlotManager(); } - public PlotManager getPlotManager(Location location) { - PlotArea pa = getPlotAreaAbs(location); - return pa != null ? pa.getPlotManager() : null; + @Nullable public PlotManager getPlotManager(@NotNull final Location location) { + final PlotArea plotArea = this.getPlotAreaManager().getPlotArea(location); + if (plotArea == null) { + return null; + } + return plotArea.getPlotManager(); } /** @@ -586,8 +594,8 @@ public class PlotSquared

{ setPlotsTmp(area); } - public void removePlotAreas(String world) { - for (PlotArea area : getPlotAreas(world)) { + public void removePlotAreas(@NotNull final String world) { + for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) { if (area.getWorldName().equals(world)) { removePlotArea(area); } @@ -609,9 +617,9 @@ public class PlotSquared

{ this.clusters_tmp.put(area.toString(), area.getClusters()); } - public Set getClusters(String world) { - Set set = new HashSet<>(); - for (PlotArea area : getPlotAreas(world)) { + public Set getClusters(@NotNull final String world) { + final Set set = new HashSet<>(); + for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) { set.addAll(area.getClusters()); } return Collections.unmodifiableSet(set); @@ -882,7 +890,7 @@ public class PlotSquared

{ */ @Deprecated public Set getPlots(final PlotFilter... filters) { final List areas = new LinkedList<>(); - for (final PlotArea plotArea : this.getPlotAreas()) { + for (final PlotArea plotArea : this.getPlotAreaManager().getAllPlotAreas()) { for (final PlotFilter filter : filters) { if (filter.allowsArea(plotArea)) { areas.add(plotArea); @@ -911,21 +919,20 @@ public class PlotSquared

{ return result; } - public void setPlots(HashMap> plots) { + public void setPlots(@NotNull final Map> plots) { if (this.plots_tmp == null) { this.plots_tmp = new HashMap<>(); } - for (Entry> entry : plots.entrySet()) { - String world = entry.getKey(); - PlotArea area = getPlotArea(world, null); - if (area == null) { - HashMap map = - this.plots_tmp.computeIfAbsent(world, k -> new HashMap<>()); + for (final Entry> entry : plots.entrySet()) { + final String world = entry.getKey(); + final PlotArea plotArea = this.getPlotAreaManager().getPlotArea(world, null); + if (plotArea == null) { + Map map = this.plots_tmp.computeIfAbsent(world, k -> new HashMap<>()); map.putAll(entry.getValue()); } else { for (Plot plot : entry.getValue().values()) { - plot.setArea(area); - area.addPlot(plot); + plot.setArea(plotArea); + plotArea.addPlot(plot); } } } @@ -962,7 +969,7 @@ public class PlotSquared

{ * @param player the plot owner * @return Set of plot */ - public Set getPlots(String world, PlotPlayer player) { + public Set getPlots(String world, PlotPlayer player) { return PlotQuery.newQuery().inWorld(world).ownedBy(player).asSet(); } @@ -973,7 +980,7 @@ public class PlotSquared

{ * @param player the plot owner * @return Set of plot */ - public Set getPlots(PlotArea area, PlotPlayer player) { + public Set getPlots(PlotArea area, PlotPlayer player) { return PlotQuery.newQuery().inArea(area).ownedBy(player).asSet(); } @@ -999,17 +1006,6 @@ public class PlotSquared

{ return PlotQuery.newQuery().inArea(area).ownedBy(uuid).asSet(); } - /** - * Check if a plot world. - * - * @param world the world - * @return if a plot world is registered - * @see #getPlotAreaByString(String) to get the PlotArea object - */ - public boolean hasPlotArea(String world) { - return plotAreaManager.getPlotAreas(world, null).length != 0; - } - public Collection getPlots(String world) { return PlotQuery.newQuery().inWorld(world).asCollection(); } @@ -1020,7 +1016,7 @@ public class PlotSquared

{ * @param player the player to retrieve the plots for * @return Set of Plot */ - public Set getPlots(PlotPlayer player) { + public Set getPlots(PlotPlayer player) { return PlotQuery.newQuery().ownedBy(player).asSet(); } @@ -1032,7 +1028,7 @@ public class PlotSquared

{ return area == null ? null : id == null ? null : area.getPlot(id); } - public Set getBasePlots(PlotPlayer player) { + public Set getBasePlots(PlotPlayer player) { return getBasePlots(player.getUUID()); } @@ -1276,7 +1272,7 @@ public class PlotSquared

{ throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `--`"); } - PlotArea existing = getPlotArea(world, name); + final PlotArea existing = this.getPlotAreaManager().getPlotArea(world, name); if (existing != null && name.equals(existing.getId())) { continue; } @@ -1937,11 +1933,6 @@ public class PlotSquared

{ } } - public PlotArea getFirstPlotArea() { - PlotArea[] areas = plotAreaManager.getAllPlotAreas(); - return areas.length > 0 ? areas[0] : null; - } - public int getPlotAreaCount() { return this.plotAreaManager.getAllPlotAreas().length; } @@ -1951,12 +1942,6 @@ public class PlotSquared

{ .mapToInt(PlotArea::getPlotCount).sum(); } - public Set getPlotAreas() { - final Set set = new HashSet<>(); - Collections.addAll(set, plotAreaManager.getAllPlotAreas()); - return Collections.unmodifiableSet(set); - } - /** * Check if the chunk uses vanilla/non-PlotSquared generation * @@ -1979,81 +1964,6 @@ public class PlotSquared

{ return areas != null && (areas.length > 1 || areas[0].getType() != PlotAreaType.NORMAL); } - /** - * Gets a list of PlotArea objects. - * - * @param world the world - * @return Collection of PlotArea objects - */ - public Set getPlotAreas(@NonNull final String world) { - final Set set = new HashSet<>(); - Collections.addAll(set, plotAreaManager.getPlotAreas(world, null)); - return set; - } - - /** - * Gets the relevant plot area for a specified location. - *

    - *
  • If there is only one plot area globally that will be returned. - *
  • If there is only one plot area in the world, it will return that. - *
  • If the plot area for a location cannot be unambiguously - * resolved, null will be returned. - *
- * Note: An applicable plot area may not include the location i.e. clusters - * - * @param location the location - * @return - */ - public PlotArea getApplicablePlotArea(@NonNull final Location location) { - return plotAreaManager.getApplicablePlotArea(location); - } - - public PlotArea getPlotArea(@NonNull final String world, final String id) { - return plotAreaManager.getPlotArea(world, id); - } - - /** - * Gets the {@code PlotArea} which contains a location. - *
    - *
  • If the plot area does not contain a location, null - * will be returned. - *
- * - * @param location the location - * @return the {@link PlotArea} in the location, null if non existent - */ - public PlotArea getPlotAreaAbs(@NonNull final Location location) { - return plotAreaManager.getPlotArea(location); - } - - public PlotArea getPlotAreaByString(@NonNull final String search) { - String[] split = search.split("[;,]"); - PlotArea[] areas = plotAreaManager.getPlotAreas(split[0], null); - if (areas == null) { - for (PlotArea area : plotAreaManager.getAllPlotAreas()) { - if (area.getWorldName().equalsIgnoreCase(split[0])) { - if (area.getId() == null || split.length == 2 && area.getId() - .equalsIgnoreCase(split[1])) { - return area; - } - } - } - return null; - } - if (areas.length == 1) { - return areas[0]; - } else if (split.length == 1) { - return null; - } else { - for (PlotArea area : areas) { - if (StringMan.isEqual(split[1], area.getId())) { - return area; - } - } - return null; - } - } - /** * Gets Plots based on alias * @@ -2066,13 +1976,6 @@ public class PlotSquared

{ return PlotQuery.newQuery().inWorld(worldname).withAlias(alias).asSet(); } - public Set getPlotAreas(final String world, final CuboidRegion region) { - final PlotArea[] areas = plotAreaManager.getPlotAreas(world, region); - final Set set = new HashSet<>(); - Collections.addAll(set, areas); - return Collections.unmodifiableSet(set); - } - public YamlConfiguration getConfig() { return config; } diff --git a/Core/src/main/java/com/plotsquared/core/api/PlotAPI.java b/Core/src/main/java/com/plotsquared/core/api/PlotAPI.java index 3991643a3..a88e404fe 100644 --- a/Core/src/main/java/com/plotsquared/core/api/PlotAPI.java +++ b/Core/src/main/java/com/plotsquared/core/api/PlotAPI.java @@ -157,7 +157,7 @@ import java.util.UUID; if (world == null) { return Collections.emptySet(); } - return PlotSquared.get().getPlotAreas(world); + return PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world); } /** diff --git a/Core/src/main/java/com/plotsquared/core/command/Area.java b/Core/src/main/java/com/plotsquared/core/command/Area.java index 514030d6b..7f7e2bb1c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Area.java +++ b/Core/src/main/java/com/plotsquared/core/command/Area.java @@ -70,6 +70,8 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Objects; import java.util.Set; @@ -102,7 +104,7 @@ public class Area extends SubCommand { MainUtil.sendMessage(player, Captions.SINGLE_AREA_NEEDS_NAME); return false; } - final PlotArea existingArea = PlotSquared.get().getPlotArea(player.getLocation().getWorld(), args[1]); + final PlotArea existingArea = PlotSquared.get().getPlotAreaManager().getPlotArea(player.getLocation().getWorld(), args[1]); if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) { MainUtil.sendMessage(player, Captions.SINGLE_AREA_NAME_TAKEN); return false; @@ -274,8 +276,8 @@ public class Area extends SubCommand { final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower); final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower); final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz); - Set areas = - PlotSquared.get().getPlotAreas(area.getWorldName(), region); + final Set areas = PlotSquared.get().getPlotAreaManager() + .getPlotAreasSet(area.getWorldName(), region); if (!areas.isEmpty()) { Captions.CLUSTER_INTERSECTION .send(player, areas.iterator().next().toString()); @@ -340,12 +342,12 @@ public class Area extends SubCommand { builder.worldName(split[0]); final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id, PlotSquared.platform().getDefaultGenerator(), null, null); - PlotArea other = PlotSquared.get().getPlotArea(pa.getWorldName(), id); + PlotArea other = PlotSquared.get().getPlotAreaManager().getPlotArea(pa.getWorldName(), id); if (other != null && Objects.equals(pa.getId(), other.getId())) { Captions.SETUP_WORLD_TAKEN.send(player, pa.toString()); return false; } - Set areas = PlotSquared.get().getPlotAreas(pa.getWorldName()); + Set areas = PlotSquared.get().getPlotAreaManager().getPlotAreasSet(pa.getWorldName()); if (!areas.isEmpty()) { PlotArea area = areas.iterator().next(); pa.setType(area.getType()); @@ -490,7 +492,7 @@ public class Area extends SubCommand { area = player.getApplicablePlotArea(); break; case 2: - area = PlotSquared.get().getPlotAreaByString(args[1]); + area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]); break; default: Captions.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]"); @@ -552,7 +554,7 @@ public class Area extends SubCommand { Captions.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]"); return false; } - ArrayList areas = new ArrayList<>(PlotSquared.get().getPlotAreas()); + final List areas = new ArrayList<>(Arrays.asList(PlotSquared.get().getPlotAreaManager().getAllPlotAreas())); paginate(player, areas, 8, page, new RunnableVal3() { @Override public void run(Integer i, PlotArea area, PlotMessage message) { @@ -635,7 +637,7 @@ public class Area extends SubCommand { Captions.COMMAND_SYNTAX.send(player, "/plot visit [area]"); return false; } - PlotArea area = PlotSquared.get().getPlotAreaByString(args[1]); + PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]); if (area == null) { Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/Condense.java b/Core/src/main/java/com/plotsquared/core/command/Condense.java index 8f792ee7e..0e49ebd36 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Condense.java +++ b/Core/src/main/java/com/plotsquared/core/command/Condense.java @@ -59,7 +59,7 @@ public class Condense extends SubCommand { MainUtil.sendMessage(player, getUsage()); return false; } - PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]); + PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]); if (area == null || !WorldUtil.IMP.isWorld(area.getWorldName())) { MainUtil.sendMessage(player, "INVALID AREA"); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java index 413aa35bd..84f2a67f7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java @@ -80,7 +80,7 @@ public class DatabaseCommand extends SubCommand { return false; } List plots; - PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]); + PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]); if (area != null) { plots = PlotSquared.get().sortPlotsByTemp(area.getPlots()); args = Arrays.copyOfRange(args, 1, args.length); @@ -116,7 +116,7 @@ public class DatabaseCommand extends SubCommand { plots = new ArrayList<>(); for (Entry> entry : map.entrySet()) { String areaName = entry.getKey(); - PlotArea pa = PlotSquared.get().getPlotAreaByString(areaName); + PlotArea pa = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(areaName); if (pa != null) { for (Entry entry2 : entry.getValue().entrySet()) { Plot plot = entry2.getValue(); diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index 91997a4ec..28150d27c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -118,7 +118,7 @@ public class Debug extends SubCommand { information.append(header); information.append(getSection(section, "PlotArea")); information.append( - getLine(line, "Plot Worlds", StringMan.join(PlotSquared.get().getPlotAreas(), ", "))); + getLine(line, "Plot Worlds", StringMan.join(PlotSquared.get().getPlotAreaManager().getAllPlotAreas(), ", "))); information.append(getLine(line, "Owned Plots", PlotSquared.get().getPlots().size())); information.append(getSection(section, "Messages")); information.append(getLine(line, "Total Messages", Captions.values().length)); diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java index 036e5ed2a..1f4967734 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -259,7 +259,7 @@ public class DebugExec extends SubCommand { "&cInvalid syntax: /plot debugexec start-rgar "); return false; } - PlotArea area = PlotSquared.get().getPlotAreaByString(args[1]); + PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]); if (area == null) { MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD, args[1]); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/Download.java b/Core/src/main/java/com/plotsquared/core/command/Download.java index efd4079d5..26ce40575 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Download.java +++ b/Core/src/main/java/com/plotsquared/core/command/Download.java @@ -52,7 +52,7 @@ public class Download extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { String world = player.getLocation().getWorld(); - if (!PlotSquared.get().hasPlotArea(world)) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); } final Plot plot = player.getCurrentPlot(); diff --git a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java index 0f5564055..518e780a4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -297,7 +297,7 @@ public class ListCmd extends SubCommand { plotConsumer.accept(PlotQuery.newQuery().plotsBySearch(term)); break; default: - if (PlotSquared.get().hasPlotArea(args[0])) { + if (PlotSquared.get().getPlotAreaManager().hasPlotArea(args[0])) { if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_WORLD); diff --git a/Core/src/main/java/com/plotsquared/core/command/Load.java b/Core/src/main/java/com/plotsquared/core/command/Load.java index aa952a007..30a503c76 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Load.java +++ b/Core/src/main/java/com/plotsquared/core/command/Load.java @@ -54,7 +54,7 @@ public class Load extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { String world = player.getLocation().getWorld(); - if (!PlotSquared.get().hasPlotArea(world)) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); } final Plot plot = player.getCurrentPlot(); diff --git a/Core/src/main/java/com/plotsquared/core/command/Move.java b/Core/src/main/java/com/plotsquared/core/command/Move.java index 136bbcfaa..f6debe194 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Move.java +++ b/Core/src/main/java/com/plotsquared/core/command/Move.java @@ -70,7 +70,7 @@ public class Move extends SubCommand { Captions.COMMAND_SYNTAX.send(player, getUsage()); return CompletableFuture.completedFuture(false); } - PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]); + PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]); Plot plot2; if (area == null) { plot2 = MainUtil.getPlotFromString(player, args[0], true); diff --git a/Core/src/main/java/com/plotsquared/core/command/Purge.java b/Core/src/main/java/com/plotsquared/core/command/Purge.java index 9a89b2230..764825ca7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Purge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java @@ -78,7 +78,7 @@ public class Purge extends SubCommand { break; case "area": case "a": - area = PlotSquared.get().getPlotAreaByString(split[1]); + area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(split[1]); if (area == null) { Captions.NOT_VALID_PLOT_WORLD.send(player, split[1]); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java index 69d0022f6..5f87a131a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java +++ b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java @@ -59,7 +59,7 @@ public class RegenAllRoads extends SubCommand { "/plot regenallroads [height]"); return false; } - PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]); + PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]); if (area == null) { Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/Save.java b/Core/src/main/java/com/plotsquared/core/command/Save.java index 480167576..a9f55e31e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -51,7 +51,7 @@ public class Save extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { String world = player.getLocation().getWorld(); - if (!PlotSquared.get().hasPlotArea(world)) { + if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) { return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); } final Plot plot = player.getCurrentPlot(); diff --git a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java index 66e4a0662..f6c971911 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java @@ -150,7 +150,7 @@ public class SchematicCmd extends SubCommand { MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_WORLD_ARGS); return false; } - PlotArea area = PlotSquared.get().getPlotAreaByString(args[1]); + PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]); if (area == null) { Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/Template.java b/Core/src/main/java/com/plotsquared/core/command/Template.java index 5e5f9675b..8234e7226 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Template.java +++ b/Core/src/main/java/com/plotsquared/core/command/Template.java @@ -159,7 +159,7 @@ public class Template extends SubCommand { "/plot template import