Encapsulation and Magic Values (#2711)

* Encapsulate attributes of PlotArea using lombok Getters/Setters

* Limit access to collections, don't expose implementation details

* Better naming for some boolean attributes

* Replace magic type value with PlotAreaType enum

* Replace magic terrain value with PlotAreaTerrainType enum

* Fix remaining rebase conflicts

* Reduce code duplication

Co-authored-by: Alexander Söderberg <Sauilitired@users.noreply.github.com>
This commit is contained in:
Hannes Greule 2020-04-02 14:34:38 +02:00 committed by GitHub
parent 9764d4d226
commit 099a680c85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 600 additions and 436 deletions

View File

@ -39,6 +39,8 @@ import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject; import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
@ -318,7 +320,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override @SuppressWarnings("deprecation") public void runEntityTask() { @Override @SuppressWarnings("deprecation") public void runEntityTask() {
PlotSquared.log(Captions.PREFIX + "KillAllEntities started."); PlotSquared.log(Captions.PREFIX + "KillAllEntities started.");
TaskManager.runTaskRepeat(() -> PlotSquared.get().forEachPlotArea(plotArea -> { TaskManager.runTaskRepeat(() -> PlotSquared.get().forEachPlotArea(plotArea -> {
final World world = Bukkit.getWorld(plotArea.worldname); final World world = Bukkit.getWorld(plotArea.getWorldName());
try { try {
if (world == null) { if (world == null) {
return; return;
@ -728,8 +730,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
SetupObject setup = new SetupObject(); SetupObject setup = new SetupObject();
setup.plotManager = manager; setup.plotManager = manager;
setup.setupGenerator = worldConfig.getString("generator.init", manager); setup.setupGenerator = worldConfig.getString("generator.init", manager);
setup.type = worldConfig.getInt("generator.type"); setup.type = MainUtil.getType(worldConfig);
setup.terrain = worldConfig.getInt("generator.terrain"); setup.terrain = MainUtil.getTerrain(worldConfig);
setup.step = new ConfigurationNode[0]; setup.step = new ConfigurationNode[0];
setup.world = worldName; setup.world = worldName;
SetupUtils.manager.setupWorld(setup); SetupUtils.manager.setupWorld(setup);

View File

@ -63,7 +63,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
} }
@Override public void augment(PlotArea area) { @Override public void augment(PlotArea area) {
BukkitAugmentedGenerator.get(BukkitUtil.getWorld(area.worldname)); BukkitAugmentedGenerator.get(BukkitUtil.getWorld(area.getWorldName()));
} }
@Override public boolean isFull() { @Override public boolean isFull() {
@ -88,8 +88,8 @@ public class BukkitPlotGenerator extends ChunkGenerator
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(name); Set<PlotArea> areas = PlotSquared.get().getPlotAreas(name);
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
PlotArea area = areas.iterator().next(); PlotArea area = areas.iterator().next();
if (!area.MOB_SPAWNING) { if (!area.isMobSpawning()) {
if (!area.SPAWN_EGGS) { if (!area.isSpawnEggs()) {
world.setSpawnFlags(false, false); world.setSpawnFlags(false, false);
} }
world.setAmbientSpawnLimit(0); world.setAmbientSpawnLimit(0);

View File

@ -28,7 +28,7 @@ final class BlockStatePopulator extends BlockPopulator {
this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false); this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
} }
final PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null); final PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
final ChunkWrapper wrap = new ChunkWrapper(area.worldname, source.getX(), source.getZ()); final ChunkWrapper wrap = new ChunkWrapper(area.getWorldName(), source.getX(), source.getZ());
final ScopedLocalBlockQueue chunk = this.queue.getForChunk(wrap.x, wrap.z); final ScopedLocalBlockQueue chunk = this.queue.getForChunk(wrap.x, wrap.z);
if (this.plotGenerator.populateChunk(chunk, area)) { if (this.plotGenerator.populateChunk(chunk, area)) {
this.queue.flush(); this.queue.flush();

View File

@ -101,7 +101,7 @@ public class EntitySpawnListener implements Listener {
} }
Plot plot = location.getOwnedPlotAbs(); Plot plot = location.getOwnedPlotAbs();
if (plot == null) { if (plot == null) {
if (!area.MOB_SPAWNING) { if (!area.isMobSpawning()) {
EntityType type = entity.getType(); EntityType type = entity.getType();
switch (type) { switch (type) {
case DROPPED_ITEM: case DROPPED_ITEM:
@ -112,7 +112,7 @@ public class EntitySpawnListener implements Listener {
case PLAYER: case PLAYER:
return; return;
} }
if (type.isAlive() || !area.MISC_SPAWN_UNOWNED) { if (type.isAlive() || !area.isMiscSpawnUnowned()) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -996,7 +996,7 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation(); Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) { if (area == null || (area.isPlotChat() == plotPlayer.getAttribute("chat"))) {
return; return;
} }
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
@ -1064,12 +1064,12 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
} else if ( } else if (
(location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT) (location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight())
&& !Permissions && !Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true); event.setCancelled(true);
MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.getTranslated() MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.getTranslated()
.replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT))); .replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions if (!Permissions
@ -2094,7 +2094,7 @@ public class PlayerEvents extends PlotListener implements Listener {
case EGG: case EGG:
case OCELOT_BABY: case OCELOT_BABY:
case SPAWNER_EGG: case SPAWNER_EGG:
if (!area.SPAWN_EGGS) { if (!area.isSpawnEggs()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -2102,12 +2102,12 @@ public class PlayerEvents extends PlotListener implements Listener {
case REINFORCEMENTS: case REINFORCEMENTS:
case NATURAL: case NATURAL:
case CHUNK_GEN: case CHUNK_GEN:
if (!area.MOB_SPAWNING) { if (!area.isMobSpawning()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
case BREEDING: case BREEDING:
if (!area.SPAWN_BREEDING) { if (!area.isSpawnBreeding()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -2116,13 +2116,13 @@ public class PlayerEvents extends PlotListener implements Listener {
case BUILD_SNOWMAN: case BUILD_SNOWMAN:
case BUILD_WITHER: case BUILD_WITHER:
case CUSTOM: case CUSTOM:
if (!area.SPAWN_CUSTOM && entity.getType() != EntityType.ARMOR_STAND) { if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break; break;
case SPAWNER: case SPAWNER:
if (!area.MOB_SPAWNER_SPAWNING) { if (!area.isMobSpawnerSpawning()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -2130,7 +2130,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
Plot plot = area.getOwnedPlotAbs(location); Plot plot = area.getOwnedPlotAbs(location);
if (plot == null) { if (plot == null) {
if (!area.MOB_SPAWNING) { if (!area.isMobSpawning()) {
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
@ -2928,11 +2928,11 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot != null) { if (plot != null) {
if ((location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT) if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight())
&& !Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { && !Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true); event.setCancelled(true);
MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated() MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated()
.replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT))); .replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {

View File

@ -128,7 +128,7 @@ public class BukkitChunkManager extends ChunkManager {
return existing; return existing;
} }
PlotArea area = plot.getArea(); PlotArea area = plot.getArea();
World world = BukkitUtil.getWorld(area.worldname); World world = BukkitUtil.getWorld(area.getWorldName());
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
Location top = plot.getTopAbs(); Location top = plot.getTopAbs();

View File

@ -7,6 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper; import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject; import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
@ -80,10 +81,10 @@ public class BukkitSetupUtils extends SetupUtils {
SetupUtils.manager.updateGenerators(); SetupUtils.manager.updateGenerators();
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step; ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
String world = object.world; String world = object.world;
int type = object.type; PlotAreaType type = object.type;
String worldPath = "worlds." + object.world; String worldPath = "worlds." + object.world;
switch (type) { switch (type) {
case 2: { case PARTIAL: {
if (object.id != null) { if (object.id != null) {
if (!PlotSquared.get().worlds.contains(worldPath)) { if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath); PlotSquared.get().worlds.createSection(worldPath);
@ -101,8 +102,8 @@ public class BukkitSetupUtils extends SetupUtils {
for (ConfigurationNode step : steps) { for (ConfigurationNode step : steps) {
options.put(step.getConstant(), step.getValue()); options.put(step.getConstant(), step.getValue());
} }
options.put("generator.type", object.type); options.put("generator.type", object.type.toString());
options.put("generator.terrain", object.terrain); options.put("generator.terrain", object.terrain.toString());
options.put("generator.plugin", object.plotManager); options.put("generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) { .equals(object.plotManager)) {
@ -127,7 +128,7 @@ public class BukkitSetupUtils extends SetupUtils {
} }
break; break;
} }
case 1: { case AUGMENTED: {
if (!object.plotManager.endsWith(":single")) { if (!object.plotManager.endsWith(":single")) {
if (!PlotSquared.get().worlds.contains(worldPath)) { if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath); PlotSquared.get().worlds.createSection(worldPath);
@ -140,9 +141,9 @@ public class BukkitSetupUtils extends SetupUtils {
} }
} }
PlotSquared.get().worlds PlotSquared.get().worlds
.set("worlds." + world + ".generator.type", object.type); .set("worlds." + world + ".generator.type", object.type.toString());
PlotSquared.get().worlds PlotSquared.get().worlds
.set("worlds." + world + ".generator.terrain", object.terrain); .set("worlds." + world + ".generator.terrain", object.terrain.toString());
PlotSquared.get().worlds PlotSquared.get().worlds
.set("worlds." + world + ".generator.plugin", object.plotManager); .set("worlds." + world + ".generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator if (object.setupGenerator != null && !object.setupGenerator
@ -157,7 +158,7 @@ public class BukkitSetupUtils extends SetupUtils {
} }
break; break;
} }
case 0: { case NORMAL: {
if (steps.length != 0) { if (steps.length != 0) {
if (!PlotSquared.get().worlds.contains(worldPath)) { if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath); PlotSquared.get().worlds.createSection(worldPath);
@ -224,7 +225,7 @@ public class BukkitSetupUtils extends SetupUtils {
if (SetupUtils.generators.isEmpty()) { if (SetupUtils.generators.isEmpty()) {
updateGenerators(); updateGenerators();
} }
World world = Bukkit.getWorld(plotArea.worldname); World world = Bukkit.getWorld(plotArea.getWorldName());
if (world == null) { if (world == null) {
return null; return null;
} }

View File

@ -405,12 +405,12 @@ import java.util.zip.ZipInputStream;
} }
public PlotManager getPlotManager(Plot plot) { public PlotManager getPlotManager(Plot plot) {
return plot.getArea().manager; return plot.getArea().getPlotManager();
} }
public PlotManager getPlotManager(Location location) { public PlotManager getPlotManager(Location location) {
PlotArea pa = getPlotAreaAbs(location); PlotArea pa = getPlotAreaAbs(location);
return pa != null ? pa.manager : null; return pa != null ? pa.getPlotManager() : null;
} }
/** /**
@ -422,8 +422,8 @@ import java.util.zip.ZipInputStream;
public void addPlotArea(PlotArea plotArea) { public void addPlotArea(PlotArea plotArea) {
HashMap<PlotId, Plot> plots; HashMap<PlotId, Plot> plots;
if (plots_tmp == null || (plots = plots_tmp.remove(plotArea.toString())) == null) { if (plots_tmp == null || (plots = plots_tmp.remove(plotArea.toString())) == null) {
if (plotArea.TYPE == 2) { if (plotArea.getType() == PlotAreaType.PARTIAL) {
plots = this.plots_tmp != null ? this.plots_tmp.get(plotArea.worldname) : null; plots = this.plots_tmp != null ? this.plots_tmp.get(plotArea.getWorldName()) : null;
if (plots != null) { if (plots != null) {
Iterator<Entry<PlotId, Plot>> iterator = plots.entrySet().iterator(); Iterator<Entry<PlotId, Plot>> iterator = plots.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -443,9 +443,9 @@ import java.util.zip.ZipInputStream;
} }
Set<PlotCluster> clusters; Set<PlotCluster> clusters;
if (clusters_tmp == null || (clusters = clusters_tmp.remove(plotArea.toString())) == null) { if (clusters_tmp == null || (clusters = clusters_tmp.remove(plotArea.toString())) == null) {
if (plotArea.TYPE == 2) { if (plotArea.getType() == PlotAreaType.PARTIAL) {
clusters = clusters =
this.clusters_tmp != null ? this.clusters_tmp.get(plotArea.worldname) : null; this.clusters_tmp != null ? this.clusters_tmp.get(plotArea.getWorldName()) : null;
if (clusters != null) { if (clusters != null) {
Iterator<PlotCluster> iterator = clusters.iterator(); Iterator<PlotCluster> iterator = clusters.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -515,7 +515,7 @@ import java.util.zip.ZipInputStream;
public void removePlotAreas(String world) { public void removePlotAreas(String world) {
for (PlotArea area : getPlotAreas(world)) { for (PlotArea area : getPlotAreas(world)) {
if (area.worldname.equals(world)) { if (area.getWorldName().equals(world)) {
removePlotArea(area); removePlotArea(area);
} }
} }
@ -1090,13 +1090,13 @@ import java.util.zip.ZipInputStream;
} }
String path = "worlds." + world; String path = "worlds." + world;
ConfigurationSection worldSection = this.worlds.getConfigurationSection(path); ConfigurationSection worldSection = this.worlds.getConfigurationSection(path);
int type; PlotAreaType type;
if (worldSection != null) { if (worldSection != null) {
type = worldSection.getInt("generator.type", 0); type = MainUtil.getType(worldSection);
} else { } else {
type = 0; type = PlotAreaType.NORMAL;
} }
if (type == 0) { if (type == PlotAreaType.NORMAL) {
if (plotAreaManager.getPlotAreas(world, null).length != 0) { if (plotAreaManager.getPlotAreas(world, null).length != 0) {
debug("World possibly already loaded: " + world); debug("World possibly already loaded: " + world);
return; return;
@ -1158,7 +1158,7 @@ import java.util.zip.ZipInputStream;
} }
PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'"); PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'");
String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName()); String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName());
if (type == 2) { if (type == PlotAreaType.PARTIAL) {
Set<PlotCluster> clusters = Set<PlotCluster> clusters =
this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<>(); this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<>();
if (clusters == null) { if (clusters == null) {
@ -1225,9 +1225,9 @@ import java.util.zip.ZipInputStream;
addPlotArea(pa); addPlotArea(pa);
return; return;
} }
if (type == 1) { if (type == PlotAreaType.AUGMENTED) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Invalid type for multi-area world. Expected `2`, got `" + 1 + "`"); "Invalid type for multi-area world. Expected `PARTIAL`, got `" + PlotAreaType.AUGMENTED + "`");
} }
for (String areaId : areasSection.getKeys(false)) { for (String areaId : areasSection.getKeys(false)) {
PlotSquared.log(Captions.PREFIX + " - " + areaId); PlotSquared.log(Captions.PREFIX + " - " + areaId);
@ -1244,7 +1244,7 @@ import java.util.zip.ZipInputStream;
+ ". Expected form `<name>-<x1;z1>-<x2;z2>`"); + ". Expected form `<name>-<x1;z1>-<x2;z2>`");
} }
PlotArea existing = getPlotArea(world, name); PlotArea existing = getPlotArea(world, name);
if (existing != null && name.equals(existing.id)) { if (existing != null && name.equals(existing.getId())) {
continue; continue;
} }
ConfigurationSection section = areasSection.getConfigurationSection(areaId); ConfigurationSection section = areasSection.getConfigurationSection(areaId);
@ -1919,7 +1919,7 @@ import java.util.zip.ZipInputStream;
public boolean isAugmented(@NonNull final String world) { public boolean isAugmented(@NonNull final String world) {
final PlotArea[] areas = plotAreaManager.getPlotAreas(world, null); final PlotArea[] areas = plotAreaManager.getPlotAreas(world, null);
return areas != null && (areas.length > 1 || areas[0].TYPE != 0); return areas != null && (areas.length > 1 || areas[0].getType() != PlotAreaType.NORMAL);
} }
/** /**
@ -1974,8 +1974,8 @@ import java.util.zip.ZipInputStream;
PlotArea[] areas = plotAreaManager.getPlotAreas(split[0], null); PlotArea[] areas = plotAreaManager.getPlotAreas(split[0], null);
if (areas == null) { if (areas == null) {
for (PlotArea area : plotAreaManager.getAllPlotAreas()) { for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
if (area.worldname.equalsIgnoreCase(split[0])) { if (area.getWorldName().equalsIgnoreCase(split[0])) {
if (area.id == null || split.length == 2 && area.id if (area.getId() == null || split.length == 2 && area.getId()
.equalsIgnoreCase(split[1])) { .equalsIgnoreCase(split[1])) {
return area; return area;
} }
@ -1989,7 +1989,7 @@ import java.util.zip.ZipInputStream;
return null; return null;
} else { } else {
for (PlotArea area : areas) { for (PlotArea area : areas) {
if (StringMan.isEqual(split[1], area.id)) { if (StringMan.isEqual(split[1], area.getId())) {
return area; return area;
} }
} }

View File

@ -64,7 +64,7 @@ public class Add extends Command {
size += plot.getTrusted().contains(uuid) ? 0 : 1; size += plot.getTrusted().contains(uuid) ? 0 : 1;
} }
checkTrue(!uuids.isEmpty(), null); checkTrue(!uuids.isEmpty(), null);
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions checkTrue(size <= plot.getArea().getMaxPlotMembers() || Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
Captions.PLOT_MAX_MEMBERS); Captions.PLOT_MAX_MEMBERS);
// Success // Success

View File

@ -9,6 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils;
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld; import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage; import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -107,24 +109,24 @@ public class Area extends SubCommand {
final int offsetZ = bz - (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); final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz);
Set<PlotArea> areas = Set<PlotArea> areas =
PlotSquared.get().getPlotAreas(area.worldname, region); PlotSquared.get().getPlotAreas(area.getWorldName(), region);
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
Captions.CLUSTER_INTERSECTION Captions.CLUSTER_INTERSECTION
.send(player, areas.iterator().next().toString()); .send(player, areas.iterator().next().toString());
return false; return false;
} }
final SetupObject object = new SetupObject(); final SetupObject object = new SetupObject();
object.world = area.worldname; object.world = area.getWorldName();
object.id = area.id; object.id = area.getId();
object.terrain = area.TERRAIN; object.terrain = area.getTerrain();
object.type = area.TYPE; object.type = area.getType();
object.min = new PlotId(1, 1); object.min = new PlotId(1, 1);
object.max = new PlotId(numX, numZ); object.max = new PlotId(numX, numZ);
object.plotManager = PlotSquared.imp().getPluginName(); object.plotManager = PlotSquared.imp().getPluginName();
object.setupGenerator = PlotSquared.imp().getPluginName(); object.setupGenerator = PlotSquared.imp().getPluginName();
object.step = area.getSettingNodes(); object.step = area.getSettingNodes();
final String path = final String path =
"worlds." + area.worldname + ".areas." + area.id + '-' "worlds." + area.getWorldName() + ".areas." + area.getId() + '-'
+ object.min + '-' + object.max; + object.min + '-' + object.max;
Runnable run = () -> { Runnable run = () -> {
if (offsetX != 0) { if (offsetX != 0) {
@ -141,7 +143,7 @@ public class Area extends SubCommand {
Captions.SETUP_FINISHED.send(player); Captions.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world), player.teleport(WorldUtil.IMP.getSpawn(world),
TeleportCause.COMMAND); TeleportCause.COMMAND);
if (area.TERRAIN != 3) { if (area.getTerrain() != PlotAreaTerrainType.ALL) {
ChunkManager.largeRegionTask(world, region, ChunkManager.largeRegionTask(world, region,
new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
@ -153,7 +155,7 @@ public class Area extends SubCommand {
} else { } else {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"An error occurred while creating the world: " "An error occurred while creating the world: "
+ area.worldname); + area.getWorldName());
} }
}; };
if (hasConfirmation(player)) { if (hasConfirmation(player)) {
@ -176,15 +178,15 @@ public class Area extends SubCommand {
object.world = split[0]; object.world = split[0];
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, final HybridPlotWorld pa = new HybridPlotWorld(object.world, id,
PlotSquared.get().IMP.getDefaultGenerator(), null, null); PlotSquared.get().IMP.getDefaultGenerator(), null, null);
PlotArea other = PlotSquared.get().getPlotArea(pa.worldname, id); PlotArea other = PlotSquared.get().getPlotArea(pa.getWorldName(), id);
if (other != null && Objects.equals(pa.id, other.id)) { if (other != null && Objects.equals(pa.getId(), other.getId())) {
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString()); Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
return false; return false;
} }
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(pa.worldname); Set<PlotArea> areas = PlotSquared.get().getPlotAreas(pa.getWorldName());
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
PlotArea area = areas.iterator().next(); PlotArea area = areas.iterator().next();
pa.TYPE = area.TYPE; pa.setType(area.getType());
} }
pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH); pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH);
for (int i = 2; i < args.length; i++) { for (int i = 2; i < args.length; i++) {
@ -230,12 +232,12 @@ public class Area extends SubCommand {
pa.WALL_BLOCK = Configuration.BLOCK_BUCKET.parseString(pair[1]); pa.WALL_BLOCK = Configuration.BLOCK_BUCKET.parseString(pair[1]);
break; break;
case "terrain": case "terrain":
pa.TERRAIN = Integer.parseInt(pair[1]); pa.setTerrain(PlotAreaTerrainType.fromString(pair[1]).orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid terrain.")));
object.terrain = pa.TERRAIN; object.terrain = pa.getTerrain();
break; break;
case "type": case "type":
pa.TYPE = Integer.parseInt(pair[1]); pa.setType(PlotAreaType.fromString(pair[1]).orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid type.")));
object.type = pa.TYPE; object.type = pa.getType();
break; break;
default: default:
Captions.COMMAND_SYNTAX.send(player, getCommandString() Captions.COMMAND_SYNTAX.send(player, getCommandString()
@ -243,13 +245,13 @@ public class Area extends SubCommand {
return false; return false;
} }
} }
if (pa.TYPE != 2) { if (pa.getType() != PlotAreaType.PARTIAL) {
if (WorldUtil.IMP.isWorld(pa.worldname)) { if (WorldUtil.IMP.isWorld(pa.getWorldName())) {
Captions.SETUP_WORLD_TAKEN.send(player, pa.worldname); Captions.SETUP_WORLD_TAKEN.send(player, pa.getWorldName());
return false; return false;
} }
Runnable run = () -> { Runnable run = () -> {
String path = "worlds." + pa.worldname; String path = "worlds." + pa.getWorldName();
if (!PlotSquared.get().worlds.contains(path)) { if (!PlotSquared.get().worlds.contains(path)) {
PlotSquared.get().worlds.createSection(path); PlotSquared.get().worlds.createSection(path);
} }
@ -267,7 +269,7 @@ public class Area extends SubCommand {
} else { } else {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"An error occurred while creating the world: " "An error occurred while creating the world: "
+ pa.worldname); + pa.getWorldName());
} }
try { try {
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile); PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
@ -283,21 +285,21 @@ public class Area extends SubCommand {
} }
return true; return true;
} }
if (pa.id == null) { if (pa.getId() == null) {
Captions.COMMAND_SYNTAX.send(player, getCommandString() Captions.COMMAND_SYNTAX.send(player, getCommandString()
+ " create [world[:id]] [<modifier>=<value>]..."); + " create [world[:id]] [<modifier>=<value>]...");
return false; return false;
} }
if (WorldUtil.IMP.isWorld(pa.worldname)) { if (WorldUtil.IMP.isWorld(pa.getWorldName())) {
if (!player.getLocation().getWorld().equals(pa.worldname)) { if (!player.getLocation().getWorld().equals(pa.getWorldName())) {
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname), player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND); TeleportCause.COMMAND);
} }
} else { } else {
object.terrain = 0; object.terrain = PlotAreaTerrainType.NONE;
object.type = 0; object.type = PlotAreaType.NORMAL;
SetupUtils.manager.setupWorld(object); SetupUtils.manager.setupWorld(object);
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname), player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND); TeleportCause.COMMAND);
} }
player.setMeta("area_create_area", pa); player.setMeta("area_create_area", pa);
@ -339,20 +341,20 @@ public class Area extends SubCommand {
int clusters = area.getClusters().size(); int clusters = area.getClusters().size();
String region; String region;
String generator = String.valueOf(area.getGenerator()); String generator = String.valueOf(area.getGenerator());
if (area.TYPE == 2) { if (area.getType() == PlotAreaType.PARTIAL) {
PlotId min = area.getMin(); PlotId min = area.getMin();
PlotId max = area.getMax(); PlotId max = area.getMax();
name = area.worldname + ';' + area.id + ';' + min + ';' + max; name = area.getWorldName() + ';' + area.getId() + ';' + min + ';' + max;
int size = (max.x - min.x + 1) * (max.y - min.y + 1); int size = (max.x - min.x + 1) * (max.y - min.y + 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 {
name = area.worldname; name = area.getWorldName();
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE; percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
region = "N/A"; region = "N/A";
} }
String value = "&r$1NAME: " + name + "\n$1Type: $2" + area.TYPE + "\n$1Terrain: $2" String value = "&r$1NAME: " + name + "\n$1Type: $2" + area.getType() + "\n$1Terrain: $2"
+ area.TERRAIN + "\n$1Usage: $2" + String.format("%.2f", percent) + '%' + area.getTerrain() + "\n$1Usage: $2" + String.format("%.2f", percent) + '%'
+ "\n$1Claimed: $2" + claimed + "\n$1Clusters: $2" + clusters + "\n$1Region: $2" + "\n$1Claimed: $2" + claimed + "\n$1Clusters: $2" + clusters + "\n$1Region: $2"
+ region + "\n$1Generator: $2" + generator; + region + "\n$1Generator: $2" + generator;
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
@ -390,15 +392,15 @@ public class Area extends SubCommand {
int clusters = area.getClusters().size(); int clusters = area.getClusters().size();
String region; String region;
String generator = String.valueOf(area.getGenerator()); String generator = String.valueOf(area.getGenerator());
if (area.TYPE == 2) { if (area.getType() == PlotAreaType.PARTIAL) {
PlotId min = area.getMin(); PlotId min = area.getMin();
PlotId max = area.getMax(); PlotId max = area.getMax();
name = area.worldname + ';' + area.id + ';' + min + ';' + max; name = area.getWorldName() + ';' + area.getId() + ';' + min + ';' + max;
int size = (max.x - min.x + 1) * (max.y - min.y + 1); int size = (max.x - min.x + 1) * (max.y - min.y + 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 {
name = area.worldname; name = area.getWorldName();
percent = claimed == 0 ? percent = claimed == 0 ?
0 : 0 :
Short.MAX_VALUE * Short.MAX_VALUE / (double) claimed; Short.MAX_VALUE * Short.MAX_VALUE / (double) claimed;
@ -417,7 +419,7 @@ public class Area extends SubCommand {
.tooltip(visit).color("$1").text("]").color("$3").text(' ' + name) .tooltip(visit).color("$1").text("]").color("$3").text(' ' + name)
.tooltip(tooltip).command(getCommandString() + " info " + area) .tooltip(tooltip).command(getCommandString() + " info " + area)
.color("$1").text(" - ").color("$2") .color("$1").text(" - ").color("$2")
.text(area.TYPE + ":" + area.TERRAIN).color("$3"); .text(area.getType() + ":" + area.getTerrain()).color("$3");
} }
}, "/plot area list", Captions.AREA_LIST_HEADER_PAGED.getTranslated()); }, "/plot area list", Captions.AREA_LIST_HEADER_PAGED.getTranslated());
return true; return true;
@ -434,16 +436,16 @@ public class Area extends SubCommand {
Captions.NOT_IN_PLOT_WORLD.send(player); Captions.NOT_IN_PLOT_WORLD.send(player);
return false; return false;
} }
if (area.TYPE != 2) { if (area.getType() != PlotAreaType.PARTIAL) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"$4Stop the server and delete: " + area.worldname + "/region"); "$4Stop the server and delete: " + area.getWorldName() + "/region");
return false; return false;
} }
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), ChunkManager.largeRegionTask(area.getWorldName(), area.getRegion(),
new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
AugmentedUtils AugmentedUtils
.generate(area.worldname, value.getX(), value.getZ(), null); .generate(area.getWorldName(), value.getX(), value.getZ(), null);
} }
}, () -> player.sendMessage("Regen complete")); }, () -> player.sendMessage("Regen complete"));
return true; return true;
@ -467,16 +469,16 @@ public class Area extends SubCommand {
return false; return false;
} }
Location center; Location center;
if (area.TYPE != 2) { if (area.getType() != PlotAreaType.PARTIAL) {
center = WorldUtil.IMP.getSpawn(area.worldname); center = WorldUtil.IMP.getSpawn(area.getWorldName());
} else { } else {
CuboidRegion region = area.getRegion(); CuboidRegion region = area.getRegion();
center = new Location(area.worldname, region.getMinimumPoint().getX() center = new Location(area.getWorldName(), region.getMinimumPoint().getX()
+ (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.getMinimumPoint().getZ() 0, region.getMinimumPoint().getZ()
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2); + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
center.setY(1 + WorldUtil.IMP center.setY(1 + WorldUtil.IMP
.getHighestBlock(area.worldname, center.getX(), center.getZ())); .getHighestBlock(area.getWorldName(), center.getX(), center.getZ()));
} }
player.teleport(center, TeleportCause.COMMAND); player.teleport(center, TeleportCause.COMMAND);
return true; return true;

View File

@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Direction;
import com.github.intellectualsites.plotsquared.plot.object.Expression; import com.github.intellectualsites.plotsquared.plot.object.Expression;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@ -50,7 +51,7 @@ public class Auto extends SubCommand {
if (Settings.Limit.GLOBAL) { if (Settings.Limit.GLOBAL) {
currentPlots = player.getPlotCount(); currentPlots = player.getPlotCount();
} else { } else {
currentPlots = player.getPlotCount(plotarea.worldname); currentPlots = player.getPlotCount(plotarea.getWorldName());
} }
int diff = currentPlots - allowedPlots; int diff = currentPlots - allowedPlots;
if (diff + sizeX * sizeZ > 0) { if (diff + sizeX * sizeZ > 0) {
@ -135,7 +136,7 @@ public class Auto extends SubCommand {
if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) { if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) {
plot.claim(player, true, schematic, false); plot.claim(player, true, schematic, false);
if (area.AUTO_MERGE) { if (area.isAutoMerge()) {
PlotMergeEvent event = PlotSquared.get().getEventDispatcher() PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); .callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
@ -173,7 +174,7 @@ public class Auto extends SubCommand {
if (EconHandler.manager != null) { if (EconHandler.manager != null) {
for (PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) { for (PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
if (EconHandler.manager if (EconHandler.manager
.hasPermission(area.worldname, player.getName(), "plots.auto")) { .hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
if (plotarea != null) { if (plotarea != null) {
plotarea = null; plotarea = null;
break; break;
@ -249,7 +250,7 @@ public class Auto extends SubCommand {
} }
if (schematic != null && !schematic.isEmpty()) { if (schematic != null && !schematic.isEmpty()) {
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) { if (!plotarea.hasSchematic(schematic)) {
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic); sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true; return true;
} }
@ -263,11 +264,11 @@ public class Auto extends SubCommand {
return true; return true;
} }
} }
if (EconHandler.manager != null && plotarea.USE_ECONOMY) { if (EconHandler.manager != null && plotarea.useEconomy()) {
Expression<Double> costExp = plotarea.PRICES.get("claim"); Expression<Double> costExp = plotarea.getPrices().get("claim");
double cost = costExp.evaluate((double) (Settings.Limit.GLOBAL ? double cost = costExp.evaluate((double) (Settings.Limit.GLOBAL ?
player.getPlotCount() : player.getPlotCount() :
player.getPlotCount(plotarea.worldname))); player.getPlotCount(plotarea.getWorldName())));
cost = (size_x * size_z) * cost; cost = (size_x * size_z) * cost;
if (cost > 0d) { if (cost > 0d) {
if (!force && EconHandler.manager.getMoney(player) < cost) { if (!force && EconHandler.manager.getMoney(player) < cost) {
@ -278,12 +279,12 @@ public class Auto extends SubCommand {
sendMessage(player, Captions.REMOVED_BALANCE, cost + ""); sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
} }
} }
// TODO handle type 2 the same as normal worlds! // TODO handle type 2 (partial) the same as normal worlds!
if (size_x == 1 && size_z == 1) { if (size_x == 1 && size_z == 1) {
autoClaimSafe(player, plotarea, null, schematic, allowed_plots); autoClaimSafe(player, plotarea, null, schematic, allowed_plots);
return true; return true;
} else { } else {
if (plotarea.TYPE == 2) { if (plotarea.getType() == PlotAreaType.PARTIAL) {
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS); MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
return false; return false;
} }

View File

@ -61,8 +61,8 @@ public class Claim extends SubCommand {
} }
final PlotArea area = plot.getArea(); final PlotArea area = plot.getArea();
if (schematic != null && !schematic.isEmpty()) { if (schematic != null && !schematic.isEmpty()) {
if (area.SCHEMATIC_CLAIM_SPECIFY) { if (area.isSchematicClaimSpecify()) {
if (!area.SCHEMATICS.contains(schematic.toLowerCase())) { if (!area.hasSchematic(schematic)) {
return sendMessage(player, Captions.SCHEMATIC_INVALID, return sendMessage(player, Captions.SCHEMATIC_INVALID,
"non-existent: " + schematic); "non-existent: " + schematic);
} }
@ -74,8 +74,8 @@ public class Claim extends SubCommand {
} }
} }
} }
if ((EconHandler.manager != null) && area.USE_ECONOMY && !force) { if ((EconHandler.manager != null) && area.useEconomy() && !force) {
Expression<Double> costExr = area.PRICES.get("claim"); Expression<Double> costExr = area.getPrices().get("claim");
double cost = costExr.evaluate((double) currentPlots); double cost = costExr.evaluate((double) currentPlots);
if (cost > 0d) { if (cost > 0d) {
if (EconHandler.manager.getMoney(player) < cost) { if (EconHandler.manager.getMoney(player) < cost) {
@ -102,7 +102,7 @@ public class Claim extends SubCommand {
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() { DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override public void run(Object value) { @Override public void run(Object value) {
plot.claim(player, true, finalSchematic); plot.claim(player, true, finalSchematic);
if (area.AUTO_MERGE) { if (area.isAutoMerge()) {
PlotMergeEvent event = PlotSquared.get().getEventDispatcher() PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); .callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {

View File

@ -36,7 +36,7 @@ public class Condense extends SubCommand {
return false; return false;
} }
PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]); PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) { if (area == null || !WorldUtil.IMP.isWorld(area.getWorldName())) {
MainUtil.sendMessage(player, "INVALID AREA"); MainUtil.sendMessage(player, "INVALID AREA");
return false; return false;
} }
@ -204,7 +204,7 @@ public class Condense extends SubCommand {
return true; return true;
} }
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"/plot condense " + area.worldname + " <start|stop|info> [radius]"); "/plot condense " + area.getWorldName() + " <start|stop|info> [radius]");
return false; return false;
} }

View File

@ -38,7 +38,7 @@ public class DebugClaimTest extends SubCommand {
+ "plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}"); + "plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
} }
PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]); PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) { if (area == null || !WorldUtil.IMP.isWorld(area.getWorldName())) {
Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]); Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]);
return false; return false;
} }
@ -70,7 +70,7 @@ public class DebugClaimTest extends SubCommand {
} }
Location location = manager.getSignLoc(plot); Location location = manager.getSignLoc(plot);
BlockVector2 chunk = BlockVector2.at(location.getX() >> 4, location.getZ() >> 4); BlockVector2 chunk = BlockVector2.at(location.getX() >> 4, location.getZ() >> 4);
ChunkManager.manager.loadChunk(area.worldname, chunk, false).thenRun(() -> { ChunkManager.manager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
String[] lines = WorldUtil.IMP.getSign(location); String[] lines = WorldUtil.IMP.getSign(location);
if (lines != null) { if (lines != null) {
String line = lines[2]; String line = lines[2];

View File

@ -63,8 +63,8 @@ public class Delete extends SubCommand {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
boolean result = plot.deletePlot(() -> { boolean result = plot.deletePlot(() -> {
plot.removeRunning(); plot.removeRunning();
if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) { if ((EconHandler.manager != null) && plotArea.useEconomy()) {
Expression<Double> valueExr = plotArea.PRICES.get("sell"); Expression<Double> valueExr = plotArea.getPrices().get("sell");
double value = plots.size() * valueExr.evaluate((double) currentPlots); double value = plots.size() * valueExr.evaluate((double) currentPlots);
if (value > 0d) { if (value > 0d) {
EconHandler.manager.depositMoney(player, value); EconHandler.manager.depositMoney(player, value);

View File

@ -88,7 +88,7 @@ public class Load extends SubCommand {
} }
PlotArea area = plot.getArea(); PlotArea area = plot.getArea();
SchematicHandler.manager SchematicHandler.manager
.paste(taskSchematic, plot, 0, area.MIN_BUILD_HEIGHT, 0, false, .paste(taskSchematic, plot, 0, area.getMinBuildHeight(), 0, false,
new RunnableVal<Boolean>() { new RunnableVal<Boolean>() {
@Override public void run(Boolean value) { @Override public void run(Boolean value) {
plot.removeRunning(); plot.removeRunning();

View File

@ -144,7 +144,7 @@ public class MainCommand extends Command {
if (EconHandler.manager != null) { if (EconHandler.manager != null) {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null) { if (area != null) {
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId()); Expression<Double> priceEval = area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != null if (price != null
&& EconHandler.manager.getMoney(player) < price) { && EconHandler.manager.getMoney(player) < price) {
@ -164,7 +164,7 @@ public class MainCommand extends Command {
if (EconHandler.manager != null) { if (EconHandler.manager != null) {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null) { if (area != null) {
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId()); Expression<Double> priceEval = area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d && EconHandler.manager.getMoney(player) < price) { if (price != 0d && EconHandler.manager.getMoney(player) < price) {
if (failure != null) { if (failure != null) {
@ -230,7 +230,7 @@ public class MainCommand extends Command {
if (EconHandler.manager != null) { if (EconHandler.manager != null) {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null) { if (area != null) {
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId()); Expression<Double> priceEval = area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d if (price != 0d
&& EconHandler.manager.getMoney(player) < price) { && EconHandler.manager.getMoney(player) < price) {

View File

@ -116,7 +116,7 @@ public class Merge extends SubCommand {
return false; return false;
} }
final PlotArea plotArea = plot.getArea(); final PlotArea plotArea = plot.getArea();
Expression<Double> priceExr = plotArea.PRICES.getOrDefault("merge", null); Expression<Double> priceExr = plotArea.getPrices().getOrDefault("merge", null);
final double price = priceExr == null ? 0d : priceExr.evaluate((double) size); final double price = priceExr == null ? 0d : priceExr.evaluate((double) size);
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
@ -132,7 +132,7 @@ public class Merge extends SubCommand {
return true; return true;
} }
if (plot.autoMerge(Direction.ALL, maxSize, uuid, terrain)) { if (plot.autoMerge(Direction.ALL, maxSize, uuid, terrain)) {
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) { if (EconHandler.manager != null && plotArea.useEconomy() && price > 0d) {
EconHandler.manager.withdrawMoney(player, price); EconHandler.manager.withdrawMoney(player, price);
sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price)); sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price));
} }
@ -150,7 +150,7 @@ public class Merge extends SubCommand {
uuid = plot.guessOwner(); uuid = plot.guessOwner();
} }
} }
if (!force && EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d if (!force && EconHandler.manager != null && plotArea.useEconomy() && price > 0d
&& EconHandler.manager.getMoney(player) < price) { && EconHandler.manager.getMoney(player) < price) {
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price)); sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
return false; return false;
@ -167,7 +167,7 @@ public class Merge extends SubCommand {
return true; return true;
} }
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) { if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) { if (EconHandler.manager != null && plotArea.useEconomy() && price > 0d) {
EconHandler.manager.withdrawMoney(player, price); EconHandler.manager.withdrawMoney(player, price);
sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price)); sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price));
} }
@ -201,7 +201,7 @@ public class Merge extends SubCommand {
sendMessage(accepter, Captions.MERGE_NOT_VALID); sendMessage(accepter, Captions.MERGE_NOT_VALID);
return; return;
} }
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) { if (EconHandler.manager != null && plotArea.useEconomy() && price > 0d) {
if (!force && EconHandler.manager.getMoney(player) < price) { if (!force && EconHandler.manager.getMoney(player) < price) {
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price)); sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
return; return;

View File

@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.configuration.MemorySection;
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration; import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -28,16 +29,16 @@ public class Reload extends SubCommand {
Captions.load(PlotSquared.get().translationFile); Captions.load(PlotSquared.get().translationFile);
PlotSquared.get().forEachPlotArea(area -> { PlotSquared.get().forEachPlotArea(area -> {
ConfigurationSection worldSection = ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection("worlds." + area.worldname); PlotSquared.get().worlds.getConfigurationSection("worlds." + area.getWorldName());
if (worldSection == null) { if (worldSection == null) {
return; return;
} }
if (area.TYPE != 2 || !worldSection.contains("areas")) { if (area.getType() != PlotAreaType.PARTIAL || !worldSection.contains("areas")) {
area.saveConfiguration(worldSection); area.saveConfiguration(worldSection);
area.loadDefaultConfiguration(worldSection); area.loadDefaultConfiguration(worldSection);
} else { } else {
ConfigurationSection areaSection = worldSection.getConfigurationSection( ConfigurationSection areaSection = worldSection.getConfigurationSection(
"areas." + area.id + "-" + area.getMin() + "-" + area.getMax()); "areas." + area.getId() + "-" + area.getMin() + "-" + area.getMax());
YamlConfiguration clone = new YamlConfiguration(); YamlConfiguration clone = new YamlConfiguration();
for (String key : areaSection.getKeys(true)) { for (String key : areaSection.getKeys(true)) {
if (areaSection.get(key) instanceof MemorySection) { if (areaSection.get(key) instanceof MemorySection) {

View File

@ -7,6 +7,8 @@ import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper; import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage; import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -32,6 +34,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "setup", @CommandDeclaration(command = "setup",
@ -114,21 +117,22 @@ public class Setup extends SubCommand {
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial); + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
break; break;
case 1: // choose world type case 1: // choose world type
List<String> allTypes = Arrays.asList("default", "augmented", "partial"); List<String> allTypes = Arrays.asList("normal", "augmented", "partial");
List<String> allDesc = Arrays List<String> allDesc = Arrays
.asList("Standard plot generation", "Plot generation with vanilla terrain", .asList("Standard plot generation", "Plot generation with vanilla terrain",
"Vanilla with clusters of plots"); "Vanilla with clusters of plots");
ArrayList<String> types = new ArrayList<>(); ArrayList<String> types = new ArrayList<>();
if (SetupUtils.generators.get(object.setupGenerator).isFull()) { if (SetupUtils.generators.get(object.setupGenerator).isFull()) {
types.add("default"); types.add("normal");
} }
types.add("augmented"); types.add("augmented");
types.add("partial"); types.add("partial");
if (args.length != 1 || !types.contains(args[0].toLowerCase())) { Optional<PlotAreaType> plotAreaType;
if (args.length != 1 || !(plotAreaType = PlotAreaType.fromString(args[0])).isPresent()) {
MainUtil.sendMessage(player, "&cYou must choose a world type!"); MainUtil.sendMessage(player, "&cYou must choose a world type!");
for (String type : types) { for (String type : types) {
int i = allTypes.indexOf(type); int i = allTypes.indexOf(type);
if (type.equals("default")) { if (type.equals("normal")) {
MainUtil MainUtil
.sendMessage(player, "&8 - &2" + type + " &8-&7 " + allDesc.get(i)); .sendMessage(player, "&8 - &2" + type + " &8-&7 " + allDesc.get(i));
} else { } else {
@ -138,9 +142,9 @@ public class Setup extends SubCommand {
} }
return false; return false;
} }
object.type = allTypes.indexOf(args[0].toLowerCase()); object.type = plotAreaType.orElse(PlotAreaType.NORMAL);
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator); GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
if (object.type == 0) { if (object.type == PlotAreaType.NORMAL) {
object.current = 6; object.current = 6;
if (object.step == null) { if (object.step == null) {
object.plotManager = object.setupGenerator; object.plotManager = object.setupGenerator;
@ -181,7 +185,7 @@ public class Setup extends SubCommand {
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null) .getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null)
.getSettingNodes(); .getSettingNodes();
} }
if (object.type == 2) { if (object.type == PlotAreaType.PARTIAL) {
MainUtil.sendMessage(player, "What would you like this area called?"); MainUtil.sendMessage(player, "What would you like this area called?");
object.current++; object.current++;
} else { } else {
@ -200,7 +204,7 @@ public class Setup extends SubCommand {
return false; return false;
} }
for (PlotArea area : PlotSquared.get().getPlotAreas()) { for (PlotArea area : PlotSquared.get().getPlotAreas()) {
if (area.id != null && area.id.equalsIgnoreCase(args[0])) { if (area.getId() != null && area.getId().equalsIgnoreCase(args[0])) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&cYou must choose an area id that is not in use!"); "&cYou must choose an area id that is not in use!");
return false; return false;
@ -243,8 +247,8 @@ public class Setup extends SubCommand {
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
break; break;
case 5: { // Choose terrain case 5: { // Choose terrain
List<String> terrain = Arrays.asList("none", "ore", "road", "all"); Optional<PlotAreaTerrainType> optTerrain;
if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) { if (args.length != 1 || !(optTerrain = PlotAreaTerrainType.fromString(args[0])).isPresent()) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all"
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
@ -252,7 +256,7 @@ public class Setup extends SubCommand {
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
return false; return false;
} }
object.terrain = terrain.indexOf(args[0].toLowerCase()); object.terrain = optTerrain.get();
object.current++; object.current++;
if (object.step == null) { if (object.step == null) {
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator() object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()

View File

@ -10,11 +10,14 @@ import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.FileBytes; import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject; import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause; import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
@ -81,7 +84,7 @@ public class Template extends SubCommand {
public static byte[] getBytes(PlotArea plotArea) { public static byte[] getBytes(PlotArea plotArea) {
ConfigurationSection section = ConfigurationSection section =
PlotSquared.get().worlds.getConfigurationSection("worlds." + plotArea.worldname); PlotSquared.get().worlds.getConfigurationSection("worlds." + plotArea.getWorldName());
YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
String generator = SetupUtils.manager.getGenerator(plotArea); String generator = SetupUtils.manager.getGenerator(plotArea);
if (generator != null) { if (generator != null) {
@ -157,14 +160,12 @@ public class Template extends SubCommand {
String manager = String manager =
worldConfig.getString("generator.plugin", PlotSquared.imp().getPluginName()); worldConfig.getString("generator.plugin", PlotSquared.imp().getPluginName());
String generator = worldConfig.getString("generator.init", manager); String generator = worldConfig.getString("generator.init", manager);
int type = worldConfig.getInt("generator.type");
int terrain = worldConfig.getInt("generator.terrain");
SetupObject setup = new SetupObject(); SetupObject setup = new SetupObject();
setup.type = MainUtil.getType(worldConfig);
setup.terrain = MainUtil.getTerrain(worldConfig);
setup.plotManager = manager; setup.plotManager = manager;
setup.setupGenerator = generator; setup.setupGenerator = generator;
setup.type = type;
setup.terrain = terrain;
setup.step = new ConfigurationNode[0]; setup.step = new ConfigurationNode[0];
setup.world = world; setup.world = world;
SetupUtils.manager.setupWorld(setup); SetupUtils.manager.setupWorld(setup);

View File

@ -67,7 +67,7 @@ public class Trust extends Command {
size += currentPlot.getMembers().contains(uuid) ? 0 : 1; size += currentPlot.getMembers().contains(uuid) ? 0 : 1;
} }
checkTrue(!uuids.isEmpty(), null); checkTrue(!uuids.isEmpty(), null);
checkTrue(size <= currentPlot.getArea().MAX_PLOT_MEMBERS || Permissions checkTrue(size <= currentPlot.getArea().getMaxPlotMembers() || Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
Captions.PLOT_MAX_MEMBERS); Captions.PLOT_MAX_MEMBERS);
// Success // Success

View File

@ -3,6 +3,8 @@ package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
@ -42,10 +44,10 @@ public class AugmentedUtils {
} }
boolean toReturn = false; boolean toReturn = false;
for (final PlotArea area : areas) { for (final PlotArea area : areas) {
if (area.TYPE == 0) { if (area.getType() == PlotAreaType.NORMAL) {
return false; return false;
} }
if (area.TERRAIN == 3) { if (area.getTerrain() == PlotAreaTerrainType.ALL) {
continue; continue;
} }
IndependentPlotGenerator generator = area.getGenerator(); IndependentPlotGenerator generator = area.getGenerator();
@ -60,7 +62,7 @@ public class AugmentedUtils {
int txx; int txx;
int tzz; int tzz;
// gen // gen
if (area.TYPE == 2) { if (area.getType() == PlotAreaType.PARTIAL) {
bxx = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX); bxx = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX);
bzz = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ); bzz = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ);
txx = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX); txx = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
@ -87,7 +89,7 @@ public class AugmentedUtils {
} }
LocalBlockQueue secondaryMask; LocalBlockQueue secondaryMask;
BlockState air = BlockTypes.AIR.getDefaultState(); BlockState air = BlockTypes.AIR.getDefaultState();
if (area.TERRAIN == 2) { if (area.getTerrain() == PlotAreaTerrainType.ROAD) {
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
final boolean[][] canPlace = new boolean[16][16]; final boolean[][] canPlace = new boolean[16][16];
boolean has = false; boolean has = false;
@ -133,8 +135,8 @@ public class AugmentedUtils {
toReturn = true; toReturn = true;
} }
ScopedLocalBlockQueue scoped = new ScopedLocalBlockQueue(secondaryMask, ScopedLocalBlockQueue scoped = new ScopedLocalBlockQueue(secondaryMask,
new Location(area.worldname, blockX, 0, blockZ), new Location(area.getWorldName(), blockX, 0, blockZ),
new Location(area.worldname, blockX + 15, 255, blockZ + 15)); new Location(area.getWorldName(), blockX + 15, 255, blockZ + 15));
generator.generateChunk(scoped, area); generator.generateChunk(scoped, area);
generator.populateChunk(scoped, area); generator.populateChunk(scoped, area);
} }

View File

@ -65,10 +65,10 @@ public class ClassicPlotManager extends SquarePlotManager {
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (CuboidRegion region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
classicPlotWorld.PLOT_HEIGHT, region.getMinimumPoint().getZ()); classicPlotWorld.PLOT_HEIGHT, region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
classicPlotWorld.PLOT_HEIGHT, region.getMaximumPoint().getZ()); classicPlotWorld.PLOT_HEIGHT, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
@ -85,10 +85,10 @@ public class ClassicPlotManager extends SquarePlotManager {
int maxY = getWorldHeight(); int maxY = getWorldHeight();
for (CuboidRegion region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), 1, new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(), 1,
region.getMinimumPoint().getZ()); region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(), maxY,
region.getMaximumPoint().getZ()); region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
@ -104,10 +104,10 @@ public class ClassicPlotManager extends SquarePlotManager {
int maxY = getWorldHeight(); int maxY = getWorldHeight();
for (CuboidRegion region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
classicPlotWorld.PLOT_HEIGHT + 1, region.getMinimumPoint().getZ()); classicPlotWorld.PLOT_HEIGHT + 1, region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(), maxY,
region.getMaximumPoint().getZ()); region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
@ -122,10 +122,10 @@ public class ClassicPlotManager extends SquarePlotManager {
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
for (CuboidRegion region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), 1, new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(), 1,
region.getMinimumPoint().getZ()); region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
classicPlotWorld.PLOT_HEIGHT - 1, region.getMaximumPoint().getZ()); classicPlotWorld.PLOT_HEIGHT - 1, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
@ -191,10 +191,10 @@ public class ClassicPlotManager extends SquarePlotManager {
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (CuboidRegion region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), maxY, new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(), maxY,
region.getMinimumPoint().getZ()); region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(), maxY,
region.getMaximumPoint().getZ()); region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
@ -301,29 +301,29 @@ public class ClassicPlotManager extends SquarePlotManager {
int ez = pos2.getZ() + 2; int ez = pos2.getZ() + 2;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
int maxY = getWorldHeight(); int maxY = getWorldHeight();
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz + 1), Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz + 1),
new Location(classicPlotWorld.worldname, ex, maxY, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, maxY, ez - 1),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 0, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 0, sz + 1),
new Location(classicPlotWorld.worldname, ex, 0, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, 0, ez - 1),
BlockUtil.get((short) 7, (byte) 0)); BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, ez - 1),
classicPlotWorld.WALL_BLOCK.toPattern()); classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.worldname, ex, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), ex, 1, sz + 1),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, sz + 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1),
classicPlotWorld.WALL_BLOCK.toPattern()); classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1),
classicPlotWorld.ROAD_BLOCK.toPattern()); classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -336,30 +336,30 @@ public class ClassicPlotManager extends SquarePlotManager {
int sx = pos1.getX() - 2; int sx = pos1.getX() - 2;
int ex = pos2.getX() + 2; int ex = pos2.getX() + 2;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
new Location(classicPlotWorld.worldname, ex - 1, new Location(classicPlotWorld.getWorldName(), ex - 1,
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 0, sz),
new Location(classicPlotWorld.worldname, ex - 1, 0, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, 0, ez),
BlockUtil.get((short) 7, (byte) 0)); BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, sz), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz), new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, sz), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, sz),
classicPlotWorld.WALL_BLOCK.toPattern()); classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, ez), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, ez),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, ez), new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, ez),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez),
classicPlotWorld.WALL_BLOCK.toPattern()); classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1),
classicPlotWorld.ROAD_BLOCK.toPattern()); classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -372,15 +372,15 @@ public class ClassicPlotManager extends SquarePlotManager {
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1; int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.ROAD_HEIGHT + 1, new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1,
sz + 1), new Location(classicPlotWorld.worldname, ex - 1, sz + 1), new Location(classicPlotWorld.getWorldName(), ex - 1,
classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1), classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 0, sz + 1),
new Location(classicPlotWorld.worldname, ex - 1, 0, ez - 1), new Location(classicPlotWorld.getWorldName(), ex - 1, 0, ez - 1),
BlockUtil.get((short) 7, (byte) 0)); BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1),
classicPlotWorld.ROAD_BLOCK.toPattern()); classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -393,17 +393,17 @@ public class ClassicPlotManager extends SquarePlotManager {
int sz = pos1.getZ() - 1; int sz = pos1.getZ() - 1;
int ez = pos2.getZ() + 1; int ez = pos2.getZ() + 1;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx,
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
new Location(classicPlotWorld.worldname, ex, new Location(classicPlotWorld.getWorldName(), ex,
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1),
classicPlotWorld.MAIN_BLOCK.toPattern()); classicPlotWorld.MAIN_BLOCK.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez - 1),
classicPlotWorld.TOP_BLOCK.toPattern()); classicPlotWorld.TOP_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -416,17 +416,17 @@ public class ClassicPlotManager extends SquarePlotManager {
int sx = pos1.getX() - 1; int sx = pos1.getX() - 1;
int ex = pos2.getX() + 1; int ex = pos2.getX() + 1;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx,
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
new Location(classicPlotWorld.worldname, ex, new Location(classicPlotWorld.getWorldName(), ex,
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez),
classicPlotWorld.MAIN_BLOCK.toPattern()); classicPlotWorld.MAIN_BLOCK.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz), new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT, ez),
classicPlotWorld.TOP_BLOCK.toPattern()); classicPlotWorld.TOP_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -439,16 +439,16 @@ public class ClassicPlotManager extends SquarePlotManager {
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1; int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT + 1, sz), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.ROAD_HEIGHT + 1, sz),
new Location(classicPlotWorld.worldname, ex, new Location(classicPlotWorld.getWorldName(), ex,
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.ROAD_HEIGHT - 1, ez),
classicPlotWorld.MAIN_BLOCK.toPattern()); classicPlotWorld.MAIN_BLOCK.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.ROAD_HEIGHT, sz),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT, ez), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.ROAD_HEIGHT, ez),
classicPlotWorld.TOP_BLOCK.toPattern()); classicPlotWorld.TOP_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -513,7 +513,7 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override public Location getSignLoc(Plot plot) { @Override public Location getSignLoc(Plot plot) {
plot = plot.getBasePlot(false); plot = plot.getBasePlot(false);
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
return new Location(classicPlotWorld.worldname, bot.getX() - 1, return new Location(classicPlotWorld.getWorldName(), bot.getX() - 1,
classicPlotWorld.ROAD_HEIGHT + 1, bot.getZ() - 2); classicPlotWorld.ROAD_HEIGHT + 1, bot.getZ() - 2);
} }
} }

View File

@ -92,7 +92,7 @@ import java.util.Locale;
// Dump world settings // Dump world settings
if (Settings.DEBUG) { if (Settings.DEBUG) {
PlotSquared.debug(String PlotSquared.debug(String
.format("- Dumping settings for ClassicPlotWorld with name %s", this.worldname)); .format("- Dumping settings for ClassicPlotWorld with name %s", this.getWorldName()));
final Field[] fields = this.getClass().getFields(); final Field[] fields = this.getClass().getFields();
for (final Field field : fields) { for (final Field field : fields) {
final String name = field.getName().toLowerCase(Locale.ENGLISH); final String name = field.getName().toLowerCase(Locale.ENGLISH);

View File

@ -47,7 +47,7 @@ public class HybridGen extends IndependentPlotGenerator {
HybridPlotWorld hpw = (HybridPlotWorld) settings; HybridPlotWorld hpw = (HybridPlotWorld) settings;
// Biome // Biome
result.fillBiome(hpw.PLOT_BIOME); result.fillBiome(hpw.getPlotBiome());
// Bedrock // Bedrock
if (hpw.PLOT_BEDROCK) { if (hpw.PLOT_BEDROCK) {
for (short x = 0; x < 16; x++) { for (short x = 0; x < 16; x++) {

View File

@ -6,6 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.FileBytes; import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
@ -42,7 +44,7 @@ public class HybridPlotManager extends ClassicPlotManager {
new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml",
Template.getBytes(hybridPlotWorld))); Template.getBytes(hybridPlotWorld)));
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator
+ hybridPlotWorld.worldname + File.separator; + hybridPlotWorld.getWorldName() + File.separator;
try { try {
File sideRoad = File sideRoad =
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem"); MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem");
@ -65,7 +67,7 @@ public class HybridPlotManager extends ClassicPlotManager {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
Template.zipAll(hybridPlotWorld.worldname, files); Template.zipAll(hybridPlotWorld.getWorldName(), files);
} }
@Override public boolean createRoadEast(Plot plot) { @Override public boolean createRoadEast(Plot plot) {
@ -74,9 +76,9 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x + 1, id.y); PlotId id2 = new PlotId(id.x + 1, id.y);
Location bot = getPlotBottomLocAbs(id2); Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id); Location top = getPlotTopLocAbs(id);
Location pos1 = new Location(hybridPlotWorld.worldname, top.getX() + 1, 0, bot.getZ() - 1); Location pos1 = new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
Location pos2 = Location pos2 =
new Location(hybridPlotWorld.worldname, bot.getX(), Math.min(getWorldHeight(), 255), new Location(hybridPlotWorld.getWorldName(), bot.getX(), Math.min(getWorldHeight(), 255),
top.getZ() + 1); top.getZ() + 1);
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2); MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@ -134,9 +136,9 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x, id.y + 1); PlotId id2 = new PlotId(id.x, id.y + 1);
Location bot = getPlotBottomLocAbs(id2); Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id); Location top = getPlotTopLocAbs(id);
Location pos1 = new Location(hybridPlotWorld.worldname, bot.getX() - 1, 0, top.getZ() + 1); Location pos1 = new Location(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
Location pos2 = Location pos2 =
new Location(hybridPlotWorld.worldname, top.getX() + 1, Math.min(getWorldHeight(), 255), new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, Math.min(getWorldHeight(), 255),
bot.getZ()); bot.getZ());
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2); MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@ -172,12 +174,13 @@ public class HybridPlotManager extends ClassicPlotManager {
* </p> * </p>
*/ */
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) { @Override public boolean clearPlot(Plot plot, final Runnable whenDone) {
final String world = hybridPlotWorld.worldname; final String world = hybridPlotWorld.getWorldName();
Location pos1 = plot.getBottomAbs(); Location pos1 = plot.getBottomAbs();
Location pos2 = plot.getExtendedTopAbs(); Location pos2 = plot.getExtendedTopAbs();
// If augmented // If augmented
final boolean canRegen = final boolean canRegen =
(hybridPlotWorld.TYPE == 0) && (hybridPlotWorld.TERRAIN == 0) && REGENERATIVE_CLEAR; (hybridPlotWorld.getType() == PlotAreaType.NORMAL)
&& (hybridPlotWorld.getTerrain() == PlotAreaTerrainType.NONE) && REGENERATIVE_CLEAR;
// The component blocks // The component blocks
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern(); final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern(); final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
@ -188,7 +191,7 @@ public class HybridPlotManager extends ClassicPlotManager {
bedrock = BlockUtil.get((short) 0, (byte) 0); bedrock = BlockUtil.get((short) 0, (byte) 0);
} }
final BlockState air = BlockUtil.get((short) 0, (byte) 0); final BlockState air = BlockUtil.get((short) 0, (byte) 0);
final BiomeType biome = hybridPlotWorld.PLOT_BIOME; final BiomeType biome = hybridPlotWorld.getPlotBiome();
final LocalBlockQueue queue = hybridPlotWorld.getQueue(false); final LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override public void run(int[] value) { @Override public void run(int[] value) {

View File

@ -145,7 +145,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
this.G_SCH = new HashMap<>(); this.G_SCH = new HashMap<>();
this.G_SCH_B = new HashMap<>(); this.G_SCH_B = new HashMap<>();
File root = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), File root = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
"schematics/GEN_ROAD_SCHEMATIC/" + this.worldname); "schematics/GEN_ROAD_SCHEMATIC/" + this.getWorldName());
File schematic1File = new File(root, "sideroad.schem"); File schematic1File = new File(root, "sideroad.schem");
if (!schematic1File.exists()) if (!schematic1File.exists())
schematic1File = new File(root, "sideroad.schematic"); schematic1File = new File(root, "sideroad.schematic");

View File

@ -11,6 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.listener.WEExtent;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@ -352,7 +353,7 @@ public abstract class HybridUtils {
return false; return false;
} }
HybridUtils.UPDATE = true; HybridUtils.UPDATE = true;
Set<BlockVector2> regions = ChunkManager.manager.getChunkChunks(area.worldname); Set<BlockVector2> regions = ChunkManager.manager.getChunkChunks(area.getWorldName());
return scheduleRoadUpdate(area, regions, extend, new HashSet<>()); return scheduleRoadUpdate(area, regions, extend, new HashSet<>());
} }
@ -384,7 +385,7 @@ public abstract class HybridUtils {
if (!regenedRoad) { if (!regenedRoad) {
PlotSquared.debug("Failed to regenerate roads."); PlotSquared.debug("Failed to regenerate roads.");
} }
ChunkManager.manager.unloadChunk(area.worldname, chunk, true); ChunkManager.manager.unloadChunk(area.getWorldName(), chunk, true);
} }
PlotSquared.debug("Cancelled road task"); PlotSquared.debug("Cancelled road task");
return; return;
@ -443,14 +444,14 @@ public abstract class HybridUtils {
BlockVector2 loc = iterator.next(); BlockVector2 loc = iterator.next();
iterator.remove(); iterator.remove();
PlotSquared.debug( PlotSquared.debug(
"[ERROR] Could not update '" + area.worldname + "/region/r." + loc "[ERROR] Could not update '" + area.getWorldName() + "/region/r." + loc
.getX() + "." + loc.getZ() + ".mca' (Corrupt chunk?)"); .getX() + "." + loc.getZ() + ".mca' (Corrupt chunk?)");
int sx = loc.getX() << 5; int sx = loc.getX() << 5;
int sz = loc.getZ() << 5; int sz = loc.getZ() << 5;
for (int x = sx; x < sx + 32; x++) { for (int x = sx; x < sx + 32; x++) {
for (int z = sz; z < sz + 32; z++) { for (int z = sz; z < sz + 32; z++) {
ChunkManager.manager ChunkManager.manager
.unloadChunk(area.worldname, BlockVector2.at(x, z), true); .unloadChunk(area.getWorldName(), BlockVector2.at(x, z), true);
} }
} }
PlotSquared.debug(" - Potentially skipping 1024 chunks"); PlotSquared.debug(" - Potentially skipping 1024 chunks");
@ -538,7 +539,7 @@ public abstract class HybridUtils {
return false; return false;
} }
AtomicBoolean toCheck = new AtomicBoolean(false); AtomicBoolean toCheck = new AtomicBoolean(false);
if (plotWorld.TYPE == 2) { if (plotWorld.getType() == PlotAreaType.PARTIAL) {
boolean chunk1 = area.contains(x, z); boolean chunk1 = area.contains(x, z);
boolean chunk2 = area.contains(ex, ez); boolean chunk2 = area.contains(ex, ez);
if (!chunk1 && !chunk2) { if (!chunk1 && !chunk2) {
@ -554,9 +555,9 @@ public abstract class HybridUtils {
z -= plotWorld.ROAD_OFFSET_Z; z -= plotWorld.ROAD_OFFSET_Z;
final int finalX = x; final int finalX = x;
final int finalZ = z; final int finalZ = z;
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(plotWorld.worldname, false); LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(plotWorld.getWorldName(), false);
if (id1 == null || id2 == null || id1 != id2) { if (id1 == null || id2 == null || id1 != id2) {
ChunkManager.manager.loadChunk(area.worldname, chunk, false).thenRun(() -> { ChunkManager.manager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
if (id1 != null) { if (id1 != null) {
Plot p1 = area.getPlotAbs(id1); Plot p1 = area.getPlotAbs(id1);
if (p1 != null && p1.hasOwner() && p1.isMerged()) { if (p1 != null && p1.hasOwner() && p1.isMerged()) {

View File

@ -55,7 +55,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1; + squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1; + squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
return new Location(squarePlotWorld.worldname, x, Math.min(getWorldHeight(), 255), z); return new Location(squarePlotWorld.getWorldName(), x, Math.min(getWorldHeight(), 255), z);
} }
@Override public PlotId getPlotIdAbs(int x, int y, int z) { @Override public PlotId getPlotIdAbs(int x, int y, int z) {
@ -204,7 +204,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
PlotSquared.debug("invalid location: " + Arrays.toString(merged)); PlotSquared.debug("invalid location: " + Arrays.toString(merged));
} catch (Exception ignored) { } catch (Exception ignored) {
PlotSquared.debug("Invalid plot / road width in settings.yml for world: " PlotSquared.debug("Invalid plot / road width in settings.yml for world: "
+ squarePlotWorld.worldname); + squarePlotWorld.getWorldName());
} }
return null; return null;
} }
@ -221,6 +221,6 @@ public abstract class SquarePlotManager extends GridPlotManager {
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math + squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math
.floor(squarePlotWorld.ROAD_WIDTH / 2); .floor(squarePlotWorld.ROAD_WIDTH / 2);
return new Location(squarePlotWorld.worldname, x, squarePlotWorld.MIN_BUILD_HEIGHT, z); return new Location(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), z);
} }
} }

View File

@ -264,14 +264,14 @@ public class PlotListener {
} }
if (!plot.getFlag(GamemodeFlag.class).equals(GamemodeFlag.DEFAULT) || !plot if (!plot.getFlag(GamemodeFlag.class).equals(GamemodeFlag.DEFAULT) || !plot
.getFlag(GuestGamemodeFlag.class).equals(GamemodeFlag.DEFAULT)) { .getFlag(GuestGamemodeFlag.class).equals(GamemodeFlag.DEFAULT)) {
if (player.getGameMode() != pw.GAMEMODE) { if (player.getGameMode() != pw.getGameMode()) {
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
player.setGameMode(pw.GAMEMODE); player.setGameMode(pw.getGameMode());
} else { } else {
MainUtil.sendMessage(player, StringMan MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), "{plot}", .replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), "{plot}",
plot.toString(), "{gamemode}", plot.toString(), "{gamemode}",
pw.GAMEMODE.getName().toLowerCase())); pw.getGameMode().getName().toLowerCase()));
} }
} }
} }

View File

@ -83,8 +83,8 @@ public class WEManager {
(allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot (allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot
.getTrusted().contains(uuid))) && !plot.getFlag(NoWorldeditFlag.class)) { .getTrusted().contains(uuid))) && !plot.getFlag(NoWorldeditFlag.class)) {
for (CuboidRegion region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
BlockVector3 pos1 = region.getMinimumPoint().withY(area.MIN_BUILD_HEIGHT); BlockVector3 pos1 = region.getMinimumPoint().withY(area.getMinBuildHeight());
BlockVector3 pos2 = region.getMaximumPoint().withY(area.MAX_BUILD_HEIGHT); BlockVector3 pos2 = region.getMaximumPoint().withY(area.getMaxBuildHeight());
CuboidRegion copy = new CuboidRegion(pos1, pos2); CuboidRegion copy = new CuboidRegion(pos1, pos2);
regions.add(copy); regions.add(copy);
} }

View File

@ -22,7 +22,7 @@ public class ConsolePlayer extends PlotPlayer {
Location location; Location location;
if (area != null) { if (area != null) {
CuboidRegion region = area.getRegion(); CuboidRegion region = area.getRegion();
location = new Location(area.worldname, location = new Location(area.getWorldName(),
region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0, region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0,
region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2); region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2);
} else { } else {

View File

@ -280,7 +280,7 @@ public class Plot {
} }
public String getWorldName() { public String getWorldName() {
return area.worldname; return area.getWorldName();
} }
/** /**
@ -894,7 +894,7 @@ public class Plot {
return; return;
} }
Plot current = queue.poll(); Plot current = queue.poll();
if (Plot.this.area.TERRAIN != 0) { if (Plot.this.area.getTerrain() != PlotAreaTerrainType.NONE) {
try { try {
ChunkManager.manager ChunkManager.manager
.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false, .regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false,
@ -993,7 +993,7 @@ public class Plot {
if (createRoad) { if (createRoad) {
manager.startPlotUnlink(ids); manager.startPlotUnlink(ids);
} }
if (this.area.TERRAIN != 3 && createRoad) { if (this.area.getTerrain() != PlotAreaTerrainType.ALL && createRoad) {
for (Plot current : plots) { for (Plot current : plots) {
if (current.getMerged(Direction.EAST)) { if (current.getMerged(Direction.EAST)) {
manager.createRoadEast(current); manager.createRoadEast(current);
@ -1040,9 +1040,9 @@ public class Plot {
return; return;
} }
PlotManager manager = this.area.getPlotManager(); PlotManager manager = this.area.getPlotManager();
if (this.area.ALLOW_SIGNS) { if (this.area.allowSigns()) {
Location location = manager.getSignLoc(this); Location location = manager.getSignLoc(this);
String id = this.id.x + ";" + this.id.y; String id = this.id.toString();
String[] lines = String[] lines =
new String[] {Captions.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id), new String[] {Captions.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id),
Captions.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll( Captions.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll(
@ -1330,7 +1330,7 @@ public class Plot {
return location; return location;
} }
int y = WorldUtil.IMP.getHighestBlock(getWorldName(), location.getX(), location.getZ()); int y = WorldUtil.IMP.getHighestBlock(getWorldName(), location.getX(), location.getZ());
if (area.ALLOW_SIGNS) { if (area.allowSigns()) {
y = Math.max(y, getManager().getSignLoc(this).getY()); y = Math.max(y, getManager().getSignLoc(this).getY());
} }
location.setY(1 + y); location.setY(1 + y);
@ -1344,7 +1344,7 @@ public class Plot {
int z = largest.getMinimumPoint().getZ() - 1; int z = largest.getMinimumPoint().getZ() - 1;
PlotManager manager = getManager(); PlotManager manager = getManager();
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 62; int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 62;
if (area.ALLOW_SIGNS && (y <= 0 || y >= 255)) { if (area.allowSigns() && (y <= 0 || y >= 255)) {
y = Math.max(y, manager.getSignLoc(this).getY() - 1); y = Math.max(y, manager.getSignLoc(this).getY() - 1);
} }
return new Location(getWorldName(), x, y + 1, z); return new Location(getWorldName(), x, y + 1, z);
@ -1406,7 +1406,7 @@ public class Plot {
public Location getDefaultHome(boolean member) { public Location getDefaultHome(boolean member) {
Plot plot = this.getBasePlot(false); Plot plot = this.getBasePlot(false);
PlotLoc loc = member ? area.DEFAULT_HOME : area.NONMEMBER_HOME; PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
if (loc != null) { if (loc != null) {
int x; int x;
int z; int z;
@ -1541,7 +1541,7 @@ public class Plot {
*/ */
public void removeSign() { public void removeSign() {
PlotManager manager = this.area.getPlotManager(); PlotManager manager = this.area.getPlotManager();
if (!this.area.ALLOW_SIGNS) { if (!this.area.allowSigns()) {
return; return;
} }
Location location = manager.getSignLoc(this); Location location = manager.getSignLoc(this);
@ -1602,15 +1602,15 @@ public class Plot {
teleportPlayer(player, TeleportCause.COMMAND); teleportPlayer(player, TeleportCause.COMMAND);
} }
PlotArea plotworld = getArea(); PlotArea plotworld = getArea();
if (plotworld.SCHEMATIC_ON_CLAIM) { if (plotworld.isSchematicOnClaim()) {
Schematic sch; Schematic sch;
try { try {
if (schematic == null || schematic.isEmpty()) { if (schematic == null || schematic.isEmpty()) {
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); sch = SchematicHandler.manager.getSchematic(plotworld.getSchematicFile());
} else { } else {
sch = SchematicHandler.manager.getSchematic(schematic); sch = SchematicHandler.manager.getSchematic(schematic);
if (sch == null) { if (sch == null) {
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); sch = SchematicHandler.manager.getSchematic(plotworld.getSchematicFile());
} }
} }
} catch (SchematicHandler.UnsupportedFormatException e) { } catch (SchematicHandler.UnsupportedFormatException e) {
@ -1663,7 +1663,7 @@ public class Plot {
if (this.area.addPlot(this)) { if (this.area.addPlot(this)) {
DBFunc.createPlotAndSettings(this, () -> { DBFunc.createPlotAndSettings(this, () -> {
PlotArea plotworld = Plot.this.area; PlotArea plotworld = Plot.this.area;
if (notify && plotworld.AUTO_MERGE) { if (notify && plotworld.isAutoMerge()) {
PlotPlayer player = WorldUtil.IMP.wrapPlayer(uuid); PlotPlayer player = WorldUtil.IMP.wrapPlayer(uuid);
PlotMergeEvent event = PlotSquared.get().getEventDispatcher() PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player); .callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
@ -1846,17 +1846,14 @@ public class Plot {
* - Used when a plot is merged<br> * - Used when a plot is merged<br>
*/ */
public void removeRoadEast() { public void removeRoadEast() {
if (this.area.TYPE != 0 && this.area.TERRAIN > 1) { if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
if (this.area.TERRAIN == 3) {
return;
}
Plot other = this.getRelative(Direction.EAST); Plot other = this.getRelative(Direction.EAST);
Location bot = other.getBottomAbs(); Location bot = other.getBottomAbs();
Location top = this.getTopAbs(); Location top = this.getTopAbs();
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ()); Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
Location pos2 = new Location(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ()); Location pos2 = new Location(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null); ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
} else { } else if (this.area.getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.area.getPlotManager().removeRoadEast(this); this.area.getPlotManager().removeRoadEast(this);
} }
} }
@ -2228,7 +2225,7 @@ public class Plot {
if (this.hasOwner()) { if (this.hasOwner()) {
return this.owner; return this.owner;
} }
if (!this.area.ALLOW_SIGNS) { if (!this.area.allowSigns()) {
return null; return null;
} }
try { try {
@ -2291,17 +2288,14 @@ public class Plot {
* - Used when a plot is merged<br> * - Used when a plot is merged<br>
*/ */
public void removeRoadSouth() { public void removeRoadSouth() {
if (this.area.TYPE != 0 && this.area.TERRAIN > 1) { if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
if (this.area.TERRAIN == 3) {
return;
}
Plot other = this.getRelative(Direction.SOUTH); Plot other = this.getRelative(Direction.SOUTH);
Location bot = other.getBottomAbs(); Location bot = other.getBottomAbs();
Location top = this.getTopAbs(); Location top = this.getTopAbs();
Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ()); Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
Location pos2 = new Location(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ()); Location pos2 = new Location(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null); ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
} else { } else if (this.area.getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.getManager().removeRoadSouth(this); this.getManager().removeRoadSouth(this);
} }
} }
@ -2470,17 +2464,14 @@ public class Plot {
* Remove the SE road (only effects terrain) * Remove the SE road (only effects terrain)
*/ */
public void removeRoadSouthEast() { public void removeRoadSouthEast() {
if (this.area.TYPE != 0 && this.area.TERRAIN > 1) { if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
if (this.area.TERRAIN == 3) {
return;
}
Plot other = this.getRelative(1, 1); Plot other = this.getRelative(1, 1);
Location pos1 = this.getTopAbs().add(1, 0, 1); Location pos1 = this.getTopAbs().add(1, 0, 1);
Location pos2 = other.getBottomAbs().subtract(1, 0, 1); Location pos2 = other.getBottomAbs().subtract(1, 0, 1);
pos1.setY(0); pos1.setY(0);
pos2.setY(MAX_HEIGHT); pos2.setY(MAX_HEIGHT);
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null); ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
} else { } else if (this.area.getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.area.getPlotManager().removeRoadSouthEast(this); this.area.getPlotManager().removeRoadSouthEast(this);
} }
} }
@ -2884,7 +2875,7 @@ public class Plot {
return false; return false;
} }
final Location location; final Location location;
if (this.area.HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) { if (this.area.isHomeAllowNonmember() || plot.isAdded(player.getUUID())) {
location = this.getHome(); location = this.getHome();
} else { } else {
location = this.getDefaultHome(false); location = this.getDefaultHome(false);

View File

@ -29,7 +29,9 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -51,40 +53,40 @@ import java.util.function.Consumer;
*/ */
public abstract class PlotArea { public abstract class PlotArea {
public final String worldname;
public final String id;
@NotNull public final PlotManager manager;
public final int worldhash;
protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>(); protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
@Getter @NotNull private final String worldName;
@Getter private final String id;
@Getter @NotNull private final PlotManager plotManager;
@Getter private final int worldHash;
private final PlotId min; private final PlotId min;
private final PlotId max; private final PlotId max;
@NotNull private final IndependentPlotGenerator generator; @Getter @NotNull private final IndependentPlotGenerator generator;
public int MAX_PLOT_MEMBERS = 128; @Getter private int maxPlotMembers = 128;
public boolean AUTO_MERGE = false; @Getter private boolean autoMerge = false;
public boolean ALLOW_SIGNS = true; @Setter private boolean allowSigns = true;
public boolean MISC_SPAWN_UNOWNED = false; @Getter private boolean miscSpawnUnowned = false;
public boolean MOB_SPAWNING = false; @Getter private boolean mobSpawning = false;
public boolean MOB_SPAWNER_SPAWNING = false; @Getter private boolean mobSpawnerSpawning = false;
public BiomeType PLOT_BIOME = BiomeTypes.FOREST; @Getter private BiomeType plotBiome = BiomeTypes.FOREST;
public boolean PLOT_CHAT = false; @Getter private boolean plotChat = false;
public boolean SCHEMATIC_CLAIM_SPECIFY = false; @Getter private boolean schematicClaimSpecify = false;
public boolean SCHEMATIC_ON_CLAIM = false; @Getter private boolean schematicOnClaim = false;
public String SCHEMATIC_FILE = "null"; @Getter private String schematicFile = "null";
public List<String> SCHEMATICS = null; @Getter private boolean spawnEggs = false;
public boolean USE_ECONOMY = false; @Getter private boolean spawnCustom = true;
public Map<String, Expression<Double>> PRICES = new HashMap<>(); @Getter private boolean spawnBreeding = false;
public boolean SPAWN_EGGS = false; @Getter private PlotAreaType type = PlotAreaType.NORMAL;
public boolean SPAWN_CUSTOM = true; @Getter private PlotAreaTerrainType terrain = PlotAreaTerrainType.NONE;
public boolean SPAWN_BREEDING = false; @Getter private boolean homeAllowNonmember = false;
public boolean WORLD_BORDER = false; @Getter private PlotLoc nonmemberHome;
public int TYPE = 0; @Getter @Setter(AccessLevel.PROTECTED) private PlotLoc defaultHome;
public int TERRAIN = 0; @Getter private int maxBuildHeight = 256;
public boolean HOME_ALLOW_NONMEMBER = false; @Getter private int minBuildHeight = 1;
public PlotLoc NONMEMBER_HOME; @Getter private GameMode gameMode = GameModes.CREATIVE;
public PlotLoc DEFAULT_HOME; @Getter private Map<String, Expression<Double>> prices = new HashMap<>();
public int MAX_BUILD_HEIGHT = 256; @Getter(AccessLevel.PROTECTED) private List<String> schematics = new ArrayList<>();
public int MIN_BUILD_HEIGHT = 1; private boolean worldBorder = false;
public GameMode GAMEMODE = GameModes.CREATIVE; private boolean useEconomy = false;
private int hash; private int hash;
private CuboidRegion region; private CuboidRegion region;
private ConcurrentHashMap<String, Object> meta; private ConcurrentHashMap<String, Object> meta;
@ -98,9 +100,9 @@ public abstract class PlotArea {
public PlotArea(@NotNull final String worldName, @Nullable final String id, public PlotArea(@NotNull final String worldName, @Nullable final String id,
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min, @NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
@Nullable final PlotId max) { @Nullable final PlotId max) {
this.worldname = worldName; this.worldName = worldName;
this.id = id; this.id = id;
this.manager = createManager(); this.plotManager = createManager();
this.generator = generator; this.generator = generator;
if (min == null || max == null) { if (min == null || max == null) {
if (min != max) { if (min != max) {
@ -113,13 +115,13 @@ public abstract class PlotArea {
this.min = min; this.min = min;
this.max = max; this.max = max;
} }
this.worldhash = worldName.hashCode(); this.worldHash = worldName.hashCode();
} }
@NotNull protected abstract PlotManager createManager(); @NotNull protected abstract PlotManager createManager();
public LocalBlockQueue getQueue(final boolean autoQueue) { public LocalBlockQueue getQueue(final boolean autoQueue) {
return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue); return GlobalBlockQueue.IMP.getNewQueue(worldName, autoQueue);
} }
/** /**
@ -174,15 +176,6 @@ public abstract class PlotArea {
return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max; return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
} }
/**
* Get the implementation independent generator for this area.
*
* @return the {@link IndependentPlotGenerator}
*/
@NotNull public IndependentPlotGenerator getGenerator() {
return this.generator;
}
@Override public boolean equals(Object obj) { @Override public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
@ -191,8 +184,8 @@ public abstract class PlotArea {
return false; return false;
} }
PlotArea plotarea = (PlotArea) obj; PlotArea plotarea = (PlotArea) obj;
return this.worldhash == plotarea.worldhash && this.worldname.equals(plotarea.worldname) return this.getWorldHash() == plotarea.getWorldHash() && this.getWorldName().equals(plotarea.getWorldName())
&& StringMan.isEqual(this.id, plotarea.id); && StringMan.isEqual(this.getId(), plotarea.getId());
} }
public Set<PlotCluster> getClusters() { public Set<PlotCluster> getClusters() {
@ -208,9 +201,9 @@ public abstract class PlotArea {
public boolean isCompatible(PlotArea plotArea) { public boolean isCompatible(PlotArea plotArea) {
ConfigurationSection section = PlotSquared.get().worlds.getConfigurationSection("worlds"); ConfigurationSection section = PlotSquared.get().worlds.getConfigurationSection("worlds");
for (ConfigurationNode setting : plotArea.getSettingNodes()) { for (ConfigurationNode setting : plotArea.getSettingNodes()) {
Object constant = section.get(plotArea.worldname + '.' + setting.getConstant()); Object constant = section.get(plotArea.worldName + '.' + setting.getConstant());
if (constant == null || !constant if (constant == null || !constant
.equals(section.get(this.worldname + '.' + setting.getConstant()))) { .equals(section.get(this.worldName + '.' + setting.getConstant()))) {
return false; return false;
} }
} }
@ -227,79 +220,79 @@ public abstract class PlotArea {
throw new IllegalArgumentException("Must extend GridPlotWorld to provide"); throw new IllegalArgumentException("Must extend GridPlotWorld to provide");
} }
if (config.contains("generator.terrain")) { if (config.contains("generator.terrain")) {
this.TERRAIN = config.getInt("generator.terrain"); this.terrain = MainUtil.getTerrain(config);
this.TYPE = config.getInt("generator.type"); this.type = MainUtil.getType(config);
} }
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.mobSpawning = config.getBoolean("natural_mob_spawning");
this.MISC_SPAWN_UNOWNED = config.getBoolean("misc_spawn_unowned"); this.miscSpawnUnowned = config.getBoolean("misc_spawn_unowned");
this.MOB_SPAWNER_SPAWNING = config.getBoolean("mob_spawner_spawning"); this.mobSpawnerSpawning = config.getBoolean("mob_spawner_spawning");
this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); this.autoMerge = config.getBoolean("plot.auto_merge");
this.MAX_PLOT_MEMBERS = config.getInt("limits.max-members"); this.maxPlotMembers = config.getInt("limits.max-members");
this.ALLOW_SIGNS = config.getBoolean("plot.create_signs"); this.allowSigns = config.getBoolean("plot.create_signs");
this.PLOT_BIOME = Configuration.BIOME.parseString(config.getString("plot.biome")); this.plotBiome = Configuration.BIOME.parseString(config.getString("plot.biome"));
this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim"); this.schematicOnClaim = config.getBoolean("schematic.on_claim");
this.SCHEMATIC_FILE = config.getString("schematic.file"); this.schematicFile = config.getString("schematic.file");
this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim"); this.schematicClaimSpecify = config.getBoolean("schematic.specify_on_claim");
this.SCHEMATICS = new ArrayList<>(config.getStringList("schematic.schematics")); this.schematics = new ArrayList<>(config.getStringList("schematic.schematics"));
this.SCHEMATICS.replaceAll(String::toLowerCase); this.schematics.replaceAll(String::toLowerCase);
this.USE_ECONOMY = config.getBoolean("economy.use") && EconHandler.getEconHandler() != null; this.useEconomy = config.getBoolean("economy.use") && EconHandler.getEconHandler() != null;
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices"); ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
if (this.USE_ECONOMY) { if (this.useEconomy) {
this.PRICES = new HashMap<>(); this.prices = new HashMap<>();
for (String key : priceSection.getKeys(false)) { for (String key : priceSection.getKeys(false)) {
this.PRICES.put(key, Expression.doubleExpression(priceSection.getString(key))); this.prices.put(key, Expression.doubleExpression(priceSection.getString(key)));
} }
} }
this.PLOT_CHAT = config.getBoolean("chat.enabled"); this.plotChat = config.getBoolean("chat.enabled");
this.WORLD_BORDER = config.getBoolean("world.border"); this.worldBorder = config.getBoolean("world.border");
this.MAX_BUILD_HEIGHT = config.getInt("world.max_height"); this.maxBuildHeight = config.getInt("world.max_height");
this.MIN_BUILD_HEIGHT = config.getInt("world.min_height"); this.minBuildHeight = config.getInt("world.min_height");
switch (config.getString("world.gamemode").toLowerCase()) { switch (config.getString("world.gamemode").toLowerCase()) {
case "creative": case "creative":
case "c": case "c":
case "1": case "1":
this.GAMEMODE = GameModes.CREATIVE; this.gameMode = GameModes.CREATIVE;
break; break;
case "adventure": case "adventure":
case "a": case "a":
case "2": case "2":
this.GAMEMODE = GameModes.ADVENTURE; this.gameMode = GameModes.ADVENTURE;
break; break;
case "spectator": case "spectator":
case "3": case "3":
this.GAMEMODE = GameModes.SPECTATOR; this.gameMode = GameModes.SPECTATOR;
break; break;
case "survival": case "survival":
case "s": case "s":
case "0": case "0":
default: default:
this.GAMEMODE = GameModes.SURVIVAL; this.gameMode = GameModes.SURVIVAL;
break; break;
} }
String homeNonMembers = config.getString("home.nonmembers"); String homeNonMembers = config.getString("home.nonmembers");
String homeDefault = config.getString("home.default"); String homeDefault = config.getString("home.default");
this.DEFAULT_HOME = PlotLoc.fromString(homeDefault); this.defaultHome = PlotLoc.fromString(homeDefault);
this.HOME_ALLOW_NONMEMBER = homeNonMembers.equalsIgnoreCase(homeDefault); this.homeAllowNonmember = homeNonMembers.equalsIgnoreCase(homeDefault);
if (this.HOME_ALLOW_NONMEMBER) { if (this.homeAllowNonmember) {
this.NONMEMBER_HOME = DEFAULT_HOME; this.nonmemberHome = defaultHome;
} else { } else {
this.NONMEMBER_HOME = PlotLoc.fromString(homeNonMembers); this.nonmemberHome = PlotLoc.fromString(homeNonMembers);
} }
if ("side".equalsIgnoreCase(homeDefault)) { if ("side".equalsIgnoreCase(homeDefault)) {
this.DEFAULT_HOME = null; this.defaultHome = null;
} else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) { } else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) {
this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE); this.defaultHome = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
} else { } else {
try { try {
/*String[] split = homeDefault.split(","); /*String[] split = homeDefault.split(",");
this.DEFAULT_HOME = this.DEFAULT_HOME =
new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));*/ new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));*/
this.DEFAULT_HOME = PlotLoc.fromString(homeDefault); this.defaultHome = PlotLoc.fromString(homeDefault);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
this.DEFAULT_HOME = null; this.defaultHome = null;
} }
} }
@ -321,12 +314,12 @@ public abstract class PlotArea {
this.getFlagContainer().addAll(parseFlags(flags)); this.getFlagContainer().addAll(parseFlags(flags));
} catch (FlagParseException e) { } catch (FlagParseException e) {
e.printStackTrace(); e.printStackTrace();
PlotSquared.debug("&cInvalid default flags for " + this.worldname + ": " + StringMan PlotSquared.debug("&cInvalid default flags for " + this.getWorldName() + ": " + StringMan
.join(flags, ",")); .join(flags, ","));
} }
this.SPAWN_EGGS = config.getBoolean("event.spawn.egg"); this.spawnEggs = config.getBoolean("event.spawn.egg");
this.SPAWN_CUSTOM = config.getBoolean("event.spawn.custom"); this.spawnCustom = config.getBoolean("event.spawn.custom");
this.SPAWN_BREEDING = config.getBoolean("event.spawn.breeding"); this.spawnBreeding = config.getBoolean("event.spawn.breeding");
loadConfiguration(config); loadConfiguration(config);
} }
@ -339,40 +332,40 @@ public abstract class PlotArea {
*/ */
public void saveConfiguration(ConfigurationSection config) { public void saveConfiguration(ConfigurationSection config) {
HashMap<String, Object> options = new HashMap<>(); HashMap<String, Object> options = new HashMap<>();
options.put("natural_mob_spawning", this.MOB_SPAWNING); options.put("natural_mob_spawning", this.isMobSpawning());
options.put("misc_spawn_unowned", this.MISC_SPAWN_UNOWNED); options.put("misc_spawn_unowned", this.isMiscSpawnUnowned());
options.put("mob_spawner_spawning", this.MOB_SPAWNER_SPAWNING); options.put("mob_spawner_spawning", this.isMobSpawnerSpawning());
options.put("plot.auto_merge", this.AUTO_MERGE); options.put("plot.auto_merge", this.isAutoMerge());
options.put("plot.create_signs", this.ALLOW_SIGNS); options.put("plot.create_signs", this.allowSigns());
options.put("plot.biome", "FOREST"); options.put("plot.biome", "FOREST");
options.put("schematic.on_claim", this.SCHEMATIC_ON_CLAIM); options.put("schematic.on_claim", this.isSchematicOnClaim());
options.put("schematic.file", this.SCHEMATIC_FILE); options.put("schematic.file", this.getSchematicFile());
options.put("schematic.specify_on_claim", this.SCHEMATIC_CLAIM_SPECIFY); options.put("schematic.specify_on_claim", this.isSchematicClaimSpecify());
options.put("schematic.schematics", this.SCHEMATICS); options.put("schematic.schematics", this.getSchematics());
options.put("economy.use", this.USE_ECONOMY); options.put("economy.use", this.useEconomy());
options.put("economy.prices.claim", 100); options.put("economy.prices.claim", 100);
options.put("economy.prices.merge", 100); options.put("economy.prices.merge", 100);
options.put("economy.prices.sell", 100); options.put("economy.prices.sell", 100);
options.put("chat.enabled", this.PLOT_CHAT); options.put("chat.enabled", this.isPlotChat());
options.put("flags.default", null); options.put("flags.default", null);
options.put("event.spawn.egg", this.SPAWN_EGGS); options.put("event.spawn.egg", this.isSpawnEggs());
options.put("event.spawn.custom", this.SPAWN_CUSTOM); options.put("event.spawn.custom", this.isSpawnCustom());
options.put("event.spawn.breeding", this.SPAWN_BREEDING); options.put("event.spawn.breeding", this.isSpawnBreeding());
options.put("world.border", this.WORLD_BORDER); options.put("world.border", this.hasWorldBorder());
options.put("limits.max-members", this.MAX_PLOT_MEMBERS); options.put("limits.max-members", this.getMaxPlotMembers());
options.put("home.default", "side"); options.put("home.default", "side");
String position = config.getString("home.nonmembers", String position = config.getString("home.nonmembers",
config.getBoolean("home.allow-nonmembers", false) ? config.getBoolean("home.allow-nonmembers", false) ?
config.getString("home.default", "side") : config.getString("home.default", "side") :
"side"); "side");
options.put("home.nonmembers", position); options.put("home.nonmembers", position);
options.put("world.max_height", this.MAX_BUILD_HEIGHT); options.put("world.max_height", this.getMaxBuildHeight());
options.put("world.min_height", this.MIN_BUILD_HEIGHT); options.put("world.min_height", this.getMinBuildHeight());
options.put("world.gamemode", this.GAMEMODE.getName().toLowerCase()); options.put("world.gamemode", this.getGameMode().getName().toLowerCase());
if (this.TYPE != 0) { if (this.getType() != PlotAreaType.NORMAL) {
options.put("generator.terrain", this.TERRAIN); options.put("generator.terrain", this.getTerrain());
options.put("generator.type", this.TYPE); options.put("generator.type", this.getType().toString());
} }
ConfigurationNode[] settings = getSettingNodes(); ConfigurationNode[] settings = getSettingNodes();
/* /*
@ -393,10 +386,10 @@ public abstract class PlotArea {
} }
@NotNull @Override public String toString() { @NotNull @Override public String toString() {
if (this.id == null) { if (this.getId() == null) {
return this.worldname; return this.getWorldName();
} else { } else {
return this.worldname + ";" + this.id; return this.getWorldName() + ";" + this.getId();
} }
} }
@ -422,7 +415,7 @@ public abstract class PlotArea {
*/ */
@Nullable public Plot getPlotAbs(@NotNull final Location location) { @Nullable public Plot getPlotAbs(@NotNull final Location location) {
final PlotId pid = final PlotId pid =
this.manager.getPlotId(location.getX(), location.getY(), location.getZ()); this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) { if (pid == null) {
return null; return null;
} }
@ -437,7 +430,7 @@ public abstract class PlotArea {
*/ */
@Nullable public Plot getPlot(@NotNull final Location location) { @Nullable public Plot getPlot(@NotNull final Location location) {
final PlotId pid = final PlotId pid =
this.manager.getPlotId(location.getX(), location.getY(), location.getZ()); this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) { if (pid == null) {
return null; return null;
} }
@ -452,7 +445,7 @@ public abstract class PlotArea {
*/ */
@Nullable public Plot getOwnedPlot(@NotNull final Location location) { @Nullable public Plot getOwnedPlot(@NotNull final Location location) {
final PlotId pid = final PlotId pid =
this.manager.getPlotId(location.getX(), location.getY(), location.getZ()); this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) { if (pid == null) {
return null; return null;
} }
@ -468,7 +461,7 @@ public abstract class PlotArea {
*/ */
@Nullable public Plot getOwnedPlotAbs(@NotNull final Location location) { @Nullable public Plot getOwnedPlotAbs(@NotNull final Location location) {
final PlotId pid = final PlotId pid =
this.manager.getPlotId(location.getX(), location.getY(), location.getZ()); this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) { if (pid == null) {
return null; return null;
} }
@ -491,7 +484,7 @@ public abstract class PlotArea {
} }
public boolean contains(final int x, final int z) { public boolean contains(final int x, final int z) {
return this.TYPE != 2 || RegionUtil.contains(getRegionAbs(), x, z); return this.getType() != PlotAreaType.PARTIAL || RegionUtil.contains(getRegionAbs(), x, z);
} }
public boolean contains(@NotNull final PlotId id) { public boolean contains(@NotNull final PlotId id) {
@ -500,7 +493,7 @@ public abstract class PlotArea {
} }
public boolean contains(@NotNull final Location location) { public boolean contains(@NotNull final Location location) {
return StringMan.isEqual(location.getWorld(), this.worldname) && (getRegionAbs() == null return StringMan.isEqual(location.getWorld(), this.getWorldName()) && (getRegionAbs() == null
|| this.region.contains(location.getBlockVector3())); || this.region.contains(location.getBlockVector3()));
} }
@ -552,10 +545,10 @@ public abstract class PlotArea {
} }
//todo check if this method is needed in this class //todo check if this method is needed in this class
public int getPlotCount(@Nullable final PlotPlayer player) { public int getPlotCount(@Nullable final PlotPlayer player) {
return player != null ? getPlotCount(player.getUUID()) : 0; return player != null ? getPlotCount(player.getUUID()) : 0;
} }
@Nullable public Plot getPlotAbs(@NotNull final PlotId id) { @Nullable public Plot getPlotAbs(@NotNull final PlotId id) {
Plot plot = getOwnedPlotAbs(id); Plot plot = getOwnedPlotAbs(id);
if (plot == null) { if (plot == null) {
@ -614,10 +607,6 @@ public abstract class PlotArea {
return this.clusters != null ? this.clusters.get(id.x, id.y) : null; return this.clusters != null ? this.clusters.get(id.x, id.y) : null;
} }
@NotNull public PlotManager getPlotManager() {
return this.manager;
}
/** /**
* Session only plot metadata (session is until the server stops). * Session only plot metadata (session is until the server stops).
* <br> * <br>
@ -700,7 +689,7 @@ public abstract class PlotArea {
PlotId center; PlotId center;
PlotId min = getMin(); PlotId min = getMin();
PlotId max = getMax(); PlotId max = getMax();
if (TYPE == 2) { if (getType() == PlotAreaType.PARTIAL) {
center = new PlotId(MathMan.average(min.x, max.x), MathMan.average(min.y, max.y)); center = new PlotId(MathMan.average(min.x, max.x), MathMan.average(min.y, max.y));
plots = Math.max(max.x - min.x + 1, max.y - min.y + 1) + 1; plots = Math.max(max.x - min.x + 1, max.y - min.y + 1) + 1;
if (start != null) { if (start != null) {
@ -762,7 +751,7 @@ public abstract class PlotArea {
* Setup the plot border for a world (usually done when the world is created). * Setup the plot border for a world (usually done when the world is created).
*/ */
public void setupBorder() { public void setupBorder() {
if (!this.WORLD_BORDER) { if (!this.hasWorldBorder()) {
return; return;
} }
final Integer meta = (Integer) getMeta("worldBorder"); final Integer meta = (Integer) getMeta("worldBorder");
@ -946,6 +935,63 @@ public abstract class PlotArea {
return null; return null;
} }
/**
* Get whether a schematic with that name is available or not.
* If a schematic is available, it can be used for plot claiming.
*
* @param schematic the schematic to look for.
* @return true if the schematic exists, false otherwise.
*/
public boolean hasSchematic(@NotNull String schematic) {
return getSchematics().contains(schematic.toLowerCase());
}
/**
* Get whether economy is enabled and used on this plot area or not.
*
* @return true if this plot area uses economy, false otherwise.
*/
public boolean useEconomy() {
return useEconomy;
}
/**
* Get whether the plot area is limited by a world border or not.
*
* @return true if the plot area has a world border, false otherwise.
*/
public boolean hasWorldBorder() {
return worldBorder;
}
/**
* Get whether plot signs are allowed or not.
*
* @return true if plot signs are allow, false otherwise.
*/
public boolean allowSigns() {
return allowSigns;
}
/**
* Set the type of this plot area.
*
* @param type the type of the plot area.
*/
public void setType(PlotAreaType type) {
// TODO this should probably work only if type == null
this.type = type;
}
/**
* Set the terrain generation type of this plot area.
*
* @param terrain the terrain type of the plot area.
*/
public void setTerrain(PlotAreaTerrainType terrain) {
this.terrain = terrain;
}
private static Collection<PlotFlag<?, ?>> parseFlags(List<String> flagStrings) throws FlagParseException { private static Collection<PlotFlag<?, ?>> parseFlags(List<String> flagStrings) throws FlagParseException {
final Collection<PlotFlag<?, ?>> flags = new ArrayList<>(); final Collection<PlotFlag<?, ?>> flags = new ArrayList<>();
for (final String key : flagStrings) { for (final String key : flagStrings) {
@ -962,5 +1008,4 @@ public abstract class PlotArea {
} }
return flags; return flags;
} }
} }

View File

@ -0,0 +1,45 @@
package com.github.intellectualsites.plotsquared.plot.object;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public enum PlotAreaTerrainType {
/**
* Don't use any vanilla world elements.
*/
NONE,
/**
* Generate vanilla ores.
*/
ORE,
/**
* Generate everything using the vanilla generator but with PS roads.
*/
ROAD,
/**
* Generate everything using the vanilla generator.
*/
ALL;
private static final Map<String, PlotAreaTerrainType> types = Stream.of(values())
.collect(Collectors.toMap(e -> e.toString().toLowerCase(), Function.identity()));
public static Optional<PlotAreaTerrainType> fromString(String typeString) {
return Optional.ofNullable(types.get(typeString));
}
@Deprecated
public static Optional<PlotAreaTerrainType> fromLegacyInt(int typeId) {
if (typeId < 0 || typeId >= values().length) {
return Optional.empty();
}
return Optional.of(values()[typeId]);
}
}

View File

@ -0,0 +1,28 @@
package com.github.intellectualsites.plotsquared.plot.object;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public enum PlotAreaType {
NORMAL,
AUGMENTED,
PARTIAL;
private static final Map<String, PlotAreaType> types = Stream.of(values())
.collect(Collectors.toMap(e -> e.toString().toLowerCase(), Function.identity()));
public static Optional<PlotAreaType> fromString(String typeName) {
return Optional.ofNullable(types.get(typeName.toLowerCase()));
}
@Deprecated
public static Optional<PlotAreaType> fromLegacyInt(int typeId) {
if (typeId < 0 || typeId >= values().length) {
return Optional.empty();
}
return Optional.of(values()[typeId]);
}
}

View File

@ -140,7 +140,7 @@ public class PlotCluster {
} else { } else {
toReturn = getClusterBottom().add(home.getX(), home.getY(), home.getZ()); toReturn = getClusterBottom().add(home.getX(), home.getY(), home.getZ());
} }
int max = MainUtil.getHeighestBlock(this.area.worldname, toReturn.getX(), toReturn.getZ()); int max = MainUtil.getHeighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ());
if (max > toReturn.getY()) { if (max > toReturn.getY()) {
toReturn.setY(1 + max); toReturn.setY(1 + max);
} }

View File

@ -84,7 +84,7 @@ public abstract class PlotManager {
HashSet<FileBytes> files = new HashSet<>(Collections.singletonList( HashSet<FileBytes> files = new HashSet<>(Collections.singletonList(
new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml",
Template.getBytes(plotArea)))); Template.getBytes(plotArea))));
Template.zipAll(plotArea.worldname, files); Template.zipAll(plotArea.getWorldName(), files);
} }
public int getWorldHeight() { public int getWorldHeight() {

View File

@ -38,12 +38,12 @@ public class SetupObject {
/** /**
* The management type (normal, augmented, partial) * The management type (normal, augmented, partial)
*/ */
public int type; public PlotAreaType type;
/** /**
* The terrain type * The terrain type
*/ */
public int terrain; public PlotAreaTerrainType terrain;
/** /**
* Area ID (may be null) * Area ID (may be null)

View File

@ -49,9 +49,9 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
String world = location.getWorld(); String world = location.getWorld();
int hash = world.hashCode(); int hash = world.hashCode();
for (PlotArea area : this.plotAreas) { for (PlotArea area : this.plotAreas) {
if (hash == area.worldhash) { if (hash == area.getWorldHash()) {
if (area.contains(location.getX(), location.getZ()) && ( if (area.contains(location.getX(), location.getZ()) && (
!this.plotAreaHasCollision || world.equals(area.worldname))) { !this.plotAreaHasCollision || world.equals(area.getWorldName()))) {
return area; return area;
} }
} }
@ -91,20 +91,20 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
@Override public void addPlotArea(PlotArea plotArea) { @Override public void addPlotArea(PlotArea plotArea) {
HashSet<PlotArea> localAreas = HashSet<PlotArea> localAreas =
new HashSet<>(Arrays.asList(getPlotAreas(plotArea.worldname, null))); new HashSet<>(Arrays.asList(getPlotAreas(plotArea.getWorldName(), null)));
HashSet<PlotArea> globalAreas = new HashSet<>(Arrays.asList(plotAreas)); HashSet<PlotArea> globalAreas = new HashSet<>(Arrays.asList(plotAreas));
localAreas.add(plotArea); localAreas.add(plotArea);
globalAreas.add(plotArea); globalAreas.add(plotArea);
this.plotAreas = globalAreas.toArray(new PlotArea[0]); this.plotAreas = globalAreas.toArray(new PlotArea[0]);
this.plotAreaMap.put(plotArea.worldname, localAreas.toArray(new PlotArea[0])); this.plotAreaMap.put(plotArea.getWorldName(), localAreas.toArray(new PlotArea[0]));
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname); QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.getWorldName());
if (map == null) { if (map == null) {
map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) { map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) {
@Override public CuboidRegion getRegion(PlotArea value) { @Override public CuboidRegion getRegion(PlotArea value) {
return value.getRegion(); return value.getRegion();
} }
}; };
this.plotAreaGrid.put(plotArea.worldname, map); this.plotAreaGrid.put(plotArea.getWorldName(), map);
} }
map.add(plotArea); map.add(plotArea);
} }
@ -114,11 +114,11 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
globalAreas.remove(area); globalAreas.remove(area);
this.plotAreas = globalAreas.toArray(new PlotArea[0]); this.plotAreas = globalAreas.toArray(new PlotArea[0]);
if (globalAreas.isEmpty()) { if (globalAreas.isEmpty()) {
this.plotAreaMap.remove(area.worldname); this.plotAreaMap.remove(area.getWorldName());
this.plotAreaGrid.remove(area.worldname); this.plotAreaGrid.remove(area.getWorldName());
} else { } else {
this.plotAreaMap.put(area.worldname, globalAreas.toArray(new PlotArea[0])); this.plotAreaMap.put(area.getWorldName(), globalAreas.toArray(new PlotArea[0]));
this.plotAreaGrid.get(area.worldname).remove(area); this.plotAreaGrid.get(area.getWorldName()).remove(area);
} }
} }
@ -133,7 +133,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
return null; return null;
} }
for (PlotArea area : areas) { for (PlotArea area : areas) {
if (StringMan.isEqual(id, area.id)) { if (StringMan.isEqual(id, area.getId())) {
return area; return area;
} }
} }
@ -161,9 +161,9 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
String world = location.getWorld(); String world = location.getWorld();
int hash = world.hashCode(); int hash = world.hashCode();
for (PlotArea area : this.plotAreas) { for (PlotArea area : this.plotAreas) {
if (hash == area.worldhash) { if (hash == area.getWorldHash()) {
if (area.contains(location.getX(), location.getZ()) && ( if (area.contains(location.getX(), location.getZ()) && (
!this.plotAreaHasCollision || world.equals(area.worldname))) { !this.plotAreaHasCollision || world.equals(area.getWorldName()))) {
return area; return area;
} }
} }

View File

@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld; import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotLoc; import com.github.intellectualsites.plotsquared.plot.object.PlotLoc;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
@ -30,8 +31,8 @@ public class SinglePlotArea extends GridPlotWorld {
public SinglePlotArea() { public SinglePlotArea() {
super("*", null, new SingleWorldGenerator(), null, null); super("*", null, new SingleWorldGenerator(), null, null);
this.ALLOW_SIGNS = false; this.setAllowSigns(false);
this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE); this.setDefaultHome(new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE));
} }
@NotNull @Override protected PlotManager createManager() { @NotNull @Override protected PlotManager createManager() {
@ -54,8 +55,8 @@ public class SinglePlotArea extends GridPlotWorld {
SetupObject setup = new SetupObject(); SetupObject setup = new SetupObject();
setup.plotManager = "PlotSquared:single"; setup.plotManager = "PlotSquared:single";
setup.setupGenerator = "PlotSquared:single"; setup.setupGenerator = "PlotSquared:single";
setup.type = TYPE; setup.type = getType();
setup.terrain = TERRAIN; setup.terrain = getTerrain();
setup.step = new ConfigurationNode[0]; setup.step = new ConfigurationNode[0];
setup.world = worldName; setup.world = worldName;
@ -69,7 +70,7 @@ public class SinglePlotArea extends GridPlotWorld {
} }
} }
// Duplicate 0;0 // Duplicate 0;0
if (setup.type != 0) { if (setup.type != PlotAreaType.NORMAL) {
if (!destination.exists()) { if (!destination.exists()) {
File src = new File(container, "0.0"); File src = new File(container, "0.0");
if (src.exists()) { if (src.exists()) {

View File

@ -1,5 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.util; package com.github.intellectualsites.plotsquared.plot.util;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.Like; import com.github.intellectualsites.plotsquared.plot.commands.Like;
import com.github.intellectualsites.plotsquared.plot.config.Caption; import com.github.intellectualsites.plotsquared.plot.config.Caption;
@ -15,6 +16,8 @@ import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@ -49,8 +52,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
@ -224,10 +231,10 @@ public class MainUtil {
* @return true if any changes were made * @return true if any changes were made
*/ */
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) { public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
BiomeType biome = area.PLOT_BIOME; BiomeType biome = area.getPlotBiome();
if (!Objects.equals(WorldUtil.IMP.getBiome(area.worldname, (pos1.getX() + pos2.getX()) / 2, if (!Objects.equals(WorldUtil.IMP.getBiome(area.getWorldName(), (pos1.getX() + pos2.getX()) / 2,
(pos1.getZ() + pos2.getZ()) / 2), biome)) { (pos1.getZ() + pos2.getZ()) / 2), biome)) {
MainUtil.setBiome(area.worldname, pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(), MainUtil.setBiome(area.getWorldName(), pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(),
biome); biome);
return true; return true;
} }
@ -802,8 +809,8 @@ public class MainUtil {
boolean build = plot.isAdded(player.getUUID()); boolean build = plot.isAdded(player.getUUID());
String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners()); String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
if (plot.getArea() != null) { if (plot.getArea() != null) {
info = info.replace("%area%", plot.getArea().worldname + info = info.replace("%area%", plot.getArea().getWorldName() +
(plot.getArea().id == null ? "" : "(" + plot.getArea().id + ")")); (plot.getArea().getId() == null ? "" : "(" + plot.getArea().getId() + ")"));
} else { } else {
info = info.replace("%area%", Captions.NONE.getTranslated()); info = info.replace("%area%", Captions.NONE.getTranslated());
} }
@ -912,4 +919,32 @@ public class MainUtil {
}); });
} }
} }
private static <T> T getValueFromConfig(ConfigurationSection config, String path,
IntFunction<Optional<T>> intParser,
Function<String, Optional<T>> textualParser,
Supplier<T> defaultValue) {
String value = config.getString(path);
if (value == null) {
return defaultValue.get();
}
if (MathMan.isInteger(value)) {
return intParser.apply(Integer.parseInt(value)).orElseGet(defaultValue);
}
return textualParser.apply(value).orElseGet(defaultValue);
}
public static PlotAreaType getType(ConfigurationSection config) {
return getValueFromConfig(config, "generator.type",
PlotAreaType::fromLegacyInt,
PlotAreaType::fromString,
() -> PlotAreaType.NORMAL);
}
public static PlotAreaTerrainType getTerrain(ConfigurationSection config) {
return getValueFromConfig(config, "generator.terrain",
PlotAreaTerrainType::fromLegacyInt,
PlotAreaTerrainType::fromString,
() -> PlotAreaTerrainType.NONE);
}
} }

View File

@ -15,6 +15,7 @@ import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage; import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@ -221,7 +222,7 @@ public class ExpireManager {
// Run applicable non confirming tasks // Run applicable non confirming tasks
for (int i = 0; i < applicable.size(); i++) { for (int i = 0; i < applicable.size(); i++) {
ExpiryTask expiryTask = applicable.poll(); ExpiryTask expiryTask = applicable.poll();
if (!expiryTask.needsAnalysis() || plot.getArea().TYPE != 0) { if (!expiryTask.needsAnalysis() || plot.getArea().getType() != PlotAreaType.NORMAL) {
if (!expiryTask.requiresConfirmation()) { if (!expiryTask.requiresConfirmation()) {
return Collections.singletonList(expiryTask); return Collections.singletonList(expiryTask);
} }
@ -231,7 +232,7 @@ public class ExpireManager {
// Run applicable confirming tasks // Run applicable confirming tasks
for (int i = 0; i < applicable.size(); i++) { for (int i = 0; i < applicable.size(); i++) {
ExpiryTask expiryTask = applicable.poll(); ExpiryTask expiryTask = applicable.poll();
if (!expiryTask.needsAnalysis() || plot.getArea().TYPE != 0) { if (!expiryTask.needsAnalysis() || plot.getArea().getType() != PlotAreaType.NORMAL) {
return Collections.singletonList(expiryTask); return Collections.singletonList(expiryTask);
} }
applicable.add(expiryTask); applicable.add(expiryTask);

View File

@ -26,7 +26,7 @@ public class ExpiryTask {
} }
public boolean allowsArea(PlotArea area) { public boolean allowsArea(PlotArea area) {
return settings.WORLDS.contains(area.toString()) || settings.WORLDS.contains(area.worldname) return settings.WORLDS.contains(area.toString()) || settings.WORLDS.contains(area.getWorldName())
|| settings.WORLDS.contains("*"); || settings.WORLDS.contains("*");
} }

View File

@ -185,7 +185,7 @@ public final class NukkitMain extends PluginBase implements Listener, IPlotMain
@Override public void run() { @Override public void run() {
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() { PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@Override public void run(PlotArea plotArea) { @Override public void run(PlotArea plotArea) {
Level world = getServer().getLevelByName(plotArea.worldname); Level world = getServer().getLevelByName(plotArea.getWorldName());
try { try {
if (world == null) { if (world == null) {
return; return;

View File

@ -85,7 +85,7 @@ public class NukkitPlotGenerator extends Generator implements GeneratorWrapper<G
} }
@Override public void augment(PlotArea area) { @Override public void augment(PlotArea area) {
NukkitAugmentedGenerator.get(NukkitUtil.getWorld(area.worldname)); NukkitAugmentedGenerator.get(NukkitUtil.getWorld(area.getWorldName()));
} }
@Override public boolean isFull() { @Override public boolean isFull() {

View File

@ -66,7 +66,7 @@ public class NukkitEventUtil extends EventUtil {
} }
@Override public boolean callUnlink(PlotArea area, ArrayList<PlotId> plots) { @Override public boolean callUnlink(PlotArea area, ArrayList<PlotId> plots) {
return callEvent(new PlotUnlinkEvent(NukkitUtil.getWorld(area.worldname), area, plots)); return callEvent(new PlotUnlinkEvent(NukkitUtil.getWorld(area.getWorldName()), area, plots));
} }
@Override public void callEntry(PlotPlayer player, Plot plot) { @Override public void callEntry(PlotPlayer player, Plot plot) {

View File

@ -155,7 +155,7 @@ public class NukkitSetupUtils extends SetupUtils {
if (SetupUtils.generators.isEmpty()) { if (SetupUtils.generators.isEmpty()) {
updateGenerators(); updateGenerators();
} }
Level world = NukkitUtil.getWorld(plotArea.worldname); Level world = NukkitUtil.getWorld(plotArea.getWorldName());
if (world == null) { if (world == null) {
return null; return null;
} }

View File

@ -106,7 +106,7 @@ public class SpongePlotGenerator
} }
@Override public void augment(PlotArea area) { @Override public void augment(PlotArea area) {
SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.worldname)); SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.getWorldName()));
} }
@Override public boolean isFull() { @Override public boolean isFull() {

View File

@ -85,7 +85,7 @@ public class SpongeTerrainGen
} }
@Override public void augment(PlotArea area) { @Override public void augment(PlotArea area) {
SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.worldname)); SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.getWorldName()));
} }
@Override public boolean isFull() { @Override public boolean isFull() {

View File

@ -56,7 +56,7 @@ public class SpongeEventUtil extends EventUtil {
} }
@Override public boolean callUnlink(PlotArea area, ArrayList<PlotId> plots) { @Override public boolean callUnlink(PlotArea area, ArrayList<PlotId> plots) {
return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(area.worldname), plots)); return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(area.getWorldName()), plots));
} }
@Override public void callEntry(PlotPlayer player, Plot plot) { @Override public void callEntry(PlotPlayer player, Plot plot) {

View File

@ -59,7 +59,7 @@ public class SpongeSetupUtils extends SetupUtils {
if (SetupUtils.generators.isEmpty()) { if (SetupUtils.generators.isEmpty()) {
updateGenerators(); updateGenerators();
} }
World world = SpongeUtil.getWorld(plotArea.worldname); World world = SpongeUtil.getWorld(plotArea.getWorldName());
if (world == null) { if (world == null) {
return null; return null;
} }