diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
index 115b01944..f29a4f0ee 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
@@ -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.object.Plot;
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.PlotPlayer;
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() {
PlotSquared.log(Captions.PREFIX + "KillAllEntities started.");
TaskManager.runTaskRepeat(() -> PlotSquared.get().forEachPlotArea(plotArea -> {
- final World world = Bukkit.getWorld(plotArea.worldname);
+ final World world = Bukkit.getWorld(plotArea.getWorldName());
try {
if (world == null) {
return;
@@ -728,8 +730,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
SetupObject setup = new SetupObject();
setup.plotManager = manager;
setup.setupGenerator = worldConfig.getString("generator.init", manager);
- setup.type = worldConfig.getInt("generator.type");
- setup.terrain = worldConfig.getInt("generator.terrain");
+ setup.type = MainUtil.getType(worldConfig);
+ setup.terrain = MainUtil.getTerrain(worldConfig);
setup.step = new ConfigurationNode[0];
setup.world = worldName;
SetupUtils.manager.setupWorld(setup);
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java
index ffa585ff6..2c921c01f 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java
@@ -63,7 +63,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
}
@Override public void augment(PlotArea area) {
- BukkitAugmentedGenerator.get(BukkitUtil.getWorld(area.worldname));
+ BukkitAugmentedGenerator.get(BukkitUtil.getWorld(area.getWorldName()));
}
@Override public boolean isFull() {
@@ -88,8 +88,8 @@ public class BukkitPlotGenerator extends ChunkGenerator
Set areas = PlotSquared.get().getPlotAreas(name);
if (!areas.isEmpty()) {
PlotArea area = areas.iterator().next();
- if (!area.MOB_SPAWNING) {
- if (!area.SPAWN_EGGS) {
+ if (!area.isMobSpawning()) {
+ if (!area.isSpawnEggs()) {
world.setSpawnFlags(false, false);
}
world.setAmbientSpawnLimit(0);
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/PlotBlockPopulator.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/PlotBlockPopulator.java
index 2af7b7e45..2a0455edc 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/PlotBlockPopulator.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/PlotBlockPopulator.java
@@ -28,7 +28,7 @@ final class BlockStatePopulator extends BlockPopulator {
this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
}
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);
if (this.plotGenerator.populateChunk(chunk, area)) {
this.queue.flush();
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java
index b55aa0245..0c5ce4fd3 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java
@@ -101,7 +101,7 @@ public class EntitySpawnListener implements Listener {
}
Plot plot = location.getOwnedPlotAbs();
if (plot == null) {
- if (!area.MOB_SPAWNING) {
+ if (!area.isMobSpawning()) {
EntityType type = entity.getType();
switch (type) {
case DROPPED_ITEM:
@@ -112,7 +112,7 @@ public class EntitySpawnListener implements Listener {
case PLAYER:
return;
}
- if (type.isAlive() || !area.MISC_SPAWN_UNOWNED) {
+ if (type.isAlive() || !area.isMiscSpawnUnowned()) {
event.setCancelled(true);
}
}
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java
index c3f04a5e2..291c574ed 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java
@@ -996,7 +996,7 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea();
- if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) {
+ if (area == null || (area.isPlotChat() == plotPlayer.getAttribute("chat"))) {
return;
}
Plot plot = area.getPlot(location);
@@ -1064,12 +1064,12 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
} else if (
- (location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT)
+ (location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight())
&& !Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
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 (!Permissions
@@ -2094,7 +2094,7 @@ public class PlayerEvents extends PlotListener implements Listener {
case EGG:
case OCELOT_BABY:
case SPAWNER_EGG:
- if (!area.SPAWN_EGGS) {
+ if (!area.isSpawnEggs()) {
event.setCancelled(true);
return;
}
@@ -2102,12 +2102,12 @@ public class PlayerEvents extends PlotListener implements Listener {
case REINFORCEMENTS:
case NATURAL:
case CHUNK_GEN:
- if (!area.MOB_SPAWNING) {
+ if (!area.isMobSpawning()) {
event.setCancelled(true);
return;
}
case BREEDING:
- if (!area.SPAWN_BREEDING) {
+ if (!area.isSpawnBreeding()) {
event.setCancelled(true);
return;
}
@@ -2116,13 +2116,13 @@ public class PlayerEvents extends PlotListener implements Listener {
case BUILD_SNOWMAN:
case BUILD_WITHER:
case CUSTOM:
- if (!area.SPAWN_CUSTOM && entity.getType() != EntityType.ARMOR_STAND) {
+ if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) {
event.setCancelled(true);
return;
}
break;
case SPAWNER:
- if (!area.MOB_SPAWNER_SPAWNING) {
+ if (!area.isMobSpawnerSpawning()) {
event.setCancelled(true);
return;
}
@@ -2130,7 +2130,7 @@ public class PlayerEvents extends PlotListener implements Listener {
}
Plot plot = area.getOwnedPlotAbs(location);
if (plot == null) {
- if (!area.MOB_SPAWNING) {
+ if (!area.isMobSpawning()) {
event.setCancelled(true);
}
return;
@@ -2928,11 +2928,11 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location);
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)) {
event.setCancelled(true);
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 (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java
index fe801a15f..93a381fe4 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java
@@ -128,7 +128,7 @@ public class BukkitChunkManager extends ChunkManager {
return existing;
}
PlotArea area = plot.getArea();
- World world = BukkitUtil.getWorld(area.worldname);
+ World world = BukkitUtil.getWorld(area.getWorldName());
Location bot = plot.getBottomAbs();
Location top = plot.getTopAbs();
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitSetupUtils.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitSetupUtils.java
index 59be5f5e7..bd8b287ad 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitSetupUtils.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitSetupUtils.java
@@ -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.generator.GeneratorWrapper;
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.util.SetupUtils;
import io.papermc.lib.PaperLib;
@@ -80,10 +81,10 @@ public class BukkitSetupUtils extends SetupUtils {
SetupUtils.manager.updateGenerators();
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
String world = object.world;
- int type = object.type;
+ PlotAreaType type = object.type;
String worldPath = "worlds." + object.world;
switch (type) {
- case 2: {
+ case PARTIAL: {
if (object.id != null) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
@@ -101,8 +102,8 @@ public class BukkitSetupUtils extends SetupUtils {
for (ConfigurationNode step : steps) {
options.put(step.getConstant(), step.getValue());
}
- options.put("generator.type", object.type);
- options.put("generator.terrain", object.terrain);
+ options.put("generator.type", object.type.toString());
+ options.put("generator.terrain", object.terrain.toString());
options.put("generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) {
@@ -127,7 +128,7 @@ public class BukkitSetupUtils extends SetupUtils {
}
break;
}
- case 1: {
+ case AUGMENTED: {
if (!object.plotManager.endsWith(":single")) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
@@ -140,9 +141,9 @@ public class BukkitSetupUtils extends SetupUtils {
}
}
PlotSquared.get().worlds
- .set("worlds." + world + ".generator.type", object.type);
+ .set("worlds." + world + ".generator.type", object.type.toString());
PlotSquared.get().worlds
- .set("worlds." + world + ".generator.terrain", object.terrain);
+ .set("worlds." + world + ".generator.terrain", object.terrain.toString());
PlotSquared.get().worlds
.set("worlds." + world + ".generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
@@ -157,7 +158,7 @@ public class BukkitSetupUtils extends SetupUtils {
}
break;
}
- case 0: {
+ case NORMAL: {
if (steps.length != 0) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
@@ -224,7 +225,7 @@ public class BukkitSetupUtils extends SetupUtils {
if (SetupUtils.generators.isEmpty()) {
updateGenerators();
}
- World world = Bukkit.getWorld(plotArea.worldname);
+ World world = Bukkit.getWorld(plotArea.getWorldName());
if (world == null) {
return null;
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java
index 21d9e1c8f..2e0f5ac86 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java
@@ -405,12 +405,12 @@ import java.util.zip.ZipInputStream;
}
public PlotManager getPlotManager(Plot plot) {
- return plot.getArea().manager;
+ return plot.getArea().getPlotManager();
}
public PlotManager getPlotManager(Location 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) {
HashMap plots;
if (plots_tmp == null || (plots = plots_tmp.remove(plotArea.toString())) == null) {
- if (plotArea.TYPE == 2) {
- plots = this.plots_tmp != null ? this.plots_tmp.get(plotArea.worldname) : null;
+ if (plotArea.getType() == PlotAreaType.PARTIAL) {
+ plots = this.plots_tmp != null ? this.plots_tmp.get(plotArea.getWorldName()) : null;
if (plots != null) {
Iterator> iterator = plots.entrySet().iterator();
while (iterator.hasNext()) {
@@ -443,9 +443,9 @@ import java.util.zip.ZipInputStream;
}
Set clusters;
if (clusters_tmp == null || (clusters = clusters_tmp.remove(plotArea.toString())) == null) {
- if (plotArea.TYPE == 2) {
+ if (plotArea.getType() == PlotAreaType.PARTIAL) {
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) {
Iterator iterator = clusters.iterator();
while (iterator.hasNext()) {
@@ -515,7 +515,7 @@ import java.util.zip.ZipInputStream;
public void removePlotAreas(String world) {
for (PlotArea area : getPlotAreas(world)) {
- if (area.worldname.equals(world)) {
+ if (area.getWorldName().equals(world)) {
removePlotArea(area);
}
}
@@ -1090,13 +1090,13 @@ import java.util.zip.ZipInputStream;
}
String path = "worlds." + world;
ConfigurationSection worldSection = this.worlds.getConfigurationSection(path);
- int type;
+ PlotAreaType type;
if (worldSection != null) {
- type = worldSection.getInt("generator.type", 0);
+ type = MainUtil.getType(worldSection);
} else {
- type = 0;
+ type = PlotAreaType.NORMAL;
}
- if (type == 0) {
+ if (type == PlotAreaType.NORMAL) {
if (plotAreaManager.getPlotAreas(world, null).length != 0) {
debug("World possibly already loaded: " + world);
return;
@@ -1158,7 +1158,7 @@ import java.util.zip.ZipInputStream;
}
PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'");
String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName());
- if (type == 2) {
+ if (type == PlotAreaType.PARTIAL) {
Set clusters =
this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<>();
if (clusters == null) {
@@ -1225,9 +1225,9 @@ import java.util.zip.ZipInputStream;
addPlotArea(pa);
return;
}
- if (type == 1) {
+ if (type == PlotAreaType.AUGMENTED) {
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)) {
PlotSquared.log(Captions.PREFIX + " - " + areaId);
@@ -1244,7 +1244,7 @@ import java.util.zip.ZipInputStream;
+ ". Expected form `--`");
}
PlotArea existing = getPlotArea(world, name);
- if (existing != null && name.equals(existing.id)) {
+ if (existing != null && name.equals(existing.getId())) {
continue;
}
ConfigurationSection section = areasSection.getConfigurationSection(areaId);
@@ -1919,7 +1919,7 @@ import java.util.zip.ZipInputStream;
public boolean isAugmented(@NonNull final String world) {
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);
if (areas == null) {
for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
- if (area.worldname.equalsIgnoreCase(split[0])) {
- if (area.id == null || split.length == 2 && area.id
+ if (area.getWorldName().equalsIgnoreCase(split[0])) {
+ if (area.getId() == null || split.length == 2 && area.getId()
.equalsIgnoreCase(split[1])) {
return area;
}
@@ -1989,7 +1989,7 @@ import java.util.zip.ZipInputStream;
return null;
} else {
for (PlotArea area : areas) {
- if (StringMan.isEqual(split[1], area.id)) {
+ if (StringMan.isEqual(split[1], area.getId())) {
return area;
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java
index 5009017f5..f7d204134 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java
@@ -64,7 +64,7 @@ public class Add extends Command {
size += plot.getTrusted().contains(uuid) ? 0 : 1;
}
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),
Captions.PLOT_MAX_MEMBERS);
// Success
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Area.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Area.java
index 9c4a548f9..92e7b9de6 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Area.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Area.java
@@ -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.object.Location;
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.PlotMessage;
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 CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz);
Set areas =
- PlotSquared.get().getPlotAreas(area.worldname, region);
+ PlotSquared.get().getPlotAreas(area.getWorldName(), region);
if (!areas.isEmpty()) {
Captions.CLUSTER_INTERSECTION
.send(player, areas.iterator().next().toString());
return false;
}
final SetupObject object = new SetupObject();
- object.world = area.worldname;
- object.id = area.id;
- object.terrain = area.TERRAIN;
- object.type = area.TYPE;
+ object.world = area.getWorldName();
+ object.id = area.getId();
+ object.terrain = area.getTerrain();
+ object.type = area.getType();
object.min = new PlotId(1, 1);
object.max = new PlotId(numX, numZ);
object.plotManager = PlotSquared.imp().getPluginName();
object.setupGenerator = PlotSquared.imp().getPluginName();
object.step = area.getSettingNodes();
final String path =
- "worlds." + area.worldname + ".areas." + area.id + '-'
+ "worlds." + area.getWorldName() + ".areas." + area.getId() + '-'
+ object.min + '-' + object.max;
Runnable run = () -> {
if (offsetX != 0) {
@@ -141,7 +143,7 @@ public class Area extends SubCommand {
Captions.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world),
TeleportCause.COMMAND);
- if (area.TERRAIN != 3) {
+ if (area.getTerrain() != PlotAreaTerrainType.ALL) {
ChunkManager.largeRegionTask(world, region,
new RunnableVal() {
@Override public void run(BlockVector2 value) {
@@ -153,7 +155,7 @@ public class Area extends SubCommand {
} else {
MainUtil.sendMessage(player,
"An error occurred while creating the world: "
- + area.worldname);
+ + area.getWorldName());
}
};
if (hasConfirmation(player)) {
@@ -176,15 +178,15 @@ public class Area extends SubCommand {
object.world = split[0];
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id,
PlotSquared.get().IMP.getDefaultGenerator(), null, null);
- PlotArea other = PlotSquared.get().getPlotArea(pa.worldname, id);
- if (other != null && Objects.equals(pa.id, other.id)) {
+ PlotArea other = PlotSquared.get().getPlotArea(pa.getWorldName(), id);
+ if (other != null && Objects.equals(pa.getId(), other.getId())) {
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
return false;
}
- Set areas = PlotSquared.get().getPlotAreas(pa.worldname);
+ Set areas = PlotSquared.get().getPlotAreas(pa.getWorldName());
if (!areas.isEmpty()) {
PlotArea area = areas.iterator().next();
- pa.TYPE = area.TYPE;
+ pa.setType(area.getType());
}
pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH);
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]);
break;
case "terrain":
- pa.TERRAIN = Integer.parseInt(pair[1]);
- object.terrain = pa.TERRAIN;
+ pa.setTerrain(PlotAreaTerrainType.fromString(pair[1]).orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid terrain.")));
+ object.terrain = pa.getTerrain();
break;
case "type":
- pa.TYPE = Integer.parseInt(pair[1]);
- object.type = pa.TYPE;
+ pa.setType(PlotAreaType.fromString(pair[1]).orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid type.")));
+ object.type = pa.getType();
break;
default:
Captions.COMMAND_SYNTAX.send(player, getCommandString()
@@ -243,13 +245,13 @@ public class Area extends SubCommand {
return false;
}
}
- if (pa.TYPE != 2) {
- if (WorldUtil.IMP.isWorld(pa.worldname)) {
- Captions.SETUP_WORLD_TAKEN.send(player, pa.worldname);
+ if (pa.getType() != PlotAreaType.PARTIAL) {
+ if (WorldUtil.IMP.isWorld(pa.getWorldName())) {
+ Captions.SETUP_WORLD_TAKEN.send(player, pa.getWorldName());
return false;
}
Runnable run = () -> {
- String path = "worlds." + pa.worldname;
+ String path = "worlds." + pa.getWorldName();
if (!PlotSquared.get().worlds.contains(path)) {
PlotSquared.get().worlds.createSection(path);
}
@@ -267,7 +269,7 @@ public class Area extends SubCommand {
} else {
MainUtil.sendMessage(player,
"An error occurred while creating the world: "
- + pa.worldname);
+ + pa.getWorldName());
}
try {
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
@@ -283,21 +285,21 @@ public class Area extends SubCommand {
}
return true;
}
- if (pa.id == null) {
+ if (pa.getId() == null) {
Captions.COMMAND_SYNTAX.send(player, getCommandString()
+ " create [world[:id]] [=]...");
return false;
}
- if (WorldUtil.IMP.isWorld(pa.worldname)) {
- if (!player.getLocation().getWorld().equals(pa.worldname)) {
- player.teleport(WorldUtil.IMP.getSpawn(pa.worldname),
+ if (WorldUtil.IMP.isWorld(pa.getWorldName())) {
+ if (!player.getLocation().getWorld().equals(pa.getWorldName())) {
+ player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND);
}
} else {
- object.terrain = 0;
- object.type = 0;
+ object.terrain = PlotAreaTerrainType.NONE;
+ object.type = PlotAreaType.NORMAL;
SetupUtils.manager.setupWorld(object);
- player.teleport(WorldUtil.IMP.getSpawn(pa.worldname),
+ player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND);
}
player.setMeta("area_create_area", pa);
@@ -339,20 +341,20 @@ public class Area extends SubCommand {
int clusters = area.getClusters().size();
String region;
String generator = String.valueOf(area.getGenerator());
- if (area.TYPE == 2) {
+ if (area.getType() == PlotAreaType.PARTIAL) {
PlotId min = area.getMin();
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);
percent = claimed == 0 ? 0 : size / (double) claimed;
region = area.getRegion().toString();
} else {
- name = area.worldname;
+ name = area.getWorldName();
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
region = "N/A";
}
- String value = "&r$1NAME: " + name + "\n$1Type: $2" + area.TYPE + "\n$1Terrain: $2"
- + area.TERRAIN + "\n$1Usage: $2" + String.format("%.2f", percent) + '%'
+ String value = "&r$1NAME: " + name + "\n$1Type: $2" + area.getType() + "\n$1Terrain: $2"
+ + area.getTerrain() + "\n$1Usage: $2" + String.format("%.2f", percent) + '%'
+ "\n$1Claimed: $2" + claimed + "\n$1Clusters: $2" + clusters + "\n$1Region: $2"
+ region + "\n$1Generator: $2" + generator;
MainUtil.sendMessage(player,
@@ -390,15 +392,15 @@ public class Area extends SubCommand {
int clusters = area.getClusters().size();
String region;
String generator = String.valueOf(area.getGenerator());
- if (area.TYPE == 2) {
+ if (area.getType() == PlotAreaType.PARTIAL) {
PlotId min = area.getMin();
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);
percent = claimed == 0 ? 0 : size / (double) claimed;
region = area.getRegion().toString();
} else {
- name = area.worldname;
+ name = area.getWorldName();
percent = claimed == 0 ?
0 :
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(tooltip).command(getCommandString() + " info " + area)
.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());
return true;
@@ -434,16 +436,16 @@ public class Area extends SubCommand {
Captions.NOT_IN_PLOT_WORLD.send(player);
return false;
}
- if (area.TYPE != 2) {
+ if (area.getType() != PlotAreaType.PARTIAL) {
MainUtil.sendMessage(player,
- "$4Stop the server and delete: " + area.worldname + "/region");
+ "$4Stop the server and delete: " + area.getWorldName() + "/region");
return false;
}
- ChunkManager.largeRegionTask(area.worldname, area.getRegion(),
+ ChunkManager.largeRegionTask(area.getWorldName(), area.getRegion(),
new RunnableVal() {
@Override public void run(BlockVector2 value) {
AugmentedUtils
- .generate(area.worldname, value.getX(), value.getZ(), null);
+ .generate(area.getWorldName(), value.getX(), value.getZ(), null);
}
}, () -> player.sendMessage("Regen complete"));
return true;
@@ -467,16 +469,16 @@ public class Area extends SubCommand {
return false;
}
Location center;
- if (area.TYPE != 2) {
- center = WorldUtil.IMP.getSpawn(area.worldname);
+ if (area.getType() != PlotAreaType.PARTIAL) {
+ center = WorldUtil.IMP.getSpawn(area.getWorldName());
} else {
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,
0, region.getMinimumPoint().getZ()
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
center.setY(1 + WorldUtil.IMP
- .getHighestBlock(area.worldname, center.getX(), center.getZ()));
+ .getHighestBlock(area.getWorldName(), center.getX(), center.getZ()));
}
player.teleport(center, TeleportCause.COMMAND);
return true;
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java
index 0f361f861..1d9709e7a 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java
@@ -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.Plot;
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.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@@ -50,7 +51,7 @@ public class Auto extends SubCommand {
if (Settings.Limit.GLOBAL) {
currentPlots = player.getPlotCount();
} else {
- currentPlots = player.getPlotCount(plotarea.worldname);
+ currentPlots = player.getPlotCount(plotarea.getWorldName());
}
int diff = currentPlots - allowedPlots;
if (diff + sizeX * sizeZ > 0) {
@@ -135,7 +136,7 @@ public class Auto extends SubCommand {
if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) {
plot.claim(player, true, schematic, false);
- if (area.AUTO_MERGE) {
+ if (area.isAutoMerge()) {
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
if (event.getEventResult() == Result.DENY) {
@@ -173,7 +174,7 @@ public class Auto extends SubCommand {
if (EconHandler.manager != null) {
for (PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
if (EconHandler.manager
- .hasPermission(area.worldname, player.getName(), "plots.auto")) {
+ .hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
if (plotarea != null) {
plotarea = null;
break;
@@ -249,7 +250,7 @@ public class Auto extends SubCommand {
}
if (schematic != null && !schematic.isEmpty()) {
- if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {
+ if (!plotarea.hasSchematic(schematic)) {
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true;
}
@@ -263,11 +264,11 @@ public class Auto extends SubCommand {
return true;
}
}
- if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
- Expression costExp = plotarea.PRICES.get("claim");
+ if (EconHandler.manager != null && plotarea.useEconomy()) {
+ Expression costExp = plotarea.getPrices().get("claim");
double cost = costExp.evaluate((double) (Settings.Limit.GLOBAL ?
player.getPlotCount() :
- player.getPlotCount(plotarea.worldname)));
+ player.getPlotCount(plotarea.getWorldName())));
cost = (size_x * size_z) * cost;
if (cost > 0d) {
if (!force && EconHandler.manager.getMoney(player) < cost) {
@@ -278,12 +279,12 @@ public class Auto extends SubCommand {
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) {
autoClaimSafe(player, plotarea, null, schematic, allowed_plots);
return true;
} else {
- if (plotarea.TYPE == 2) {
+ if (plotarea.getType() == PlotAreaType.PARTIAL) {
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
return false;
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java
index 371062006..3a17fb183 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java
@@ -61,8 +61,8 @@ public class Claim extends SubCommand {
}
final PlotArea area = plot.getArea();
if (schematic != null && !schematic.isEmpty()) {
- if (area.SCHEMATIC_CLAIM_SPECIFY) {
- if (!area.SCHEMATICS.contains(schematic.toLowerCase())) {
+ if (area.isSchematicClaimSpecify()) {
+ if (!area.hasSchematic(schematic)) {
return sendMessage(player, Captions.SCHEMATIC_INVALID,
"non-existent: " + schematic);
}
@@ -74,8 +74,8 @@ public class Claim extends SubCommand {
}
}
}
- if ((EconHandler.manager != null) && area.USE_ECONOMY && !force) {
- Expression costExr = area.PRICES.get("claim");
+ if ((EconHandler.manager != null) && area.useEconomy() && !force) {
+ Expression costExr = area.getPrices().get("claim");
double cost = costExr.evaluate((double) currentPlots);
if (cost > 0d) {
if (EconHandler.manager.getMoney(player) < cost) {
@@ -102,7 +102,7 @@ public class Claim extends SubCommand {
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal
*/
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) {
- final String world = hybridPlotWorld.worldname;
+ final String world = hybridPlotWorld.getWorldName();
Location pos1 = plot.getBottomAbs();
Location pos2 = plot.getExtendedTopAbs();
// If augmented
final boolean canRegen =
- (hybridPlotWorld.TYPE == 0) && (hybridPlotWorld.TERRAIN == 0) && REGENERATIVE_CLEAR;
+ (hybridPlotWorld.getType() == PlotAreaType.NORMAL)
+ && (hybridPlotWorld.getTerrain() == PlotAreaTerrainType.NONE) && REGENERATIVE_CLEAR;
// The component blocks
final Pattern plotfloor = hybridPlotWorld.TOP_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);
}
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);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal() {
@Override public void run(int[] value) {
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java
index ebcb2620d..362813166 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java
@@ -145,7 +145,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
this.G_SCH = new HashMap<>();
this.G_SCH_B = new HashMap<>();
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");
if (!schematic1File.exists())
schematic1File = new File(root, "sideroad.schematic");
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java
index f5ce01b69..8300fb21a 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java
@@ -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.Plot;
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.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@@ -352,7 +353,7 @@ public abstract class HybridUtils {
return false;
}
HybridUtils.UPDATE = true;
- Set regions = ChunkManager.manager.getChunkChunks(area.worldname);
+ Set regions = ChunkManager.manager.getChunkChunks(area.getWorldName());
return scheduleRoadUpdate(area, regions, extend, new HashSet<>());
}
@@ -384,7 +385,7 @@ public abstract class HybridUtils {
if (!regenedRoad) {
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");
return;
@@ -443,14 +444,14 @@ public abstract class HybridUtils {
BlockVector2 loc = iterator.next();
iterator.remove();
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?)");
int sx = loc.getX() << 5;
int sz = loc.getZ() << 5;
for (int x = sx; x < sx + 32; x++) {
for (int z = sz; z < sz + 32; z++) {
ChunkManager.manager
- .unloadChunk(area.worldname, BlockVector2.at(x, z), true);
+ .unloadChunk(area.getWorldName(), BlockVector2.at(x, z), true);
}
}
PlotSquared.debug(" - Potentially skipping 1024 chunks");
@@ -538,7 +539,7 @@ public abstract class HybridUtils {
return false;
}
AtomicBoolean toCheck = new AtomicBoolean(false);
- if (plotWorld.TYPE == 2) {
+ if (plotWorld.getType() == PlotAreaType.PARTIAL) {
boolean chunk1 = area.contains(x, z);
boolean chunk2 = area.contains(ex, ez);
if (!chunk1 && !chunk2) {
@@ -554,9 +555,9 @@ public abstract class HybridUtils {
z -= plotWorld.ROAD_OFFSET_Z;
final int finalX = x;
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) {
- ChunkManager.manager.loadChunk(area.worldname, chunk, false).thenRun(() -> {
+ ChunkManager.manager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
if (id1 != null) {
Plot p1 = area.getPlotAbs(id1);
if (p1 != null && p1.hasOwner() && p1.isMerged()) {
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/SquarePlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/SquarePlotManager.java
index aab48222d..91442f134 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/SquarePlotManager.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/SquarePlotManager.java
@@ -55,7 +55,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
- return new Location(squarePlotWorld.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) {
@@ -204,7 +204,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
PlotSquared.debug("invalid location: " + Arrays.toString(merged));
} catch (Exception ignored) {
PlotSquared.debug("Invalid plot / road width in settings.yml for world: "
- + squarePlotWorld.worldname);
+ + squarePlotWorld.getWorldName());
}
return null;
}
@@ -221,6 +221,6 @@ public abstract class SquarePlotManager extends GridPlotManager {
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math
.floor(squarePlotWorld.ROAD_WIDTH / 2);
- return new Location(squarePlotWorld.worldname, x, squarePlotWorld.MIN_BUILD_HEIGHT, z);
+ return new Location(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), z);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java
index 0cc4251ed..12f70a40e 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java
@@ -264,14 +264,14 @@ public class PlotListener {
}
if (!plot.getFlag(GamemodeFlag.class).equals(GamemodeFlag.DEFAULT) || !plot
.getFlag(GuestGamemodeFlag.class).equals(GamemodeFlag.DEFAULT)) {
- if (player.getGameMode() != pw.GAMEMODE) {
+ if (player.getGameMode() != pw.getGameMode()) {
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
- player.setGameMode(pw.GAMEMODE);
+ player.setGameMode(pw.getGameMode());
} else {
MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), "{plot}",
plot.toString(), "{gamemode}",
- pw.GAMEMODE.getName().toLowerCase()));
+ pw.getGameMode().getName().toLowerCase()));
}
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEManager.java
index df1db3e2d..42a5eff88 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEManager.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEManager.java
@@ -83,8 +83,8 @@ public class WEManager {
(allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot
.getTrusted().contains(uuid))) && !plot.getFlag(NoWorldeditFlag.class)) {
for (CuboidRegion region : plot.getRegions()) {
- BlockVector3 pos1 = region.getMinimumPoint().withY(area.MIN_BUILD_HEIGHT);
- BlockVector3 pos2 = region.getMaximumPoint().withY(area.MAX_BUILD_HEIGHT);
+ BlockVector3 pos1 = region.getMinimumPoint().withY(area.getMinBuildHeight());
+ BlockVector3 pos2 = region.getMaximumPoint().withY(area.getMaxBuildHeight());
CuboidRegion copy = new CuboidRegion(pos1, pos2);
regions.add(copy);
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java
index a98696c2d..020288d4e 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java
@@ -22,7 +22,7 @@ public class ConsolePlayer extends PlotPlayer {
Location location;
if (area != null) {
CuboidRegion region = area.getRegion();
- location = new Location(area.worldname,
+ location = new Location(area.getWorldName(),
region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0,
region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2);
} else {
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java
index 39f809e0b..4aac2dd11 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java
@@ -280,7 +280,7 @@ public class Plot {
}
public String getWorldName() {
- return area.worldname;
+ return area.getWorldName();
}
/**
@@ -894,7 +894,7 @@ public class Plot {
return;
}
Plot current = queue.poll();
- if (Plot.this.area.TERRAIN != 0) {
+ if (Plot.this.area.getTerrain() != PlotAreaTerrainType.NONE) {
try {
ChunkManager.manager
.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false,
@@ -993,7 +993,7 @@ public class Plot {
if (createRoad) {
manager.startPlotUnlink(ids);
}
- if (this.area.TERRAIN != 3 && createRoad) {
+ if (this.area.getTerrain() != PlotAreaTerrainType.ALL && createRoad) {
for (Plot current : plots) {
if (current.getMerged(Direction.EAST)) {
manager.createRoadEast(current);
@@ -1040,9 +1040,9 @@ public class Plot {
return;
}
PlotManager manager = this.area.getPlotManager();
- if (this.area.ALLOW_SIGNS) {
+ if (this.area.allowSigns()) {
Location location = manager.getSignLoc(this);
- String id = this.id.x + ";" + this.id.y;
+ String id = this.id.toString();
String[] lines =
new String[] {Captions.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id),
Captions.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll(
@@ -1330,7 +1330,7 @@ public class Plot {
return location;
}
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());
}
location.setY(1 + y);
@@ -1344,7 +1344,7 @@ public class Plot {
int z = largest.getMinimumPoint().getZ() - 1;
PlotManager manager = getManager();
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);
}
return new Location(getWorldName(), x, y + 1, z);
@@ -1406,7 +1406,7 @@ public class Plot {
public Location getDefaultHome(boolean member) {
Plot plot = this.getBasePlot(false);
- PlotLoc loc = member ? area.DEFAULT_HOME : area.NONMEMBER_HOME;
+ PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
if (loc != null) {
int x;
int z;
@@ -1541,7 +1541,7 @@ public class Plot {
*/
public void removeSign() {
PlotManager manager = this.area.getPlotManager();
- if (!this.area.ALLOW_SIGNS) {
+ if (!this.area.allowSigns()) {
return;
}
Location location = manager.getSignLoc(this);
@@ -1602,15 +1602,15 @@ public class Plot {
teleportPlayer(player, TeleportCause.COMMAND);
}
PlotArea plotworld = getArea();
- if (plotworld.SCHEMATIC_ON_CLAIM) {
+ if (plotworld.isSchematicOnClaim()) {
Schematic sch;
try {
if (schematic == null || schematic.isEmpty()) {
- sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
+ sch = SchematicHandler.manager.getSchematic(plotworld.getSchematicFile());
} else {
sch = SchematicHandler.manager.getSchematic(schematic);
if (sch == null) {
- sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
+ sch = SchematicHandler.manager.getSchematic(plotworld.getSchematicFile());
}
}
} catch (SchematicHandler.UnsupportedFormatException e) {
@@ -1663,7 +1663,7 @@ public class Plot {
if (this.area.addPlot(this)) {
DBFunc.createPlotAndSettings(this, () -> {
PlotArea plotworld = Plot.this.area;
- if (notify && plotworld.AUTO_MERGE) {
+ if (notify && plotworld.isAutoMerge()) {
PlotPlayer player = WorldUtil.IMP.wrapPlayer(uuid);
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
@@ -1846,17 +1846,14 @@ public class Plot {
* - Used when a plot is merged
*/
public void removeRoadEast() {
- if (this.area.TYPE != 0 && this.area.TERRAIN > 1) {
- if (this.area.TERRAIN == 3) {
- return;
- }
+ if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
Plot other = this.getRelative(Direction.EAST);
Location bot = other.getBottomAbs();
Location top = this.getTopAbs();
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
Location pos2 = new Location(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
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);
}
}
@@ -2228,7 +2225,7 @@ public class Plot {
if (this.hasOwner()) {
return this.owner;
}
- if (!this.area.ALLOW_SIGNS) {
+ if (!this.area.allowSigns()) {
return null;
}
try {
@@ -2291,17 +2288,14 @@ public class Plot {
* - Used when a plot is merged
*/
public void removeRoadSouth() {
- if (this.area.TYPE != 0 && this.area.TERRAIN > 1) {
- if (this.area.TERRAIN == 3) {
- return;
- }
+ if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
Plot other = this.getRelative(Direction.SOUTH);
Location bot = other.getBottomAbs();
Location top = this.getTopAbs();
Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
Location pos2 = new Location(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
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);
}
}
@@ -2470,17 +2464,14 @@ public class Plot {
* Remove the SE road (only effects terrain)
*/
public void removeRoadSouthEast() {
- if (this.area.TYPE != 0 && this.area.TERRAIN > 1) {
- if (this.area.TERRAIN == 3) {
- return;
- }
+ if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
Plot other = this.getRelative(1, 1);
Location pos1 = this.getTopAbs().add(1, 0, 1);
Location pos2 = other.getBottomAbs().subtract(1, 0, 1);
pos1.setY(0);
pos2.setY(MAX_HEIGHT);
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);
}
}
@@ -2884,7 +2875,7 @@ public class Plot {
return false;
}
final Location location;
- if (this.area.HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
+ if (this.area.isHomeAllowNonmember() || plot.isAdded(player.getUUID())) {
location = this.getHome();
} else {
location = this.getDefaultHome(false);
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java
index d2b29170a..6fe608188 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java
@@ -29,7 +29,9 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -51,40 +53,40 @@ import java.util.function.Consumer;
*/
public abstract class PlotArea {
- public final String worldname;
- public final String id;
- @NotNull public final PlotManager manager;
- public final int worldhash;
protected final ConcurrentHashMap 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 max;
- @NotNull private final IndependentPlotGenerator generator;
- public int MAX_PLOT_MEMBERS = 128;
- public boolean AUTO_MERGE = false;
- public boolean ALLOW_SIGNS = true;
- public boolean MISC_SPAWN_UNOWNED = false;
- public boolean MOB_SPAWNING = false;
- public boolean MOB_SPAWNER_SPAWNING = false;
- public BiomeType PLOT_BIOME = BiomeTypes.FOREST;
- public boolean PLOT_CHAT = false;
- public boolean SCHEMATIC_CLAIM_SPECIFY = false;
- public boolean SCHEMATIC_ON_CLAIM = false;
- public String SCHEMATIC_FILE = "null";
- public List SCHEMATICS = null;
- public boolean USE_ECONOMY = false;
- public Map> PRICES = new HashMap<>();
- public boolean SPAWN_EGGS = false;
- public boolean SPAWN_CUSTOM = true;
- public boolean SPAWN_BREEDING = false;
- public boolean WORLD_BORDER = false;
- public int TYPE = 0;
- public int TERRAIN = 0;
- public boolean HOME_ALLOW_NONMEMBER = false;
- public PlotLoc NONMEMBER_HOME;
- public PlotLoc DEFAULT_HOME;
- public int MAX_BUILD_HEIGHT = 256;
- public int MIN_BUILD_HEIGHT = 1;
- public GameMode GAMEMODE = GameModes.CREATIVE;
+ @Getter @NotNull private final IndependentPlotGenerator generator;
+ @Getter private int maxPlotMembers = 128;
+ @Getter private boolean autoMerge = false;
+ @Setter private boolean allowSigns = true;
+ @Getter private boolean miscSpawnUnowned = false;
+ @Getter private boolean mobSpawning = false;
+ @Getter private boolean mobSpawnerSpawning = false;
+ @Getter private BiomeType plotBiome = BiomeTypes.FOREST;
+ @Getter private boolean plotChat = false;
+ @Getter private boolean schematicClaimSpecify = false;
+ @Getter private boolean schematicOnClaim = false;
+ @Getter private String schematicFile = "null";
+ @Getter private boolean spawnEggs = false;
+ @Getter private boolean spawnCustom = true;
+ @Getter private boolean spawnBreeding = false;
+ @Getter private PlotAreaType type = PlotAreaType.NORMAL;
+ @Getter private PlotAreaTerrainType terrain = PlotAreaTerrainType.NONE;
+ @Getter private boolean homeAllowNonmember = false;
+ @Getter private PlotLoc nonmemberHome;
+ @Getter @Setter(AccessLevel.PROTECTED) private PlotLoc defaultHome;
+ @Getter private int maxBuildHeight = 256;
+ @Getter private int minBuildHeight = 1;
+ @Getter private GameMode gameMode = GameModes.CREATIVE;
+ @Getter private Map> prices = new HashMap<>();
+ @Getter(AccessLevel.PROTECTED) private List schematics = new ArrayList<>();
+ private boolean worldBorder = false;
+ private boolean useEconomy = false;
private int hash;
private CuboidRegion region;
private ConcurrentHashMap meta;
@@ -98,9 +100,9 @@ public abstract class PlotArea {
public PlotArea(@NotNull final String worldName, @Nullable final String id,
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
@Nullable final PlotId max) {
- this.worldname = worldName;
+ this.worldName = worldName;
this.id = id;
- this.manager = createManager();
+ this.plotManager = createManager();
this.generator = generator;
if (min == null || max == null) {
if (min != max) {
@@ -113,13 +115,13 @@ public abstract class PlotArea {
this.min = min;
this.max = max;
}
- this.worldhash = worldName.hashCode();
+ this.worldHash = worldName.hashCode();
}
@NotNull protected abstract PlotManager createManager();
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;
}
- /**
- * 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) {
if (this == obj) {
return true;
@@ -191,8 +184,8 @@ public abstract class PlotArea {
return false;
}
PlotArea plotarea = (PlotArea) obj;
- return this.worldhash == plotarea.worldhash && this.worldname.equals(plotarea.worldname)
- && StringMan.isEqual(this.id, plotarea.id);
+ return this.getWorldHash() == plotarea.getWorldHash() && this.getWorldName().equals(plotarea.getWorldName())
+ && StringMan.isEqual(this.getId(), plotarea.getId());
}
public Set getClusters() {
@@ -208,9 +201,9 @@ public abstract class PlotArea {
public boolean isCompatible(PlotArea plotArea) {
ConfigurationSection section = PlotSquared.get().worlds.getConfigurationSection("worlds");
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
- .equals(section.get(this.worldname + '.' + setting.getConstant()))) {
+ .equals(section.get(this.worldName + '.' + setting.getConstant()))) {
return false;
}
}
@@ -227,79 +220,79 @@ public abstract class PlotArea {
throw new IllegalArgumentException("Must extend GridPlotWorld to provide");
}
if (config.contains("generator.terrain")) {
- this.TERRAIN = config.getInt("generator.terrain");
- this.TYPE = config.getInt("generator.type");
+ this.terrain = MainUtil.getTerrain(config);
+ this.type = MainUtil.getType(config);
}
- this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
- this.MISC_SPAWN_UNOWNED = config.getBoolean("misc_spawn_unowned");
- this.MOB_SPAWNER_SPAWNING = config.getBoolean("mob_spawner_spawning");
- this.AUTO_MERGE = config.getBoolean("plot.auto_merge");
- this.MAX_PLOT_MEMBERS = config.getInt("limits.max-members");
- this.ALLOW_SIGNS = config.getBoolean("plot.create_signs");
- this.PLOT_BIOME = Configuration.BIOME.parseString(config.getString("plot.biome"));
- this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim");
- this.SCHEMATIC_FILE = config.getString("schematic.file");
- this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim");
- this.SCHEMATICS = new ArrayList<>(config.getStringList("schematic.schematics"));
- this.SCHEMATICS.replaceAll(String::toLowerCase);
- this.USE_ECONOMY = config.getBoolean("economy.use") && EconHandler.getEconHandler() != null;
+ this.mobSpawning = config.getBoolean("natural_mob_spawning");
+ this.miscSpawnUnowned = config.getBoolean("misc_spawn_unowned");
+ this.mobSpawnerSpawning = config.getBoolean("mob_spawner_spawning");
+ this.autoMerge = config.getBoolean("plot.auto_merge");
+ this.maxPlotMembers = config.getInt("limits.max-members");
+ this.allowSigns = config.getBoolean("plot.create_signs");
+ this.plotBiome = Configuration.BIOME.parseString(config.getString("plot.biome"));
+ this.schematicOnClaim = config.getBoolean("schematic.on_claim");
+ this.schematicFile = config.getString("schematic.file");
+ this.schematicClaimSpecify = config.getBoolean("schematic.specify_on_claim");
+ this.schematics = new ArrayList<>(config.getStringList("schematic.schematics"));
+ this.schematics.replaceAll(String::toLowerCase);
+ this.useEconomy = config.getBoolean("economy.use") && EconHandler.getEconHandler() != null;
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
- if (this.USE_ECONOMY) {
- this.PRICES = new HashMap<>();
+ if (this.useEconomy) {
+ this.prices = new HashMap<>();
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.WORLD_BORDER = config.getBoolean("world.border");
- this.MAX_BUILD_HEIGHT = config.getInt("world.max_height");
- this.MIN_BUILD_HEIGHT = config.getInt("world.min_height");
+ this.plotChat = config.getBoolean("chat.enabled");
+ this.worldBorder = config.getBoolean("world.border");
+ this.maxBuildHeight = config.getInt("world.max_height");
+ this.minBuildHeight = config.getInt("world.min_height");
switch (config.getString("world.gamemode").toLowerCase()) {
case "creative":
case "c":
case "1":
- this.GAMEMODE = GameModes.CREATIVE;
+ this.gameMode = GameModes.CREATIVE;
break;
case "adventure":
case "a":
case "2":
- this.GAMEMODE = GameModes.ADVENTURE;
+ this.gameMode = GameModes.ADVENTURE;
break;
case "spectator":
case "3":
- this.GAMEMODE = GameModes.SPECTATOR;
+ this.gameMode = GameModes.SPECTATOR;
break;
case "survival":
case "s":
case "0":
default:
- this.GAMEMODE = GameModes.SURVIVAL;
+ this.gameMode = GameModes.SURVIVAL;
break;
}
String homeNonMembers = config.getString("home.nonmembers");
String homeDefault = config.getString("home.default");
- this.DEFAULT_HOME = PlotLoc.fromString(homeDefault);
- this.HOME_ALLOW_NONMEMBER = homeNonMembers.equalsIgnoreCase(homeDefault);
- if (this.HOME_ALLOW_NONMEMBER) {
- this.NONMEMBER_HOME = DEFAULT_HOME;
+ this.defaultHome = PlotLoc.fromString(homeDefault);
+ this.homeAllowNonmember = homeNonMembers.equalsIgnoreCase(homeDefault);
+ if (this.homeAllowNonmember) {
+ this.nonmemberHome = defaultHome;
} else {
- this.NONMEMBER_HOME = PlotLoc.fromString(homeNonMembers);
+ this.nonmemberHome = PlotLoc.fromString(homeNonMembers);
}
if ("side".equalsIgnoreCase(homeDefault)) {
- this.DEFAULT_HOME = null;
+ this.defaultHome = null;
} 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 {
try {
/*String[] split = homeDefault.split(",");
this.DEFAULT_HOME =
new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));*/
- this.DEFAULT_HOME = PlotLoc.fromString(homeDefault);
+ this.defaultHome = PlotLoc.fromString(homeDefault);
} catch (NumberFormatException ignored) {
- this.DEFAULT_HOME = null;
+ this.defaultHome = null;
}
}
@@ -321,12 +314,12 @@ public abstract class PlotArea {
this.getFlagContainer().addAll(parseFlags(flags));
} catch (FlagParseException e) {
e.printStackTrace();
- PlotSquared.debug("&cInvalid default flags for " + this.worldname + ": " + StringMan
+ PlotSquared.debug("&cInvalid default flags for " + this.getWorldName() + ": " + StringMan
.join(flags, ","));
}
- this.SPAWN_EGGS = config.getBoolean("event.spawn.egg");
- this.SPAWN_CUSTOM = config.getBoolean("event.spawn.custom");
- this.SPAWN_BREEDING = config.getBoolean("event.spawn.breeding");
+ this.spawnEggs = config.getBoolean("event.spawn.egg");
+ this.spawnCustom = config.getBoolean("event.spawn.custom");
+ this.spawnBreeding = config.getBoolean("event.spawn.breeding");
loadConfiguration(config);
}
@@ -339,40 +332,40 @@ public abstract class PlotArea {
*/
public void saveConfiguration(ConfigurationSection config) {
HashMap options = new HashMap<>();
- options.put("natural_mob_spawning", this.MOB_SPAWNING);
- options.put("misc_spawn_unowned", this.MISC_SPAWN_UNOWNED);
- options.put("mob_spawner_spawning", this.MOB_SPAWNER_SPAWNING);
- options.put("plot.auto_merge", this.AUTO_MERGE);
- options.put("plot.create_signs", this.ALLOW_SIGNS);
+ options.put("natural_mob_spawning", this.isMobSpawning());
+ options.put("misc_spawn_unowned", this.isMiscSpawnUnowned());
+ options.put("mob_spawner_spawning", this.isMobSpawnerSpawning());
+ options.put("plot.auto_merge", this.isAutoMerge());
+ options.put("plot.create_signs", this.allowSigns());
options.put("plot.biome", "FOREST");
- options.put("schematic.on_claim", this.SCHEMATIC_ON_CLAIM);
- options.put("schematic.file", this.SCHEMATIC_FILE);
- options.put("schematic.specify_on_claim", this.SCHEMATIC_CLAIM_SPECIFY);
- options.put("schematic.schematics", this.SCHEMATICS);
- options.put("economy.use", this.USE_ECONOMY);
+ options.put("schematic.on_claim", this.isSchematicOnClaim());
+ options.put("schematic.file", this.getSchematicFile());
+ options.put("schematic.specify_on_claim", this.isSchematicClaimSpecify());
+ options.put("schematic.schematics", this.getSchematics());
+ options.put("economy.use", this.useEconomy());
options.put("economy.prices.claim", 100);
options.put("economy.prices.merge", 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("event.spawn.egg", this.SPAWN_EGGS);
- options.put("event.spawn.custom", this.SPAWN_CUSTOM);
- options.put("event.spawn.breeding", this.SPAWN_BREEDING);
- options.put("world.border", this.WORLD_BORDER);
- options.put("limits.max-members", this.MAX_PLOT_MEMBERS);
+ options.put("event.spawn.egg", this.isSpawnEggs());
+ options.put("event.spawn.custom", this.isSpawnCustom());
+ options.put("event.spawn.breeding", this.isSpawnBreeding());
+ options.put("world.border", this.hasWorldBorder());
+ options.put("limits.max-members", this.getMaxPlotMembers());
options.put("home.default", "side");
String position = config.getString("home.nonmembers",
config.getBoolean("home.allow-nonmembers", false) ?
config.getString("home.default", "side") :
"side");
options.put("home.nonmembers", position);
- options.put("world.max_height", this.MAX_BUILD_HEIGHT);
- options.put("world.min_height", this.MIN_BUILD_HEIGHT);
- options.put("world.gamemode", this.GAMEMODE.getName().toLowerCase());
+ options.put("world.max_height", this.getMaxBuildHeight());
+ options.put("world.min_height", this.getMinBuildHeight());
+ options.put("world.gamemode", this.getGameMode().getName().toLowerCase());
- if (this.TYPE != 0) {
- options.put("generator.terrain", this.TERRAIN);
- options.put("generator.type", this.TYPE);
+ if (this.getType() != PlotAreaType.NORMAL) {
+ options.put("generator.terrain", this.getTerrain());
+ options.put("generator.type", this.getType().toString());
}
ConfigurationNode[] settings = getSettingNodes();
/*
@@ -393,10 +386,10 @@ public abstract class PlotArea {
}
@NotNull @Override public String toString() {
- if (this.id == null) {
- return this.worldname;
+ if (this.getId() == null) {
+ return this.getWorldName();
} 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) {
final PlotId pid =
- this.manager.getPlotId(location.getX(), location.getY(), location.getZ());
+ this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
return null;
}
@@ -437,7 +430,7 @@ public abstract class PlotArea {
*/
@Nullable public Plot getPlot(@NotNull final Location location) {
final PlotId pid =
- this.manager.getPlotId(location.getX(), location.getY(), location.getZ());
+ this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
return null;
}
@@ -452,7 +445,7 @@ public abstract class PlotArea {
*/
@Nullable public Plot getOwnedPlot(@NotNull final Location location) {
final PlotId pid =
- this.manager.getPlotId(location.getX(), location.getY(), location.getZ());
+ this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
return null;
}
@@ -468,7 +461,7 @@ public abstract class PlotArea {
*/
@Nullable public Plot getOwnedPlotAbs(@NotNull final Location location) {
final PlotId pid =
- this.manager.getPlotId(location.getX(), location.getY(), location.getZ());
+ this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
return null;
}
@@ -491,7 +484,7 @@ public abstract class PlotArea {
}
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) {
@@ -500,7 +493,7 @@ public abstract class PlotArea {
}
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()));
}
@@ -552,10 +545,10 @@ public abstract class PlotArea {
}
//todo check if this method is needed in this class
+
public int getPlotCount(@Nullable final PlotPlayer player) {
return player != null ? getPlotCount(player.getUUID()) : 0;
}
-
@Nullable public Plot getPlotAbs(@NotNull final PlotId id) {
Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
@@ -614,10 +607,6 @@ public abstract class PlotArea {
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).
*
@@ -700,7 +689,7 @@ public abstract class PlotArea {
PlotId center;
PlotId min = getMin();
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));
plots = Math.max(max.x - min.x + 1, max.y - min.y + 1) + 1;
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).
*/
public void setupBorder() {
- if (!this.WORLD_BORDER) {
+ if (!this.hasWorldBorder()) {
return;
}
final Integer meta = (Integer) getMeta("worldBorder");
@@ -946,6 +935,63 @@ public abstract class PlotArea {
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> parseFlags(List flagStrings) throws FlagParseException {
final Collection> flags = new ArrayList<>();
for (final String key : flagStrings) {
@@ -962,5 +1008,4 @@ public abstract class PlotArea {
}
return flags;
}
-
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotAreaTerrainType.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotAreaTerrainType.java
new file mode 100644
index 000000000..b78b5a2a9
--- /dev/null
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotAreaTerrainType.java
@@ -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 types = Stream.of(values())
+ .collect(Collectors.toMap(e -> e.toString().toLowerCase(), Function.identity()));
+
+ public static Optional fromString(String typeString) {
+ return Optional.ofNullable(types.get(typeString));
+ }
+
+ @Deprecated
+ public static Optional fromLegacyInt(int typeId) {
+ if (typeId < 0 || typeId >= values().length) {
+ return Optional.empty();
+ }
+ return Optional.of(values()[typeId]);
+ }
+}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotAreaType.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotAreaType.java
new file mode 100644
index 000000000..6f825fcb1
--- /dev/null
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotAreaType.java
@@ -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 types = Stream.of(values())
+ .collect(Collectors.toMap(e -> e.toString().toLowerCase(), Function.identity()));
+
+ public static Optional fromString(String typeName) {
+ return Optional.ofNullable(types.get(typeName.toLowerCase()));
+ }
+
+ @Deprecated
+ public static Optional fromLegacyInt(int typeId) {
+ if (typeId < 0 || typeId >= values().length) {
+ return Optional.empty();
+ }
+ return Optional.of(values()[typeId]);
+ }
+}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotCluster.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotCluster.java
index 4a653d8dd..108439edd 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotCluster.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotCluster.java
@@ -140,7 +140,7 @@ public class PlotCluster {
} else {
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()) {
toReturn.setY(1 + max);
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java
index e0fc16ddb..50678caa7 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java
@@ -84,7 +84,7 @@ public abstract class PlotManager {
HashSet files = new HashSet<>(Collections.singletonList(
new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml",
Template.getBytes(plotArea))));
- Template.zipAll(plotArea.worldname, files);
+ Template.zipAll(plotArea.getWorldName(), files);
}
public int getWorldHeight() {
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/SetupObject.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/SetupObject.java
index e203fa870..2a75539f2 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/SetupObject.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/SetupObject.java
@@ -38,12 +38,12 @@ public class SetupObject {
/**
* The management type (normal, augmented, partial)
*/
- public int type;
+ public PlotAreaType type;
/**
* The terrain type
*/
- public int terrain;
+ public PlotAreaTerrainType terrain;
/**
* Area ID (may be null)
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/DefaultPlotAreaManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/DefaultPlotAreaManager.java
index 64e234381..177fe5c25 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/DefaultPlotAreaManager.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/DefaultPlotAreaManager.java
@@ -49,9 +49,9 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
String world = location.getWorld();
int hash = world.hashCode();
for (PlotArea area : this.plotAreas) {
- if (hash == area.worldhash) {
+ if (hash == area.getWorldHash()) {
if (area.contains(location.getX(), location.getZ()) && (
- !this.plotAreaHasCollision || world.equals(area.worldname))) {
+ !this.plotAreaHasCollision || world.equals(area.getWorldName()))) {
return area;
}
}
@@ -91,20 +91,20 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
@Override public void addPlotArea(PlotArea plotArea) {
HashSet localAreas =
- new HashSet<>(Arrays.asList(getPlotAreas(plotArea.worldname, null)));
+ new HashSet<>(Arrays.asList(getPlotAreas(plotArea.getWorldName(), null)));
HashSet globalAreas = new HashSet<>(Arrays.asList(plotAreas));
localAreas.add(plotArea);
globalAreas.add(plotArea);
this.plotAreas = globalAreas.toArray(new PlotArea[0]);
- this.plotAreaMap.put(plotArea.worldname, localAreas.toArray(new PlotArea[0]));
- QuadMap map = this.plotAreaGrid.get(plotArea.worldname);
+ this.plotAreaMap.put(plotArea.getWorldName(), localAreas.toArray(new PlotArea[0]));
+ QuadMap map = this.plotAreaGrid.get(plotArea.getWorldName());
if (map == null) {
map = new QuadMap(Integer.MAX_VALUE, 0, 0) {
@Override public CuboidRegion getRegion(PlotArea value) {
return value.getRegion();
}
};
- this.plotAreaGrid.put(plotArea.worldname, map);
+ this.plotAreaGrid.put(plotArea.getWorldName(), map);
}
map.add(plotArea);
}
@@ -114,11 +114,11 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
globalAreas.remove(area);
this.plotAreas = globalAreas.toArray(new PlotArea[0]);
if (globalAreas.isEmpty()) {
- this.plotAreaMap.remove(area.worldname);
- this.plotAreaGrid.remove(area.worldname);
+ this.plotAreaMap.remove(area.getWorldName());
+ this.plotAreaGrid.remove(area.getWorldName());
} else {
- this.plotAreaMap.put(area.worldname, globalAreas.toArray(new PlotArea[0]));
- this.plotAreaGrid.get(area.worldname).remove(area);
+ this.plotAreaMap.put(area.getWorldName(), globalAreas.toArray(new PlotArea[0]));
+ this.plotAreaGrid.get(area.getWorldName()).remove(area);
}
}
@@ -133,7 +133,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
return null;
}
for (PlotArea area : areas) {
- if (StringMan.isEqual(id, area.id)) {
+ if (StringMan.isEqual(id, area.getId())) {
return area;
}
}
@@ -161,9 +161,9 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
String world = location.getWorld();
int hash = world.hashCode();
for (PlotArea area : this.plotAreas) {
- if (hash == area.worldhash) {
+ if (hash == area.getWorldHash()) {
if (area.contains(location.getX(), location.getZ()) && (
- !this.plotAreaHasCollision || world.equals(area.worldname))) {
+ !this.plotAreaHasCollision || world.equals(area.getWorldName()))) {
return area;
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java
index ba3003d6b..4fe3b69b4 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java
@@ -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.object.Location;
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.PlotLoc;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
@@ -30,8 +31,8 @@ public class SinglePlotArea extends GridPlotWorld {
public SinglePlotArea() {
super("*", null, new SingleWorldGenerator(), null, null);
- this.ALLOW_SIGNS = false;
- this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ this.setAllowSigns(false);
+ this.setDefaultHome(new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE));
}
@NotNull @Override protected PlotManager createManager() {
@@ -54,8 +55,8 @@ public class SinglePlotArea extends GridPlotWorld {
SetupObject setup = new SetupObject();
setup.plotManager = "PlotSquared:single";
setup.setupGenerator = "PlotSquared:single";
- setup.type = TYPE;
- setup.terrain = TERRAIN;
+ setup.type = getType();
+ setup.terrain = getTerrain();
setup.step = new ConfigurationNode[0];
setup.world = worldName;
@@ -69,7 +70,7 @@ public class SinglePlotArea extends GridPlotWorld {
}
}
// Duplicate 0;0
- if (setup.type != 0) {
+ if (setup.type != PlotAreaType.NORMAL) {
if (!destination.exists()) {
File src = new File(container, "0.0");
if (src.exists()) {
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java
index 1d086dcc0..a8f24ae4b 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java
@@ -1,5 +1,6 @@
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.commands.Like;
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.Plot;
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.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@@ -49,8 +52,12 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
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.IntStream;
@@ -224,10 +231,10 @@ public class MainUtil {
* @return true if any changes were made
*/
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
- BiomeType biome = area.PLOT_BIOME;
- if (!Objects.equals(WorldUtil.IMP.getBiome(area.worldname, (pos1.getX() + pos2.getX()) / 2,
+ BiomeType biome = area.getPlotBiome();
+ if (!Objects.equals(WorldUtil.IMP.getBiome(area.getWorldName(), (pos1.getX() + pos2.getX()) / 2,
(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);
return true;
}
@@ -802,8 +809,8 @@ public class MainUtil {
boolean build = plot.isAdded(player.getUUID());
String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
if (plot.getArea() != null) {
- info = info.replace("%area%", plot.getArea().worldname +
- (plot.getArea().id == null ? "" : "(" + plot.getArea().id + ")"));
+ info = info.replace("%area%", plot.getArea().getWorldName() +
+ (plot.getArea().getId() == null ? "" : "(" + plot.getArea().getId() + ")"));
} else {
info = info.replace("%area%", Captions.NONE.getTranslated());
}
@@ -912,4 +919,32 @@ public class MainUtil {
});
}
}
+
+ private static T getValueFromConfig(ConfigurationSection config, String path,
+ IntFunction> intParser,
+ Function> textualParser,
+ Supplier 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);
+ }
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java
index 359f8324d..28283ce35 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java
@@ -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.Plot;
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.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@@ -221,7 +222,7 @@ public class ExpireManager {
// Run applicable non confirming tasks
for (int i = 0; i < applicable.size(); i++) {
ExpiryTask expiryTask = applicable.poll();
- if (!expiryTask.needsAnalysis() || plot.getArea().TYPE != 0) {
+ if (!expiryTask.needsAnalysis() || plot.getArea().getType() != PlotAreaType.NORMAL) {
if (!expiryTask.requiresConfirmation()) {
return Collections.singletonList(expiryTask);
}
@@ -231,7 +232,7 @@ public class ExpireManager {
// Run applicable confirming tasks
for (int i = 0; i < applicable.size(); i++) {
ExpiryTask expiryTask = applicable.poll();
- if (!expiryTask.needsAnalysis() || plot.getArea().TYPE != 0) {
+ if (!expiryTask.needsAnalysis() || plot.getArea().getType() != PlotAreaType.NORMAL) {
return Collections.singletonList(expiryTask);
}
applicable.add(expiryTask);
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpiryTask.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpiryTask.java
index e959948b4..a4e1e4c82 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpiryTask.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpiryTask.java
@@ -26,7 +26,7 @@ public class ExpiryTask {
}
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("*");
}
diff --git a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/NukkitMain.java b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/NukkitMain.java
index c84a73b67..06106c8ea 100644
--- a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/NukkitMain.java
+++ b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/NukkitMain.java
@@ -185,7 +185,7 @@ public final class NukkitMain extends PluginBase implements Listener, IPlotMain
@Override public void run() {
PlotSquared.get().foreachPlotArea(new RunnableVal() {
@Override public void run(PlotArea plotArea) {
- Level world = getServer().getLevelByName(plotArea.worldname);
+ Level world = getServer().getLevelByName(plotArea.getWorldName());
try {
if (world == null) {
return;
diff --git a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/generator/NukkitPlotGenerator.java b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/generator/NukkitPlotGenerator.java
index d1712993b..caab8b6b0 100644
--- a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/generator/NukkitPlotGenerator.java
+++ b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/generator/NukkitPlotGenerator.java
@@ -85,7 +85,7 @@ public class NukkitPlotGenerator extends Generator implements GeneratorWrapper 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) {
diff --git a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/util/NukkitSetupUtils.java b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/util/NukkitSetupUtils.java
index 9554e4749..979a8fc58 100644
--- a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/util/NukkitSetupUtils.java
+++ b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/util/NukkitSetupUtils.java
@@ -155,7 +155,7 @@ public class NukkitSetupUtils extends SetupUtils {
if (SetupUtils.generators.isEmpty()) {
updateGenerators();
}
- Level world = NukkitUtil.getWorld(plotArea.worldname);
+ Level world = NukkitUtil.getWorld(plotArea.getWorldName());
if (world == null) {
return null;
}
diff --git a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/generator/SpongePlotGenerator.java b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/generator/SpongePlotGenerator.java
index 44796eb71..e6a286bd7 100644
--- a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/generator/SpongePlotGenerator.java
+++ b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/generator/SpongePlotGenerator.java
@@ -106,7 +106,7 @@ public class SpongePlotGenerator
}
@Override public void augment(PlotArea area) {
- SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.worldname));
+ SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.getWorldName()));
}
@Override public boolean isFull() {
diff --git a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/generator/SpongeTerrainGen.java b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/generator/SpongeTerrainGen.java
index 6d0330765..f9d83fda7 100644
--- a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/generator/SpongeTerrainGen.java
+++ b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/generator/SpongeTerrainGen.java
@@ -85,7 +85,7 @@ public class SpongeTerrainGen
}
@Override public void augment(PlotArea area) {
- SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.worldname));
+ SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.getWorldName()));
}
@Override public boolean isFull() {
diff --git a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeEventUtil.java b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeEventUtil.java
index a69f4c431..2f46e6da7 100644
--- a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeEventUtil.java
+++ b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeEventUtil.java
@@ -56,7 +56,7 @@ public class SpongeEventUtil extends EventUtil {
}
@Override public boolean callUnlink(PlotArea area, ArrayList 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) {
diff --git a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeSetupUtils.java b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeSetupUtils.java
index 7a8cfc1a6..c45a04ff7 100644
--- a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeSetupUtils.java
+++ b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeSetupUtils.java
@@ -59,7 +59,7 @@ public class SpongeSetupUtils extends SetupUtils {
if (SetupUtils.generators.isEmpty()) {
updateGenerators();
}
- World world = SpongeUtil.getWorld(plotArea.worldname);
+ World world = SpongeUtil.getWorld(plotArea.getWorldName());
if (world == null) {
return null;
}