diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 95430d7fa..24b7b15a0 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -86,5 +86,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 35eb1ddfb..e22b24b47 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,5 +1,10 @@
+
+
+
+
+
diff --git a/build.gradle.kts b/build.gradle.kts
index 80d8dc58c..abd4a14a1 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -48,10 +48,10 @@ dependencies {
implementation("io.papermc:paperlib:1.0.5")
// Jackson
- implementation("com.fasterxml.jackson.core:jackson-core:2.12+")
- implementation("com.fasterxml.jackson.core:jackson-annotations:2.12+")
- implementation("com.fasterxml.jackson.core:jackson-databind:2.12+")
- implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12+")
+ implementation("com.fasterxml.jackson.core:jackson-core:2.11+")
+ implementation("com.fasterxml.jackson.core:jackson-annotations:2.11+")
+ implementation("com.fasterxml.jackson.core:jackson-databind:2.11+")
+ implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11+")
// Spigot mc API. Provided by spigot.
compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
diff --git a/src/main/java/com/dfsek/terra/config/TerraConfig.java b/src/main/java/com/dfsek/terra/config/TerraConfig.java
index d11e45ae2..ba47f4812 100644
--- a/src/main/java/com/dfsek/terra/config/TerraConfig.java
+++ b/src/main/java/com/dfsek/terra/config/TerraConfig.java
@@ -12,9 +12,9 @@ import java.io.InputStreamReader;
@SuppressWarnings("unused")
public abstract class TerraConfig {
- protected final String id;
+ protected final YamlConfiguration yaml;
private final ConfigPack config;
- private final YamlConfiguration yaml;
+ protected String id;
/**
* Constructs a new Terra config with a file, config pack and Id.
@@ -27,8 +27,8 @@ public abstract class TerraConfig {
* @deprecated Deprecated because you should use {@link #TerraConfig(InputStream, ConfigPack, String)}
*/
@Deprecated
- public TerraConfig(File file, ConfigPack config, String id) throws IOException, InvalidConfigurationException {
- this(new FileInputStream(file), config, id);
+ public TerraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
+ this(new FileInputStream(file), config);
}
/**
@@ -40,11 +40,14 @@ public abstract class TerraConfig {
* @throws IOException
* @throws InvalidConfigurationException
*/
- public TerraConfig(InputStream stream, ConfigPack config, String id) throws IOException, InvalidConfigurationException {
+ public TerraConfig(InputStream stream, ConfigPack config) throws IOException, InvalidConfigurationException {
yaml = new YamlConfiguration();
yaml.load(new InputStreamReader(stream));
this.config = config;
- this.id = id;
+ }
+
+ public YamlConfiguration getYaml() {
+ return yaml;
}
public ConfigPack getConfig() {
diff --git a/src/main/java/com/dfsek/terra/config/deserealized/Carver.java b/src/main/java/com/dfsek/terra/config/deserealized/Carver.java
new file mode 100644
index 000000000..c82f87555
--- /dev/null
+++ b/src/main/java/com/dfsek/terra/config/deserealized/Carver.java
@@ -0,0 +1,43 @@
+package com.dfsek.terra.config.deserealized;
+
+import com.dfsek.terra.carving.UserDefinedCarver;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.block.data.BlockData;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.polydev.gaea.math.ProbabilityCollection;
+
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+public class Carver implements Generateable {
+ private UserDefinedCarver carver;
+ private String id;
+ private Set update;
+ private Map> shift;
+ private Map> inner;
+ private Map> outer;
+ private Map> top;
+ private Map> bottom;
+ private boolean updateOcean;
+ private boolean replaceIsBlacklistInner;
+ private boolean replaceIsBlacklistOuter;
+ private boolean replaceIsBlacklistTop;
+ private boolean replaceIsBlacklistBottom;
+ private Set replaceableInner;
+ private Set replaceableOuter;
+ private Set replaceableTop;
+ private Set replaceableBottom;
+
+ @Override
+ public void generate(Location location, Random random, JavaPlugin plugin) {
+ //TODO
+ }
+
+ @Override
+ public boolean isValidLocation(Location location, JavaPlugin plugin) {
+ return false;
+ //TODO
+ }
+}
diff --git a/src/main/java/com/dfsek/terra/generation/entities/Flora.java b/src/main/java/com/dfsek/terra/config/deserealized/Flora.java
similarity index 94%
rename from src/main/java/com/dfsek/terra/generation/entities/Flora.java
rename to src/main/java/com/dfsek/terra/config/deserealized/Flora.java
index 3bb850014..fa837f227 100644
--- a/src/main/java/com/dfsek/terra/generation/entities/Flora.java
+++ b/src/main/java/com/dfsek/terra/config/deserealized/Flora.java
@@ -1,6 +1,5 @@
-package com.dfsek.terra.generation.entities;
+package com.dfsek.terra.config.deserealized;
-import com.dfsek.terra.generation.deserelized.GenerationEntity;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -16,14 +15,12 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
-public class Flora implements GenerationEntity, org.polydev.gaea.world.Flora {
+public class Flora implements Generateable, org.polydev.gaea.world.Flora {
private final Palette floraPalette;
private final String id;
private final boolean physics;
private final boolean ceiling;
-
private final Set irrigable;
-
private final Set spawnable;
private final Set replaceable;
diff --git a/src/main/java/com/dfsek/terra/generation/deserelized/GenerationEntity.java b/src/main/java/com/dfsek/terra/config/deserealized/Generateable.java
similarity index 76%
rename from src/main/java/com/dfsek/terra/generation/deserelized/GenerationEntity.java
rename to src/main/java/com/dfsek/terra/config/deserealized/Generateable.java
index cb5a01140..23f10add7 100644
--- a/src/main/java/com/dfsek/terra/generation/deserelized/GenerationEntity.java
+++ b/src/main/java/com/dfsek/terra/config/deserealized/Generateable.java
@@ -1,4 +1,4 @@
-package com.dfsek.terra.generation.deserelized;
+package com.dfsek.terra.config.deserealized;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
@@ -6,7 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.util.Random;
@SuppressWarnings("unused")
-public interface GenerationEntity {
+public interface Generateable {
void generate(Location location, Random random, JavaPlugin plugin);
boolean isValidLocation(Location location, JavaPlugin plugin);
diff --git a/src/main/java/com/dfsek/terra/generation/deserelized/MultiChunkOre.java b/src/main/java/com/dfsek/terra/config/deserealized/MultiChunkOre.java
similarity index 98%
rename from src/main/java/com/dfsek/terra/generation/deserelized/MultiChunkOre.java
rename to src/main/java/com/dfsek/terra/config/deserealized/MultiChunkOre.java
index 7c381e12d..f33d4fa75 100644
--- a/src/main/java/com/dfsek/terra/generation/deserelized/MultiChunkOre.java
+++ b/src/main/java/com/dfsek/terra/config/deserealized/MultiChunkOre.java
@@ -1,4 +1,4 @@
-package com.dfsek.terra.generation.deserelized;
+package com.dfsek.terra.config.deserealized;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
diff --git a/src/main/java/com/dfsek/terra/generation/deserelized/Ore.java b/src/main/java/com/dfsek/terra/config/deserealized/Ore.java
similarity index 95%
rename from src/main/java/com/dfsek/terra/generation/deserelized/Ore.java
rename to src/main/java/com/dfsek/terra/config/deserealized/Ore.java
index 82cbbfb62..eb0eb6b14 100644
--- a/src/main/java/com/dfsek/terra/generation/deserelized/Ore.java
+++ b/src/main/java/com/dfsek/terra/config/deserealized/Ore.java
@@ -1,4 +1,4 @@
-package com.dfsek.terra.generation.deserelized;
+package com.dfsek.terra.config.deserealized;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
@@ -27,7 +27,7 @@ import java.util.Set;
@JsonSubTypes.Type(value = SingleChunkOre.class, name = "single"),
@JsonSubTypes.Type(value = VanillaOre.class, name = "vanilla")
})
-public abstract class Ore implements GenerationEntity {
+public abstract class Ore implements Generateable {
protected BlockData material;
protected double deform = 0.75;
@JsonProperty("deform-frequency")
diff --git a/src/main/java/com/dfsek/terra/generation/deserelized/SingleChunkOre.java b/src/main/java/com/dfsek/terra/config/deserealized/SingleChunkOre.java
similarity index 97%
rename from src/main/java/com/dfsek/terra/generation/deserelized/SingleChunkOre.java
rename to src/main/java/com/dfsek/terra/config/deserealized/SingleChunkOre.java
index 22c38f504..06c494c4c 100644
--- a/src/main/java/com/dfsek/terra/generation/deserelized/SingleChunkOre.java
+++ b/src/main/java/com/dfsek/terra/config/deserealized/SingleChunkOre.java
@@ -1,4 +1,4 @@
-package com.dfsek.terra.generation.deserelized;
+package com.dfsek.terra.config.deserealized;
import org.bukkit.Chunk;
import org.bukkit.Location;
diff --git a/src/main/java/com/dfsek/terra/generation/deserelized/Tree.java b/src/main/java/com/dfsek/terra/config/deserealized/Tree.java
similarity index 93%
rename from src/main/java/com/dfsek/terra/generation/deserelized/Tree.java
rename to src/main/java/com/dfsek/terra/config/deserealized/Tree.java
index f8a2ff39c..11b7eac6c 100644
--- a/src/main/java/com/dfsek/terra/generation/deserelized/Tree.java
+++ b/src/main/java/com/dfsek/terra/config/deserealized/Tree.java
@@ -1,4 +1,4 @@
-package com.dfsek.terra.generation.deserelized;
+package com.dfsek.terra.config.deserealized;
import com.dfsek.terra.structure.Rotation;
import com.dfsek.terra.structure.Structure;
@@ -12,7 +12,7 @@ import java.util.Random;
import java.util.Set;
@SuppressWarnings({"unused", "SpellCheckingInspection", "MismatchedQueryAndUpdateOfCollection"})
-public class Tree implements GenerationEntity {
+public class Tree implements Generateable {
private Set spawnable;
private String id;
@JsonProperty("y-offset")
diff --git a/src/main/java/com/dfsek/terra/generation/deserelized/VanillaOre.java b/src/main/java/com/dfsek/terra/config/deserealized/VanillaOre.java
similarity index 97%
rename from src/main/java/com/dfsek/terra/generation/deserelized/VanillaOre.java
rename to src/main/java/com/dfsek/terra/config/deserealized/VanillaOre.java
index b5b582332..1b712892e 100644
--- a/src/main/java/com/dfsek/terra/generation/deserelized/VanillaOre.java
+++ b/src/main/java/com/dfsek/terra/config/deserealized/VanillaOre.java
@@ -1,10 +1,11 @@
-package com.dfsek.terra.generation.deserelized;
+package com.dfsek.terra.config.deserealized;
import net.royawesome.jlibnoise.MathHelper;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.plugin.java.JavaPlugin;
+import org.polydev.gaea.world.Ore;
import java.util.Random;
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/BiomeGridConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/BiomeGridConfig.java
index 0b23f90d2..25b85b3f4 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/BiomeGridConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/BiomeGridConfig.java
@@ -24,19 +24,19 @@ public class BiomeGridConfig extends TerraConfig {
@SuppressWarnings("unchecked")
public BiomeGridConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config);
- if(!contains("id")) throw new ConfigException("Grid ID unspecified!", "null");
- this.gridID = getString("id");
- if(!contains("grid")) throw new ConfigException("Grid key not found!", getID());
- this.sizeX = Objects.requireNonNull(getList("grid")).size();
- this.sizeZ = ((List>) Objects.requireNonNull(getList("grid"))).get(0).size();
+ if(!yaml.contains("id")) throw new ConfigException("Grid ID unspecified!", "null");
+ this.gridID = yaml.getString("id");
+ if(!yaml.contains("grid")) throw new ConfigException("Grid key not found!", getID());
+ this.sizeX = Objects.requireNonNull(yaml.getList("grid")).size();
+ this.sizeZ = ((List>) Objects.requireNonNull(yaml.getList("grid"))).get(0).size();
gridRaw = new UserDefinedBiome[sizeX][sizeZ];
try {
for(int x = 0; x < sizeX; x++) {
for(int z = 0; z < sizeZ; z++) {
try {
- gridRaw[x][z] = config.getBiome(((List>) Objects.requireNonNull(getList("grid"))).get(x).get(z)).getBiome();
+ gridRaw[x][z] = config.getBiome(((List>) Objects.requireNonNull(yaml.getList("grid"))).get(x).get(z)).getBiome();
} catch(NullPointerException e) {
- throw new NotFoundException("Biome", ((List>) Objects.requireNonNull(getList("grid"))).get(x).get(z), getID());
+ throw new NotFoundException("Biome", ((List>) Objects.requireNonNull(yaml.getList("grid"))).get(x).get(z), getID());
}
}
}
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/CarverConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/CarverConfig.java
index 608fa7292..df8ba61d1 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/CarverConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/CarverConfig.java
@@ -45,8 +45,8 @@ public class CarverConfig extends TerraConfig {
@SuppressWarnings("unchecked")
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config);
- if(!contains("id")) throw new ConfigException("No ID specified for Carver!", "null");
- id = Objects.requireNonNull(getString("id"));
+ if(!yaml.contains("id")) throw new ConfigException("No ID specified for Carver!", "null");
+ id = Objects.requireNonNull(yaml.getString("id"));
inner = getBlocks("palette.inner.layers");
@@ -56,23 +56,23 @@ public class CarverConfig extends TerraConfig {
bottom = getBlocks("palette.bottom.layers");
- replaceableInner = ConfigUtil.toBlockData(getStringList("palette.inner.replace"), "replaceable inner", getID());
+ replaceableInner = ConfigUtil.toBlockData(yaml.getStringList("palette.inner.replace"), "replaceable inner", getID());
- replaceableOuter = ConfigUtil.toBlockData(getStringList("palette.outer.replace"), "replaceable outer", getID());
+ replaceableOuter = ConfigUtil.toBlockData(yaml.getStringList("palette.outer.replace"), "replaceable outer", getID());
- replaceableTop = ConfigUtil.toBlockData(getStringList("palette.top.replace"), "replaceable top", getID());
+ replaceableTop = ConfigUtil.toBlockData(yaml.getStringList("palette.top.replace"), "replaceable top", getID());
- replaceableBottom = ConfigUtil.toBlockData(getStringList("palette.bottom.replace"), "replaceable bottom", getID());
+ replaceableBottom = ConfigUtil.toBlockData(yaml.getStringList("palette.bottom.replace"), "replaceable bottom", getID());
- update = ConfigUtil.toBlockData(getStringList("update"), "update", getID());
+ update = ConfigUtil.toBlockData(yaml.getStringList("update"), "update", getID());
- updateOcean = getBoolean("update-liquids", false);
+ updateOcean = yaml.getBoolean("update-liquids", false);
- double step = getDouble("step", 2);
- Range recalc = new Range(getInt("recalculate-direction.min", 8), getInt("recalculate-direction.max", 12));
- double rm = getDouble("recalculate-magnitude", 4);
+ double step = yaml.getDouble("step", 2);
+ Range recalc = new Range(yaml.getInt("recalculate-direction.min", 8), yaml.getInt("recalculate-direction.max", 12));
+ double rm = yaml.getDouble("recalculate-magnitude", 4);
shift = new HashMap<>();
- for(Map.Entry e : Objects.requireNonNull(getConfigurationSection("shift")).getValues(false).entrySet()) {
+ for(Map.Entry e : Objects.requireNonNull(yaml.getConfigurationSection("shift")).getValues(false).entrySet()) {
Set l = new HashSet<>();
for(String s : (List) e.getValue()) {
l.add(Bukkit.createBlockData(s).getMaterial());
@@ -82,19 +82,19 @@ public class CarverConfig extends TerraConfig {
Debug.info("Added " + e.getKey() + " as master block");
}
- replaceIsBlacklistInner = getBoolean("palette.inner.replace-blacklist", false);
- replaceIsBlacklistOuter = getBoolean("palette.outer.replace-blacklist", false);
- replaceIsBlacklistTop = getBoolean("palette.top.replace-blacklist", false);
- replaceIsBlacklistBottom = getBoolean("palette.bottom.replace-blacklist", false);
+ replaceIsBlacklistInner = yaml.getBoolean("palette.inner.replace-blacklist", false);
+ replaceIsBlacklistOuter = yaml.getBoolean("palette.outer.replace-blacklist", false);
+ replaceIsBlacklistTop = yaml.getBoolean("palette.top.replace-blacklist", false);
+ replaceIsBlacklistBottom = yaml.getBoolean("palette.bottom.replace-blacklist", false);
- double[] start = new double[] {getDouble("start.x"), getDouble("start.y"), getDouble("start.z")};
- double[] mutate = new double[] {getDouble("mutate.x"), getDouble("mutate.y"), getDouble("mutate.z"), getDouble("mutate.radius")};
- double[] radiusMultiplier = new double[] {getDouble("start.radius.multiply.x"), getDouble("start.radius.multiply.y"), getDouble("start.radius.multiply.z")};
- Range length = new Range(getInt("length.min"), getInt("length.max"));
- Range radius = new Range(getInt("start.radius.min"), getInt("start.radius.max"));
- Range height = new Range(getInt("start.height.min"), getInt("start.height.max"));
+ double[] start = new double[] {yaml.getDouble("start.x"), yaml.getDouble("start.y"), yaml.getDouble("start.z")};
+ double[] mutate = new double[] {yaml.getDouble("mutate.x"), yaml.getDouble("mutate.y"), yaml.getDouble("mutate.z"), yaml.getDouble("mutate.radius")};
+ double[] radiusMultiplier = new double[] {yaml.getDouble("start.radius.multiply.x"), yaml.getDouble("start.radius.multiply.y"), yaml.getDouble("start.radius.multiply.z")};
+ Range length = new Range(yaml.getInt("length.min"), yaml.getInt("length.max"));
+ Range radius = new Range(yaml.getInt("start.radius.min"), yaml.getInt("start.radius.max"));
+ Range height = new Range(yaml.getInt("start.height.min"), yaml.getInt("start.height.max"));
- carver = new UserDefinedCarver(height, radius, length, start, mutate, radiusMultiplier, id.hashCode(), getInt("cut.top", 0), getInt("cut.bottom", 0));
+ carver = new UserDefinedCarver(height, radius, length, start, mutate, radiusMultiplier, id.hashCode(), yaml.getInt("cut.top", 0), yaml.getInt("cut.bottom", 0));
carver.setStep(step);
carver.setRecalc(recalc);
carver.setRecalcMagnitude(rm);
@@ -102,9 +102,9 @@ public class CarverConfig extends TerraConfig {
@SuppressWarnings("unchecked")
private Map> getBlocks(String key) throws InvalidConfigurationException {
- if(!contains(key)) throw new ConfigException("Missing Carver Palette!", getID());
+ if(!yaml.contains(key)) throw new ConfigException("Missing Carver Palette!", getID());
Map> result = new TreeMap<>();
- for(Map, ?> m : getMapList(key)) {
+ for(Map, ?> m : yaml.getMapList(key)) {
try {
ProbabilityCollection layer = new ProbabilityCollection<>();
for(Map.Entry type : ((Map) m.get("materials")).entrySet()) {
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java
index 3b0fb7dd1..b9bbd36a3 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java
@@ -36,25 +36,24 @@ public class FloraConfig extends TerraConfig implements Flora {
public FloraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config);
- load(file);
- if(!contains("id")) throw new ConfigException("Flora ID unspecified!", "null");
- this.id = getString("id");
- if(!contains("layers")) throw new ConfigException("No blocks defined in custom flora!", getID());
- if(!contains("spawnable")) throw new ConfigException("Flora spawnable blocks unspecified!", getID());
+ if(!yaml.contains("id")) throw new ConfigException("Flora ID unspecified!", "null");
+ this.id = yaml.getString("id");
+ if(!yaml.contains("layers")) throw new ConfigException("No blocks defined in custom flora!", getID());
+ if(!yaml.contains("spawnable")) throw new ConfigException("Flora spawnable blocks unspecified!", getID());
- spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID());
- replaceable = ConfigUtil.toBlockData(getStringList("replaceable"), "replaceable", getID());
+ spawnable = ConfigUtil.toBlockData(yaml.getStringList("spawnable"), "spawnable", getID());
+ replaceable = ConfigUtil.toBlockData(yaml.getStringList("replaceable"), "replaceable", getID());
- if(contains("irrigable")) {
- irrigable = ConfigUtil.toBlockData(getStringList("irrigable"), "irrigable", getID());
+ if(yaml.contains("irrigable")) {
+ irrigable = ConfigUtil.toBlockData(yaml.getStringList("irrigable"), "irrigable", getID());
} else irrigable = null;
- physics = getBoolean("physics", false);
- ceiling = getBoolean("ceiling", false);
+ physics = yaml.getBoolean("physics", false);
+ ceiling = yaml.getBoolean("ceiling", false);
- Palette p = new RandomPalette<>(new Random(getInt("seed", 4)));
+ Palette p = new RandomPalette<>(new Random(yaml.getInt("seed", 4)));
- floraPalette = PaletteConfig.getPalette(getMapList("layers"), p);
+ floraPalette = PaletteConfig.getPalette(yaml.getMapList("layers"), p);
}
public String getID() {
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/OreConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/OreConfig.java
index 8ebea851c..c2c75b036 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/OreConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/OreConfig.java
@@ -36,28 +36,28 @@ public class OreConfig extends TerraConfig {
public OreConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config);
- if(!contains("id")) throw new ConfigException("Ore ID not found!", "null");
- this.id = getString("id");
- if(!contains("material")) throw new ConfigException("Ore material not found!", getID());
- if(!contains("deform")) throw new ConfigException("Ore vein deformation not found!", getID());
- if(!contains("replace")) throw new ConfigException("Ore replaceable materials not found!", getID());
- min = getInt("radius.min", 1);
- max = getInt("radius.max", 1);
- deform = getDouble("deform", 0.75);
- deformFrequency = getDouble("deform-frequency", 0.1);
- update = getBoolean("update", false);
- crossChunks = getBoolean("cross-chunks", true);
- chunkEdgeOffset = getInt("edge-offset", 1);
+ if(!yaml.contains("id")) throw new ConfigException("Ore ID not found!", "null");
+ this.id = yaml.getString("id");
+ if(!yaml.contains("material")) throw new ConfigException("Ore material not found!", getID());
+ if(!yaml.contains("deform")) throw new ConfigException("Ore vein deformation not found!", getID());
+ if(!yaml.contains("replace")) throw new ConfigException("Ore replaceable materials not found!", getID());
+ min = yaml.getInt("radius.min", 1);
+ max = yaml.getInt("radius.max", 1);
+ deform = yaml.getDouble("deform", 0.75);
+ deformFrequency = yaml.getDouble("deform-frequency", 0.1);
+ update = yaml.getBoolean("update", false);
+ crossChunks = yaml.getBoolean("cross-chunks", true);
+ chunkEdgeOffset = yaml.getInt("edge-offset", 1);
if(chunkEdgeOffset > 7 || chunkEdgeOffset < 0)
throw new ConfigException("Edge offset is too high/low!", getID());
- replaceable = ConfigUtil.toBlockData(getStringList("replace"), "replaceable", getID());
+ replaceable = ConfigUtil.toBlockData(yaml.getStringList("replace"), "replaceable", getID());
try {
- oreData = Bukkit.createBlockData(Objects.requireNonNull(getString("material")));
+ oreData = Bukkit.createBlockData(Objects.requireNonNull(yaml.getString("material")));
} catch(NullPointerException | IllegalArgumentException e) {
- throw new ConfigException("Invalid ore material: " + getString("material"), getID());
+ throw new ConfigException("Invalid ore material: " + yaml.getString("material"), getID());
}
}
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java
index b6a3d2cb4..f85600c97 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java
@@ -26,18 +26,18 @@ public class PaletteConfig extends TerraConfig {
public PaletteConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config);
- if(!contains("id")) throw new ConfigException("Palette ID unspecified!", "null");
- this.paletteID = getString("id");
+ if(!yaml.contains("id")) throw new ConfigException("Palette ID unspecified!", "null");
+ this.paletteID = yaml.getString("id");
Palette pal;
- if(getBoolean("simplex", false)) {
+ if(yaml.getBoolean("simplex", false)) {
useNoise = true;
- FastNoiseLite pNoise = new FastNoiseLite(getInt("seed", 2403));
+ FastNoiseLite pNoise = new FastNoiseLite(yaml.getInt("seed", 2403));
pNoise.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
pNoise.setFractalOctaves(4);
- pNoise.setFrequency(getDouble("frequency", 0.02));
+ pNoise.setFrequency(yaml.getDouble("frequency", 0.02));
pal = new SimplexPalette<>(pNoise);
- } else pal = new RandomPalette<>(new Random(getInt("seed", 2403)));
- palette = getPalette(getMapList("layers"), pal);
+ } else pal = new RandomPalette<>(new Random(yaml.getInt("seed", 2403)));
+ palette = getPalette(yaml.getMapList("layers"), pal);
}
@SuppressWarnings("unchecked")
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/TreeConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/TreeConfig.java
index 56732b4b6..a2ae5cb48 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/TreeConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/TreeConfig.java
@@ -31,13 +31,13 @@ public class TreeConfig extends TerraConfig implements Tree {
public TreeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config);
- spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID());
- if(!contains("id")) throw new ConfigException("No ID specified!", "null");
- id = getString("id");
- if(!contains("files")) throw new ConfigException("No files specified!", getID());
- yOffset = getInt("y-offset", 0);
+ spawnable = ConfigUtil.toBlockData(yaml.getStringList("spawnable"), "spawnable", getID());
+ if(!yaml.contains("id")) throw new ConfigException("No ID specified!", "null");
+ id = yaml.getString("id");
+ if(!yaml.contains("files")) throw new ConfigException("No files specified!", getID());
+ yOffset = yaml.getInt("y-offset", 0);
try {
- for(Map.Entry e : Objects.requireNonNull(getConfigurationSection("files")).getValues(false).entrySet()) {
+ for(Map.Entry e : Objects.requireNonNull(yaml.getConfigurationSection("files")).getValues(false).entrySet()) {
try {
File structureFile = new File(config.getDataFolder() + File.separator + "trees" + File.separator + "data", e.getKey() + ".tstructure");
structure.add(Structure.load(structureFile), (Integer) e.getValue());
@@ -53,7 +53,7 @@ public class TreeConfig extends TerraConfig implements Tree {
if(ConfigUtil.debug) {
e.printStackTrace();
}
- throw new NotFoundException("Tree Structure", getString("file"), getID());
+ throw new NotFoundException("Tree Structure", yaml.getString("file"), getID());
}
}
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/biome/AbstractBiomeConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/AbstractBiomeConfig.java
index 9398bf39c..1964f204e 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/biome/AbstractBiomeConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/AbstractBiomeConfig.java
@@ -25,30 +25,29 @@ public class AbstractBiomeConfig extends TerraConfig {
public AbstractBiomeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config);
- load(file);
- if(!contains("id")) throw new ConfigException("Abstract Biome ID unspecified!", "null");
- this.biomeID = getString("id");
+ if(!yaml.contains("id")) throw new ConfigException("Abstract Biome ID unspecified!", "null");
+ this.biomeID = yaml.getString("id");
- equation = getString("noise-equation");
- seaLevel = getInt("ocean.level", 62);
+ equation = yaml.getString("noise-equation");
+ seaLevel = yaml.getInt("ocean.level", 62);
- if(contains("carving")) carving = new BiomeCarverConfig(this);
+ if(yaml.contains("carving")) carving = new BiomeCarverConfig(this);
- if(contains("palette")) palette = new BiomePaletteConfig(this, "palette");
+ if(yaml.contains("palette")) palette = new BiomePaletteConfig(this, "palette");
- if(contains("flora")) flora = new BiomeFloraConfig(this);
+ if(yaml.contains("flora")) flora = new BiomeFloraConfig(this);
- if(contains("trees")) trees = new BiomeTreeConfig(this);
+ if(yaml.contains("trees")) trees = new BiomeTreeConfig(this);
- if(contains("ores")) ores = new BiomeOreConfig(this);
+ if(yaml.contains("ores")) ores = new BiomeOreConfig(this);
- if(contains("ocean")) ocean = new BiomeOceanConfig(this);
+ if(yaml.contains("ocean")) ocean = new BiomeOceanConfig(this);
- if(contains("slabs") && getBoolean("slabs.enable", false)) slabs = new BiomeSlabConfig(this);
+ if(yaml.contains("slabs") && yaml.getBoolean("slabs.enable", false)) slabs = new BiomeSlabConfig(this);
- if(contains("structures")) structureConfigs = getStringList("structures");
+ if(yaml.contains("structures")) structureConfigs = yaml.getStringList("structures");
- if(contains("snow")) snow = new BiomeSnowConfig(this);
+ if(yaml.contains("snow")) snow = new BiomeSnowConfig(this);
}
@Override
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeCarverConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeCarverConfig.java
index 60e43aee5..f4730ca04 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeCarverConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeCarverConfig.java
@@ -17,7 +17,7 @@ public class BiomeCarverConfig extends TerraConfigSection {
public BiomeCarverConfig(TerraConfig parent) throws InvalidConfigurationException {
super(parent);
- ConfigurationSection configurationSection = parent.getConfigurationSection("carving");
+ ConfigurationSection configurationSection = parent.getYaml().getConfigurationSection("carving");
Map cfg;
if(configurationSection != null) {
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeConfig.java
index 32a044b85..584b1b7b7 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeConfig.java
@@ -45,36 +45,36 @@ public class BiomeConfig extends TerraConfig {
public BiomeConfig(File file, ConfigPack config) throws InvalidConfigurationException, IOException {
super(file, config);
- load(file);
this.config = config;
- if(!contains("id")) throw new ConfigException("Biome ID unspecified!", "null");
- this.biomeID = getString("id");
+ if(!yaml.contains("id")) throw new ConfigException("Biome ID unspecified!", "null");
+ this.biomeID = yaml.getString("id");
AbstractBiomeConfig abstractBiome = null;
// Whether an abstract biome is to be extended. Default to false.
boolean extending = false;
// Check if biome extends an abstract biome, load abstract biome if so.
- if(contains("extends")) {
+ if(yaml.contains("extends")) {
try {
- abstractBiome = config.getAbstractBiomes().get(getString("extends"));
- if(abstractBiome == null) throw new NotFoundException("Abstract Biome", getString("extends"), getID());
+ abstractBiome = config.getAbstractBiomes().get(yaml.getString("extends"));
+ if(abstractBiome == null)
+ throw new NotFoundException("Abstract Biome", yaml.getString("extends"), getID());
extending = true;
- Debug.info("Extending biome " + getString("extends"));
+ Debug.info("Extending biome " + yaml.getString("extends"));
} catch(NullPointerException e) {
- throw new NotFoundException("Abstract Biome", getString("extends"), getID());
+ throw new NotFoundException("Abstract Biome", yaml.getString("extends"), getID());
}
}
// Get various simple values using getOrDefault config methods.
try {
- eq = getString("noise-equation", Objects.requireNonNull(abstractBiome).getEquation());
+ eq = yaml.getString("noise-equation", Objects.requireNonNull(abstractBiome).getEquation());
} catch(NullPointerException e) {
- eq = getString("noise-equation", null);
+ eq = yaml.getString("noise-equation", null);
}
BiomePaletteConfig palette;
// Check if biome is extending abstract biome, only use abstract biome's palette if palette is NOT defined for current biome.
- if(extending && abstractBiome.getPaletteData() != null && !contains("palette")) {
+ if(extending && abstractBiome.getPaletteData() != null && !yaml.contains("palette")) {
palette = abstractBiome.getPaletteData();
Debug.info("Using super palette");
} else palette = new BiomePaletteConfig(this, "palette");
@@ -84,31 +84,31 @@ public class BiomeConfig extends TerraConfig {
throw new ConfigException("No Palette specified in biome or super biome.", getID());
// Check if carving should be handled by super biome.
- if(extending && abstractBiome.getCarving() != null && !contains("carving")) {
+ if(extending && abstractBiome.getCarving() != null && !yaml.contains("carving")) {
carver = abstractBiome.getCarving();
Debug.info("Using super carvers");
} else carver = new BiomeCarverConfig(this);
// Check if flora should be handled by super biome.
- if(extending && abstractBiome.getFlora() != null && !contains("flora")) {
+ if(extending && abstractBiome.getFlora() != null && !yaml.contains("flora")) {
flora = abstractBiome.getFlora();
Debug.info("Using super flora (" + flora.getFlora().size() + " entries, " + flora.getFloraChance() + " % chance)");
} else flora = new BiomeFloraConfig(this);
// Check if trees should be handled by super biome.
- if(extending && abstractBiome.getTrees() != null && !contains("trees")) {
+ if(extending && abstractBiome.getTrees() != null && !yaml.contains("trees")) {
tree = abstractBiome.getTrees();
Debug.info("Using super trees");
} else tree = new BiomeTreeConfig(this);
// Check if ores should be handled by super biome.
- if(extending && abstractBiome.getOres() != null && !contains("ores")) {
+ if(extending && abstractBiome.getOres() != null && !yaml.contains("ores")) {
ore = abstractBiome.getOres();
Debug.info("Using super ores");
} else ore = new BiomeOreConfig(this);
// Get slab stuff
- if(extending && abstractBiome.getSlabs() != null && !contains("slabs")) {
+ if(extending && abstractBiome.getSlabs() != null && !yaml.contains("slabs")) {
slab = abstractBiome.getSlabs();
Debug.info("Using super slabs");
} else slab = new BiomeSlabConfig(this);
@@ -127,14 +127,14 @@ public class BiomeConfig extends TerraConfig {
// Get slant stuff
TreeMap> slant = new TreeMap<>();
- if(contains("slant")) {
- String slantS = getString("slant.palette");
+ if(yaml.contains("slant")) {
+ String slantS = yaml.getString("slant.palette");
slant = new BiomePaletteConfig(this, "slant.palette").getPaletteMap();
Debug.info("Using slant palette: " + slantS);
if(slant == null) throw new NotFoundException("Slant Palette", slantS, getID());
}
- ySlantOffsetTop = getDouble("slant.y-offset.top", 0.25);
- ySlantOffsetBottom = getDouble("slant.y-offset.bottom", 0.25);
+ ySlantOffsetTop = yaml.getDouble("slant.y-offset.top", 0.25);
+ ySlantOffsetBottom = yaml.getDouble("slant.y-offset.bottom", 0.25);
//Make sure equation is non-null
if(eq == null || eq.equals(""))
@@ -146,10 +146,10 @@ public class BiomeConfig extends TerraConfig {
// Get Vanilla biome, throw exception if it is invalid/unspecified.
org.bukkit.block.Biome vanillaBiome;
try {
- if(!contains("vanilla")) throw new ConfigException("Vanilla Biome unspecified!", getID());
- vanillaBiome = org.bukkit.block.Biome.valueOf(getString("vanilla"));
+ if(!yaml.contains("vanilla")) throw new ConfigException("Vanilla Biome unspecified!", getID());
+ vanillaBiome = org.bukkit.block.Biome.valueOf(yaml.getString("vanilla"));
} catch(IllegalArgumentException e) {
- throw new ConfigException("Invalid Vanilla biome: \"" + getString("vanilla") + "\"", getID());
+ throw new ConfigException("Invalid Vanilla biome: \"" + yaml.getString("vanilla") + "\"", getID());
}
// Structure stuff
@@ -157,7 +157,7 @@ public class BiomeConfig extends TerraConfig {
List st = new ArrayList<>();
if(abstractBiome != null && abstractBiome.getStructureConfigs() != null)
st = abstractBiome.getStructureConfigs();
- if(contains("structures")) st = getStringList("structures");
+ if(yaml.contains("structures")) st = yaml.getStringList("structures");
for(String s : st) {
try {
structures.add(Objects.requireNonNull(config.getStructure(s)));
@@ -166,14 +166,14 @@ public class BiomeConfig extends TerraConfig {
}
}
- String elevation = getString("elevation.equation", null);
- boolean doElevationInterpolation = getBoolean("elevation.interpolation", true);
+ String elevation = yaml.getString("elevation.equation", null);
+ boolean doElevationInterpolation = yaml.getBoolean("elevation.interpolation", true);
try {
// Get UserDefinedBiome instance representing this config.
- UserDefinedGenerator gen = new UserDefinedGenerator(eq, elevation, config.getDefinedVariables(), palette.getPaletteMap(), slant, getBoolean("prevent-smooth", false));
+ UserDefinedGenerator gen = new UserDefinedGenerator(eq, elevation, config.getDefinedVariables(), palette.getPaletteMap(), slant, yaml.getBoolean("prevent-smooth", false));
gen.setElevationInterpolation(doElevationInterpolation);
- this.biome = new UserDefinedBiome(vanillaBiome, dec, gen, getBoolean("erodible", false), biomeID);
+ this.biome = new UserDefinedBiome(vanillaBiome, dec, gen, yaml.getBoolean("erodible", false), biomeID);
} catch(ParseException e) {
e.printStackTrace();
throw new ConfigException("Unable to parse noise equation!", getID());
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeFloraConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeFloraConfig.java
index e9e267348..5e7f133ec 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeFloraConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeFloraConfig.java
@@ -26,13 +26,13 @@ public class BiomeFloraConfig extends TerraConfigSection {
public BiomeFloraConfig(TerraConfig parent) throws InvalidConfigurationException {
super(parent);
- ConfigurationSection cfg = parent.getConfigurationSection("flora.items");
+ ConfigurationSection cfg = parent.getYaml().getConfigurationSection("flora.items");
if(cfg == null) return;
- floraSimplex = parent.getBoolean("flora.simplex.enable", false);
- floraAttempts = parent.getInt("flora.attempts", 1);
- floraChance = parent.getInt("flora.chance", 0);
- double floraFreq = parent.getDouble("flora.simplex.frequency", 0.1);
- int floraSeed = parent.getInt("flora.simplex.seed", 2403);
+ floraSimplex = parent.getYaml().getBoolean("flora.simplex.enable", false);
+ floraAttempts = parent.getYaml().getInt("flora.attempts", 1);
+ floraChance = parent.getYaml().getInt("flora.chance", 0);
+ double floraFreq = parent.getYaml().getDouble("flora.simplex.frequency", 0.1);
+ int floraSeed = parent.getYaml().getInt("flora.simplex.seed", 2403);
if(floraSimplex) {
floraNoise = new FastNoiseLite(floraSeed);
floraNoise.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeOceanConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeOceanConfig.java
index 55d233fe7..67f7c10f5 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeOceanConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeOceanConfig.java
@@ -22,8 +22,8 @@ public class BiomeOceanConfig extends TerraConfigSection {
public BiomeOceanConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
super(parent);
- seaLevel = parent.getInt("ocean.level", 62);
- String oceanN = parent.getString("ocean.palette");
+ seaLevel = parent.getYaml().getInt("ocean.level", 62);
+ String oceanN = parent.getYaml().getString("ocean.palette");
if(oceanN != null) {
if(oceanN.startsWith("BLOCK:")) {
try {
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeOreConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeOreConfig.java
index bceb1a3c9..adf874585 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeOreConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeOreConfig.java
@@ -19,7 +19,7 @@ public class BiomeOreConfig extends TerraConfigSection {
public BiomeOreConfig(TerraConfig parent) throws InvalidConfigurationException {
super(parent);
- ConfigurationSection c = parent.getConfigurationSection("ores");
+ ConfigurationSection c = parent.getYaml().getConfigurationSection("ores");
if(c == null) return;
Map cfg = c.getValues(false);
try {
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomePaletteConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomePaletteConfig.java
index ff70cca9b..bb321bf0e 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomePaletteConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomePaletteConfig.java
@@ -21,7 +21,7 @@ public class BiomePaletteConfig extends TerraConfigSection {
public BiomePaletteConfig(TerraConfig parent, String key) throws InvalidConfigurationException {
super(parent);
- List