Encapsulation and Magic Values (#2711)

* Encapsulate attributes of PlotArea using lombok Getters/Setters

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

* Better naming for some boolean attributes

* Replace magic type value with PlotAreaType enum

* Replace magic terrain value with PlotAreaTerrainType enum

* Fix remaining rebase conflicts

* Reduce code duplication

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

View File

@ -39,6 +39,8 @@ import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.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);

View File

@ -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<PlotArea> 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);

View File

@ -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();

View File

@ -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);
}
}

View File

@ -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)) {

View File

@ -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();

View File

@ -7,6 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.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;
}

View File

@ -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<PlotId, Plot> 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<Entry<PlotId, Plot>> iterator = plots.entrySet().iterator();
while (iterator.hasNext()) {
@ -443,9 +443,9 @@ import java.util.zip.ZipInputStream;
}
Set<PlotCluster> 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<PlotCluster> 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<PlotCluster> 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 `<name>-<x1;z1>-<x2;z2>`");
}
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;
}
}

View File

@ -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

View File

@ -9,6 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils;
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.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<PlotArea> 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<BlockVector2>() {
@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<PlotArea> areas = PlotSquared.get().getPlotAreas(pa.worldname);
Set<PlotArea> 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]] [<modifier>=<value>]...");
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<BlockVector2>() {
@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;

View File

@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Direction;
import com.github.intellectualsites.plotsquared.plot.object.Expression;
import com.github.intellectualsites.plotsquared.plot.object.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<Double> costExp = plotarea.PRICES.get("claim");
if (EconHandler.manager != null && plotarea.useEconomy()) {
Expression<Double> 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;
}

View File

@ -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<Double> costExr = area.PRICES.get("claim");
if ((EconHandler.manager != null) && area.useEconomy() && !force) {
Expression<Double> 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<Object>() {
@Override public void run(Object value) {
plot.claim(player, true, finalSchematic);
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) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,6 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
@ -42,7 +44,7 @@ public class HybridPlotManager extends ClassicPlotManager {
new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml",
Template.getBytes(hybridPlotWorld)));
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator
+ hybridPlotWorld.worldname + File.separator;
+ hybridPlotWorld.getWorldName() + File.separator;
try {
File sideRoad =
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem");
@ -65,7 +67,7 @@ public class HybridPlotManager extends ClassicPlotManager {
} catch (IOException e) {
e.printStackTrace();
}
Template.zipAll(hybridPlotWorld.worldname, files);
Template.zipAll(hybridPlotWorld.getWorldName(), files);
}
@Override public boolean createRoadEast(Plot plot) {
@ -74,9 +76,9 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x + 1, id.y);
Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id);
Location pos1 = new Location(hybridPlotWorld.worldname, top.getX() + 1, 0, bot.getZ() - 1);
Location pos1 = new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
Location pos2 =
new Location(hybridPlotWorld.worldname, bot.getX(), Math.min(getWorldHeight(), 255),
new Location(hybridPlotWorld.getWorldName(), bot.getX(), Math.min(getWorldHeight(), 255),
top.getZ() + 1);
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@ -134,9 +136,9 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x, id.y + 1);
Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id);
Location pos1 = new Location(hybridPlotWorld.worldname, bot.getX() - 1, 0, top.getZ() + 1);
Location pos1 = new Location(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
Location pos2 =
new Location(hybridPlotWorld.worldname, top.getX() + 1, Math.min(getWorldHeight(), 255),
new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, Math.min(getWorldHeight(), 255),
bot.getZ());
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@ -172,12 +174,13 @@ public class HybridPlotManager extends ClassicPlotManager {
* </p>
*/
@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<int[]>() {
@Override public void run(int[] value) {

View File

@ -145,7 +145,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
this.G_SCH = new HashMap<>();
this.G_SCH_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");

View File

@ -11,6 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.listener.WEExtent;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.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<BlockVector2> regions = ChunkManager.manager.getChunkChunks(area.worldname);
Set<BlockVector2> 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()) {

View File

@ -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);
}
}

View File

@ -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()));
}
}
}

View File

@ -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);
}

View File

@ -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 {

View File

@ -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<br>
*/
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<br>
*/
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);

View File

@ -29,7 +29,9 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.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<PlotId, Plot> plots = new ConcurrentHashMap<>();
@Getter @NotNull private final String worldName;
@Getter private final String id;
@Getter @NotNull private final PlotManager plotManager;
@Getter private final int worldHash;
private final PlotId min;
private final PlotId 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<String> SCHEMATICS = null;
public boolean USE_ECONOMY = false;
public Map<String, Expression<Double>> 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<String, Expression<Double>> prices = new HashMap<>();
@Getter(AccessLevel.PROTECTED) private List<String> schematics = new ArrayList<>();
private boolean worldBorder = false;
private boolean useEconomy = false;
private int hash;
private CuboidRegion region;
private ConcurrentHashMap<String, Object> 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<PlotCluster> 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<String, Object> 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).
* <br>
@ -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<PlotFlag<?, ?>> parseFlags(List<String> flagStrings) throws FlagParseException {
final Collection<PlotFlag<?, ?>> flags = new ArrayList<>();
for (final String key : flagStrings) {
@ -962,5 +1008,4 @@ public abstract class PlotArea {
}
return flags;
}
}

View File

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

View File

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

View File

@ -140,7 +140,7 @@ public class PlotCluster {
} else {
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);
}

View File

@ -84,7 +84,7 @@ public abstract class PlotManager {
HashSet<FileBytes> 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() {

View File

@ -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)

View File

@ -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<PlotArea> localAreas =
new HashSet<>(Arrays.asList(getPlotAreas(plotArea.worldname, null)));
new HashSet<>(Arrays.asList(getPlotAreas(plotArea.getWorldName(), null)));
HashSet<PlotArea> globalAreas = new HashSet<>(Arrays.asList(plotAreas));
localAreas.add(plotArea);
globalAreas.add(plotArea);
this.plotAreas = globalAreas.toArray(new PlotArea[0]);
this.plotAreaMap.put(plotArea.worldname, localAreas.toArray(new PlotArea[0]));
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname);
this.plotAreaMap.put(plotArea.getWorldName(), localAreas.toArray(new PlotArea[0]));
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.getWorldName());
if (map == null) {
map = new QuadMap<PlotArea>(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;
}
}

View File

@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.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()) {

View File

@ -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> T getValueFromConfig(ConfigurationSection config, String path,
IntFunction<Optional<T>> intParser,
Function<String, Optional<T>> textualParser,
Supplier<T> defaultValue) {
String value = config.getString(path);
if (value == null) {
return defaultValue.get();
}
if (MathMan.isInteger(value)) {
return intParser.apply(Integer.parseInt(value)).orElseGet(defaultValue);
}
return textualParser.apply(value).orElseGet(defaultValue);
}
public static PlotAreaType getType(ConfigurationSection config) {
return getValueFromConfig(config, "generator.type",
PlotAreaType::fromLegacyInt,
PlotAreaType::fromString,
() -> PlotAreaType.NORMAL);
}
public static PlotAreaTerrainType getTerrain(ConfigurationSection config) {
return getValueFromConfig(config, "generator.terrain",
PlotAreaTerrainType::fromLegacyInt,
PlotAreaTerrainType::fromString,
() -> PlotAreaTerrainType.NONE);
}
}

View File

@ -15,6 +15,7 @@ import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.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);

View File

@ -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("*");
}

View File

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

View File

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

View File

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

View File

@ -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;
}

View File

@ -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() {

View File

@ -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() {

View File

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

View File

@ -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;
}