mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-02 16:05:29 +00:00
Working stuff
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
parent
ee96e2c9ef
commit
f8599fd564
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@ -86,5 +86,10 @@
|
|||||||
<option name="name" value="maven5" />
|
<option name="name" value="maven5" />
|
||||||
<option name="url" value="https://maven.pkg.github.com/solonovamax/Gaea" />
|
<option name="url" value="https://maven.pkg.github.com/solonovamax/Gaea" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenRepo" />
|
||||||
|
<option name="name" value="MavenRepo" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
5
.idea/vcs.xml
generated
5
.idea/vcs.xml
generated
@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="CommitMessageInspectionProfile">
|
||||||
|
<profile version="1.0">
|
||||||
|
<inspection_tool class="GrazieCommit" enabled="true" level="TYPO" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
|
@ -48,10 +48,10 @@ dependencies {
|
|||||||
implementation("io.papermc:paperlib:1.0.5")
|
implementation("io.papermc:paperlib:1.0.5")
|
||||||
|
|
||||||
// Jackson
|
// Jackson
|
||||||
implementation("com.fasterxml.jackson.core:jackson-core:2.12+")
|
implementation("com.fasterxml.jackson.core:jackson-core:2.11+")
|
||||||
implementation("com.fasterxml.jackson.core:jackson-annotations:2.12+")
|
implementation("com.fasterxml.jackson.core:jackson-annotations:2.11+")
|
||||||
implementation("com.fasterxml.jackson.core:jackson-databind:2.12+")
|
implementation("com.fasterxml.jackson.core:jackson-databind:2.11+")
|
||||||
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12+")
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11+")
|
||||||
|
|
||||||
// Spigot mc API. Provided by spigot.
|
// Spigot mc API. Provided by spigot.
|
||||||
compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
|
||||||
|
@ -12,9 +12,9 @@ import java.io.InputStreamReader;
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public abstract class TerraConfig {
|
public abstract class TerraConfig {
|
||||||
protected final String id;
|
protected final YamlConfiguration yaml;
|
||||||
private final ConfigPack config;
|
private final ConfigPack config;
|
||||||
private final YamlConfiguration yaml;
|
protected String id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new Terra config with a file, config pack and 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 Deprecated because you should use {@link #TerraConfig(InputStream, ConfigPack, String)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TerraConfig(File file, ConfigPack config, String id) throws IOException, InvalidConfigurationException {
|
public TerraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
this(new FileInputStream(file), config, id);
|
this(new FileInputStream(file), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,11 +40,14 @@ public abstract class TerraConfig {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws InvalidConfigurationException
|
* @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 = new YamlConfiguration();
|
||||||
yaml.load(new InputStreamReader(stream));
|
yaml.load(new InputStreamReader(stream));
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.id = id;
|
}
|
||||||
|
|
||||||
|
public YamlConfiguration getYaml() {
|
||||||
|
return yaml;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigPack getConfig() {
|
public ConfigPack getConfig() {
|
||||||
|
@ -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<Material> update;
|
||||||
|
private Map<Material, Set<Material>> shift;
|
||||||
|
private Map<Integer, ProbabilityCollection<BlockData>> inner;
|
||||||
|
private Map<Integer, ProbabilityCollection<BlockData>> outer;
|
||||||
|
private Map<Integer, ProbabilityCollection<BlockData>> top;
|
||||||
|
private Map<Integer, ProbabilityCollection<BlockData>> bottom;
|
||||||
|
private boolean updateOcean;
|
||||||
|
private boolean replaceIsBlacklistInner;
|
||||||
|
private boolean replaceIsBlacklistOuter;
|
||||||
|
private boolean replaceIsBlacklistTop;
|
||||||
|
private boolean replaceIsBlacklistBottom;
|
||||||
|
private Set<Material> replaceableInner;
|
||||||
|
private Set<Material> replaceableOuter;
|
||||||
|
private Set<Material> replaceableTop;
|
||||||
|
private Set<Material> replaceableBottom;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(Location location, Random random, JavaPlugin plugin) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidLocation(Location location, JavaPlugin plugin) {
|
||||||
|
return false;
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
}
|
@ -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.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -16,14 +15,12 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
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<BlockData> floraPalette;
|
private final Palette<BlockData> floraPalette;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final boolean physics;
|
private final boolean physics;
|
||||||
private final boolean ceiling;
|
private final boolean ceiling;
|
||||||
|
|
||||||
private final Set<Material> irrigable;
|
private final Set<Material> irrigable;
|
||||||
|
|
||||||
private final Set<Material> spawnable;
|
private final Set<Material> spawnable;
|
||||||
private final Set<Material> replaceable;
|
private final Set<Material> replaceable;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.dfsek.terra.generation.deserelized;
|
package com.dfsek.terra.config.deserealized;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -6,7 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public interface GenerationEntity {
|
public interface Generateable {
|
||||||
void generate(Location location, Random random, JavaPlugin plugin);
|
void generate(Location location, Random random, JavaPlugin plugin);
|
||||||
|
|
||||||
boolean isValidLocation(Location location, JavaPlugin plugin);
|
boolean isValidLocation(Location location, JavaPlugin plugin);
|
@ -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.JsonDeserializer;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
@ -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.JsonProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
@ -27,7 +27,7 @@ import java.util.Set;
|
|||||||
@JsonSubTypes.Type(value = SingleChunkOre.class, name = "single"),
|
@JsonSubTypes.Type(value = SingleChunkOre.class, name = "single"),
|
||||||
@JsonSubTypes.Type(value = VanillaOre.class, name = "vanilla")
|
@JsonSubTypes.Type(value = VanillaOre.class, name = "vanilla")
|
||||||
})
|
})
|
||||||
public abstract class Ore implements GenerationEntity {
|
public abstract class Ore implements Generateable {
|
||||||
protected BlockData material;
|
protected BlockData material;
|
||||||
protected double deform = 0.75;
|
protected double deform = 0.75;
|
||||||
@JsonProperty("deform-frequency")
|
@JsonProperty("deform-frequency")
|
@ -1,4 +1,4 @@
|
|||||||
package com.dfsek.terra.generation.deserelized;
|
package com.dfsek.terra.config.deserealized;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
@ -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.Rotation;
|
||||||
import com.dfsek.terra.structure.Structure;
|
import com.dfsek.terra.structure.Structure;
|
||||||
@ -12,7 +12,7 @@ import java.util.Random;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "SpellCheckingInspection", "MismatchedQueryAndUpdateOfCollection"})
|
@SuppressWarnings({"unused", "SpellCheckingInspection", "MismatchedQueryAndUpdateOfCollection"})
|
||||||
public class Tree implements GenerationEntity {
|
public class Tree implements Generateable {
|
||||||
private Set<Material> spawnable;
|
private Set<Material> spawnable;
|
||||||
private String id;
|
private String id;
|
||||||
@JsonProperty("y-offset")
|
@JsonProperty("y-offset")
|
@ -1,10 +1,11 @@
|
|||||||
package com.dfsek.terra.generation.deserelized;
|
package com.dfsek.terra.config.deserealized;
|
||||||
|
|
||||||
import net.royawesome.jlibnoise.MathHelper;
|
import net.royawesome.jlibnoise.MathHelper;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.polydev.gaea.world.Ore;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
@ -24,19 +24,19 @@ public class BiomeGridConfig extends TerraConfig {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BiomeGridConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public BiomeGridConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
if(!contains("id")) throw new ConfigException("Grid ID unspecified!", "null");
|
if(!yaml.contains("id")) throw new ConfigException("Grid ID unspecified!", "null");
|
||||||
this.gridID = getString("id");
|
this.gridID = yaml.getString("id");
|
||||||
if(!contains("grid")) throw new ConfigException("Grid key not found!", getID());
|
if(!yaml.contains("grid")) throw new ConfigException("Grid key not found!", getID());
|
||||||
this.sizeX = Objects.requireNonNull(getList("grid")).size();
|
this.sizeX = Objects.requireNonNull(yaml.getList("grid")).size();
|
||||||
this.sizeZ = ((List<List<String>>) Objects.requireNonNull(getList("grid"))).get(0).size();
|
this.sizeZ = ((List<List<String>>) Objects.requireNonNull(yaml.getList("grid"))).get(0).size();
|
||||||
gridRaw = new UserDefinedBiome[sizeX][sizeZ];
|
gridRaw = new UserDefinedBiome[sizeX][sizeZ];
|
||||||
try {
|
try {
|
||||||
for(int x = 0; x < sizeX; x++) {
|
for(int x = 0; x < sizeX; x++) {
|
||||||
for(int z = 0; z < sizeZ; z++) {
|
for(int z = 0; z < sizeZ; z++) {
|
||||||
try {
|
try {
|
||||||
gridRaw[x][z] = config.getBiome(((List<List<String>>) Objects.requireNonNull(getList("grid"))).get(x).get(z)).getBiome();
|
gridRaw[x][z] = config.getBiome(((List<List<String>>) Objects.requireNonNull(yaml.getList("grid"))).get(x).get(z)).getBiome();
|
||||||
} catch(NullPointerException e) {
|
} catch(NullPointerException e) {
|
||||||
throw new NotFoundException("Biome", ((List<List<String>>) Objects.requireNonNull(getList("grid"))).get(x).get(z), getID());
|
throw new NotFoundException("Biome", ((List<List<String>>) Objects.requireNonNull(yaml.getList("grid"))).get(x).get(z), getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ public class CarverConfig extends TerraConfig {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
if(!contains("id")) throw new ConfigException("No ID specified for Carver!", "null");
|
if(!yaml.contains("id")) throw new ConfigException("No ID specified for Carver!", "null");
|
||||||
id = Objects.requireNonNull(getString("id"));
|
id = Objects.requireNonNull(yaml.getString("id"));
|
||||||
|
|
||||||
inner = getBlocks("palette.inner.layers");
|
inner = getBlocks("palette.inner.layers");
|
||||||
|
|
||||||
@ -56,23 +56,23 @@ public class CarverConfig extends TerraConfig {
|
|||||||
|
|
||||||
bottom = getBlocks("palette.bottom.layers");
|
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);
|
double step = yaml.getDouble("step", 2);
|
||||||
Range recalc = new Range(getInt("recalculate-direction.min", 8), getInt("recalculate-direction.max", 12));
|
Range recalc = new Range(yaml.getInt("recalculate-direction.min", 8), yaml.getInt("recalculate-direction.max", 12));
|
||||||
double rm = getDouble("recalculate-magnitude", 4);
|
double rm = yaml.getDouble("recalculate-magnitude", 4);
|
||||||
shift = new HashMap<>();
|
shift = new HashMap<>();
|
||||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("shift")).getValues(false).entrySet()) {
|
for(Map.Entry<String, Object> e : Objects.requireNonNull(yaml.getConfigurationSection("shift")).getValues(false).entrySet()) {
|
||||||
Set<Material> l = new HashSet<>();
|
Set<Material> l = new HashSet<>();
|
||||||
for(String s : (List<String>) e.getValue()) {
|
for(String s : (List<String>) e.getValue()) {
|
||||||
l.add(Bukkit.createBlockData(s).getMaterial());
|
l.add(Bukkit.createBlockData(s).getMaterial());
|
||||||
@ -82,19 +82,19 @@ public class CarverConfig extends TerraConfig {
|
|||||||
Debug.info("Added " + e.getKey() + " as master block");
|
Debug.info("Added " + e.getKey() + " as master block");
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceIsBlacklistInner = getBoolean("palette.inner.replace-blacklist", false);
|
replaceIsBlacklistInner = yaml.getBoolean("palette.inner.replace-blacklist", false);
|
||||||
replaceIsBlacklistOuter = getBoolean("palette.outer.replace-blacklist", false);
|
replaceIsBlacklistOuter = yaml.getBoolean("palette.outer.replace-blacklist", false);
|
||||||
replaceIsBlacklistTop = getBoolean("palette.top.replace-blacklist", false);
|
replaceIsBlacklistTop = yaml.getBoolean("palette.top.replace-blacklist", false);
|
||||||
replaceIsBlacklistBottom = getBoolean("palette.bottom.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[] start = new double[] {yaml.getDouble("start.x"), yaml.getDouble("start.y"), yaml.getDouble("start.z")};
|
||||||
double[] mutate = new double[] {getDouble("mutate.x"), getDouble("mutate.y"), getDouble("mutate.z"), getDouble("mutate.radius")};
|
double[] mutate = new double[] {yaml.getDouble("mutate.x"), yaml.getDouble("mutate.y"), yaml.getDouble("mutate.z"), yaml.getDouble("mutate.radius")};
|
||||||
double[] radiusMultiplier = new double[] {getDouble("start.radius.multiply.x"), getDouble("start.radius.multiply.y"), getDouble("start.radius.multiply.z")};
|
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(getInt("length.min"), getInt("length.max"));
|
Range length = new Range(yaml.getInt("length.min"), yaml.getInt("length.max"));
|
||||||
Range radius = new Range(getInt("start.radius.min"), getInt("start.radius.max"));
|
Range radius = new Range(yaml.getInt("start.radius.min"), yaml.getInt("start.radius.max"));
|
||||||
Range height = new Range(getInt("start.height.min"), getInt("start.height.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.setStep(step);
|
||||||
carver.setRecalc(recalc);
|
carver.setRecalc(recalc);
|
||||||
carver.setRecalcMagnitude(rm);
|
carver.setRecalcMagnitude(rm);
|
||||||
@ -102,9 +102,9 @@ public class CarverConfig extends TerraConfig {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Map<Integer, ProbabilityCollection<BlockData>> getBlocks(String key) throws InvalidConfigurationException {
|
private Map<Integer, ProbabilityCollection<BlockData>> 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<Integer, ProbabilityCollection<BlockData>> result = new TreeMap<>();
|
Map<Integer, ProbabilityCollection<BlockData>> result = new TreeMap<>();
|
||||||
for(Map<?, ?> m : getMapList(key)) {
|
for(Map<?, ?> m : yaml.getMapList(key)) {
|
||||||
try {
|
try {
|
||||||
ProbabilityCollection<BlockData> layer = new ProbabilityCollection<>();
|
ProbabilityCollection<BlockData> layer = new ProbabilityCollection<>();
|
||||||
for(Map.Entry<String, Integer> type : ((Map<String, Integer>) m.get("materials")).entrySet()) {
|
for(Map.Entry<String, Integer> type : ((Map<String, Integer>) m.get("materials")).entrySet()) {
|
||||||
|
@ -36,25 +36,24 @@ public class FloraConfig extends TerraConfig implements Flora {
|
|||||||
|
|
||||||
public FloraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public FloraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
load(file);
|
if(!yaml.contains("id")) throw new ConfigException("Flora ID unspecified!", "null");
|
||||||
if(!contains("id")) throw new ConfigException("Flora ID unspecified!", "null");
|
this.id = yaml.getString("id");
|
||||||
this.id = getString("id");
|
if(!yaml.contains("layers")) throw new ConfigException("No blocks defined in custom flora!", getID());
|
||||||
if(!contains("layers")) throw new ConfigException("No blocks defined in custom flora!", getID());
|
if(!yaml.contains("spawnable")) throw new ConfigException("Flora spawnable blocks unspecified!", getID());
|
||||||
if(!contains("spawnable")) throw new ConfigException("Flora spawnable blocks unspecified!", getID());
|
|
||||||
|
|
||||||
spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID());
|
spawnable = ConfigUtil.toBlockData(yaml.getStringList("spawnable"), "spawnable", getID());
|
||||||
replaceable = ConfigUtil.toBlockData(getStringList("replaceable"), "replaceable", getID());
|
replaceable = ConfigUtil.toBlockData(yaml.getStringList("replaceable"), "replaceable", getID());
|
||||||
|
|
||||||
if(contains("irrigable")) {
|
if(yaml.contains("irrigable")) {
|
||||||
irrigable = ConfigUtil.toBlockData(getStringList("irrigable"), "irrigable", getID());
|
irrigable = ConfigUtil.toBlockData(yaml.getStringList("irrigable"), "irrigable", getID());
|
||||||
} else irrigable = null;
|
} else irrigable = null;
|
||||||
|
|
||||||
physics = getBoolean("physics", false);
|
physics = yaml.getBoolean("physics", false);
|
||||||
ceiling = getBoolean("ceiling", false);
|
ceiling = yaml.getBoolean("ceiling", false);
|
||||||
|
|
||||||
Palette<BlockData> p = new RandomPalette<>(new Random(getInt("seed", 4)));
|
Palette<BlockData> 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() {
|
public String getID() {
|
||||||
|
@ -36,28 +36,28 @@ public class OreConfig extends TerraConfig {
|
|||||||
|
|
||||||
public OreConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public OreConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
if(!contains("id")) throw new ConfigException("Ore ID not found!", "null");
|
if(!yaml.contains("id")) throw new ConfigException("Ore ID not found!", "null");
|
||||||
this.id = getString("id");
|
this.id = yaml.getString("id");
|
||||||
if(!contains("material")) throw new ConfigException("Ore material not found!", getID());
|
if(!yaml.contains("material")) throw new ConfigException("Ore material not found!", getID());
|
||||||
if(!contains("deform")) throw new ConfigException("Ore vein deformation not found!", getID());
|
if(!yaml.contains("deform")) throw new ConfigException("Ore vein deformation not found!", getID());
|
||||||
if(!contains("replace")) throw new ConfigException("Ore replaceable materials not found!", getID());
|
if(!yaml.contains("replace")) throw new ConfigException("Ore replaceable materials not found!", getID());
|
||||||
min = getInt("radius.min", 1);
|
min = yaml.getInt("radius.min", 1);
|
||||||
max = getInt("radius.max", 1);
|
max = yaml.getInt("radius.max", 1);
|
||||||
deform = getDouble("deform", 0.75);
|
deform = yaml.getDouble("deform", 0.75);
|
||||||
deformFrequency = getDouble("deform-frequency", 0.1);
|
deformFrequency = yaml.getDouble("deform-frequency", 0.1);
|
||||||
update = getBoolean("update", false);
|
update = yaml.getBoolean("update", false);
|
||||||
crossChunks = getBoolean("cross-chunks", true);
|
crossChunks = yaml.getBoolean("cross-chunks", true);
|
||||||
chunkEdgeOffset = getInt("edge-offset", 1);
|
chunkEdgeOffset = yaml.getInt("edge-offset", 1);
|
||||||
|
|
||||||
if(chunkEdgeOffset > 7 || chunkEdgeOffset < 0)
|
if(chunkEdgeOffset > 7 || chunkEdgeOffset < 0)
|
||||||
throw new ConfigException("Edge offset is too high/low!", getID());
|
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 {
|
try {
|
||||||
oreData = Bukkit.createBlockData(Objects.requireNonNull(getString("material")));
|
oreData = Bukkit.createBlockData(Objects.requireNonNull(yaml.getString("material")));
|
||||||
} catch(NullPointerException | IllegalArgumentException e) {
|
} catch(NullPointerException | IllegalArgumentException e) {
|
||||||
throw new ConfigException("Invalid ore material: " + getString("material"), getID());
|
throw new ConfigException("Invalid ore material: " + yaml.getString("material"), getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,18 +26,18 @@ public class PaletteConfig extends TerraConfig {
|
|||||||
|
|
||||||
public PaletteConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public PaletteConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
if(!contains("id")) throw new ConfigException("Palette ID unspecified!", "null");
|
if(!yaml.contains("id")) throw new ConfigException("Palette ID unspecified!", "null");
|
||||||
this.paletteID = getString("id");
|
this.paletteID = yaml.getString("id");
|
||||||
Palette<BlockData> pal;
|
Palette<BlockData> pal;
|
||||||
if(getBoolean("simplex", false)) {
|
if(yaml.getBoolean("simplex", false)) {
|
||||||
useNoise = true;
|
useNoise = true;
|
||||||
FastNoiseLite pNoise = new FastNoiseLite(getInt("seed", 2403));
|
FastNoiseLite pNoise = new FastNoiseLite(yaml.getInt("seed", 2403));
|
||||||
pNoise.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
pNoise.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
||||||
pNoise.setFractalOctaves(4);
|
pNoise.setFractalOctaves(4);
|
||||||
pNoise.setFrequency(getDouble("frequency", 0.02));
|
pNoise.setFrequency(yaml.getDouble("frequency", 0.02));
|
||||||
pal = new SimplexPalette<>(pNoise);
|
pal = new SimplexPalette<>(pNoise);
|
||||||
} else pal = new RandomPalette<>(new Random(getInt("seed", 2403)));
|
} else pal = new RandomPalette<>(new Random(yaml.getInt("seed", 2403)));
|
||||||
palette = getPalette(getMapList("layers"), pal);
|
palette = getPalette(yaml.getMapList("layers"), pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -31,13 +31,13 @@ public class TreeConfig extends TerraConfig implements Tree {
|
|||||||
|
|
||||||
public TreeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public TreeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID());
|
spawnable = ConfigUtil.toBlockData(yaml.getStringList("spawnable"), "spawnable", getID());
|
||||||
if(!contains("id")) throw new ConfigException("No ID specified!", "null");
|
if(!yaml.contains("id")) throw new ConfigException("No ID specified!", "null");
|
||||||
id = getString("id");
|
id = yaml.getString("id");
|
||||||
if(!contains("files")) throw new ConfigException("No files specified!", getID());
|
if(!yaml.contains("files")) throw new ConfigException("No files specified!", getID());
|
||||||
yOffset = getInt("y-offset", 0);
|
yOffset = yaml.getInt("y-offset", 0);
|
||||||
try {
|
try {
|
||||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("files")).getValues(false).entrySet()) {
|
for(Map.Entry<String, Object> e : Objects.requireNonNull(yaml.getConfigurationSection("files")).getValues(false).entrySet()) {
|
||||||
try {
|
try {
|
||||||
File structureFile = new File(config.getDataFolder() + File.separator + "trees" + File.separator + "data", e.getKey() + ".tstructure");
|
File structureFile = new File(config.getDataFolder() + File.separator + "trees" + File.separator + "data", e.getKey() + ".tstructure");
|
||||||
structure.add(Structure.load(structureFile), (Integer) e.getValue());
|
structure.add(Structure.load(structureFile), (Integer) e.getValue());
|
||||||
@ -53,7 +53,7 @@ public class TreeConfig extends TerraConfig implements Tree {
|
|||||||
if(ConfigUtil.debug) {
|
if(ConfigUtil.debug) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
throw new NotFoundException("Tree Structure", getString("file"), getID());
|
throw new NotFoundException("Tree Structure", yaml.getString("file"), getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,30 +25,29 @@ public class AbstractBiomeConfig extends TerraConfig {
|
|||||||
|
|
||||||
public AbstractBiomeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public AbstractBiomeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
load(file);
|
if(!yaml.contains("id")) throw new ConfigException("Abstract Biome ID unspecified!", "null");
|
||||||
if(!contains("id")) throw new ConfigException("Abstract Biome ID unspecified!", "null");
|
this.biomeID = yaml.getString("id");
|
||||||
this.biomeID = getString("id");
|
|
||||||
|
|
||||||
equation = getString("noise-equation");
|
equation = yaml.getString("noise-equation");
|
||||||
seaLevel = getInt("ocean.level", 62);
|
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
|
@Override
|
||||||
|
@ -17,7 +17,7 @@ public class BiomeCarverConfig extends TerraConfigSection {
|
|||||||
|
|
||||||
public BiomeCarverConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeCarverConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
ConfigurationSection configurationSection = parent.getConfigurationSection("carving");
|
ConfigurationSection configurationSection = parent.getYaml().getConfigurationSection("carving");
|
||||||
|
|
||||||
Map<String, Object> cfg;
|
Map<String, Object> cfg;
|
||||||
if(configurationSection != null) {
|
if(configurationSection != null) {
|
||||||
|
@ -45,36 +45,36 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
|
|
||||||
public BiomeConfig(File file, ConfigPack config) throws InvalidConfigurationException, IOException {
|
public BiomeConfig(File file, ConfigPack config) throws InvalidConfigurationException, IOException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
load(file);
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
if(!contains("id")) throw new ConfigException("Biome ID unspecified!", "null");
|
if(!yaml.contains("id")) throw new ConfigException("Biome ID unspecified!", "null");
|
||||||
this.biomeID = getString("id");
|
this.biomeID = yaml.getString("id");
|
||||||
|
|
||||||
AbstractBiomeConfig abstractBiome = null;
|
AbstractBiomeConfig abstractBiome = null;
|
||||||
// Whether an abstract biome is to be extended. Default to false.
|
// Whether an abstract biome is to be extended. Default to false.
|
||||||
boolean extending = false;
|
boolean extending = false;
|
||||||
// Check if biome extends an abstract biome, load abstract biome if so.
|
// Check if biome extends an abstract biome, load abstract biome if so.
|
||||||
if(contains("extends")) {
|
if(yaml.contains("extends")) {
|
||||||
try {
|
try {
|
||||||
abstractBiome = config.getAbstractBiomes().get(getString("extends"));
|
abstractBiome = config.getAbstractBiomes().get(yaml.getString("extends"));
|
||||||
if(abstractBiome == null) throw new NotFoundException("Abstract Biome", getString("extends"), getID());
|
if(abstractBiome == null)
|
||||||
|
throw new NotFoundException("Abstract Biome", yaml.getString("extends"), getID());
|
||||||
extending = true;
|
extending = true;
|
||||||
Debug.info("Extending biome " + getString("extends"));
|
Debug.info("Extending biome " + yaml.getString("extends"));
|
||||||
} catch(NullPointerException e) {
|
} 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.
|
// Get various simple values using getOrDefault config methods.
|
||||||
try {
|
try {
|
||||||
eq = getString("noise-equation", Objects.requireNonNull(abstractBiome).getEquation());
|
eq = yaml.getString("noise-equation", Objects.requireNonNull(abstractBiome).getEquation());
|
||||||
} catch(NullPointerException e) {
|
} catch(NullPointerException e) {
|
||||||
eq = getString("noise-equation", null);
|
eq = yaml.getString("noise-equation", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
BiomePaletteConfig palette;
|
BiomePaletteConfig palette;
|
||||||
// Check if biome is extending abstract biome, only use abstract biome's palette if palette is NOT defined for current biome.
|
// 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();
|
palette = abstractBiome.getPaletteData();
|
||||||
Debug.info("Using super palette");
|
Debug.info("Using super palette");
|
||||||
} else palette = new BiomePaletteConfig(this, "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());
|
throw new ConfigException("No Palette specified in biome or super biome.", getID());
|
||||||
|
|
||||||
// Check if carving should be handled by super biome.
|
// 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();
|
carver = abstractBiome.getCarving();
|
||||||
Debug.info("Using super carvers");
|
Debug.info("Using super carvers");
|
||||||
} else carver = new BiomeCarverConfig(this);
|
} else carver = new BiomeCarverConfig(this);
|
||||||
|
|
||||||
// Check if flora should be handled by super biome.
|
// 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();
|
flora = abstractBiome.getFlora();
|
||||||
Debug.info("Using super flora (" + flora.getFlora().size() + " entries, " + flora.getFloraChance() + " % chance)");
|
Debug.info("Using super flora (" + flora.getFlora().size() + " entries, " + flora.getFloraChance() + " % chance)");
|
||||||
} else flora = new BiomeFloraConfig(this);
|
} else flora = new BiomeFloraConfig(this);
|
||||||
|
|
||||||
// Check if trees should be handled by super biome.
|
// 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();
|
tree = abstractBiome.getTrees();
|
||||||
Debug.info("Using super trees");
|
Debug.info("Using super trees");
|
||||||
} else tree = new BiomeTreeConfig(this);
|
} else tree = new BiomeTreeConfig(this);
|
||||||
|
|
||||||
// Check if ores should be handled by super biome.
|
// 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();
|
ore = abstractBiome.getOres();
|
||||||
Debug.info("Using super ores");
|
Debug.info("Using super ores");
|
||||||
} else ore = new BiomeOreConfig(this);
|
} else ore = new BiomeOreConfig(this);
|
||||||
|
|
||||||
// Get slab stuff
|
// Get slab stuff
|
||||||
if(extending && abstractBiome.getSlabs() != null && !contains("slabs")) {
|
if(extending && abstractBiome.getSlabs() != null && !yaml.contains("slabs")) {
|
||||||
slab = abstractBiome.getSlabs();
|
slab = abstractBiome.getSlabs();
|
||||||
Debug.info("Using super slabs");
|
Debug.info("Using super slabs");
|
||||||
} else slab = new BiomeSlabConfig(this);
|
} else slab = new BiomeSlabConfig(this);
|
||||||
@ -127,14 +127,14 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
|
|
||||||
// Get slant stuff
|
// Get slant stuff
|
||||||
TreeMap<Integer, Palette<BlockData>> slant = new TreeMap<>();
|
TreeMap<Integer, Palette<BlockData>> slant = new TreeMap<>();
|
||||||
if(contains("slant")) {
|
if(yaml.contains("slant")) {
|
||||||
String slantS = getString("slant.palette");
|
String slantS = yaml.getString("slant.palette");
|
||||||
slant = new BiomePaletteConfig(this, "slant.palette").getPaletteMap();
|
slant = new BiomePaletteConfig(this, "slant.palette").getPaletteMap();
|
||||||
Debug.info("Using slant palette: " + slantS);
|
Debug.info("Using slant palette: " + slantS);
|
||||||
if(slant == null) throw new NotFoundException("Slant Palette", slantS, getID());
|
if(slant == null) throw new NotFoundException("Slant Palette", slantS, getID());
|
||||||
}
|
}
|
||||||
ySlantOffsetTop = getDouble("slant.y-offset.top", 0.25);
|
ySlantOffsetTop = yaml.getDouble("slant.y-offset.top", 0.25);
|
||||||
ySlantOffsetBottom = getDouble("slant.y-offset.bottom", 0.25);
|
ySlantOffsetBottom = yaml.getDouble("slant.y-offset.bottom", 0.25);
|
||||||
|
|
||||||
//Make sure equation is non-null
|
//Make sure equation is non-null
|
||||||
if(eq == null || eq.equals(""))
|
if(eq == null || eq.equals(""))
|
||||||
@ -146,10 +146,10 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
// Get Vanilla biome, throw exception if it is invalid/unspecified.
|
// Get Vanilla biome, throw exception if it is invalid/unspecified.
|
||||||
org.bukkit.block.Biome vanillaBiome;
|
org.bukkit.block.Biome vanillaBiome;
|
||||||
try {
|
try {
|
||||||
if(!contains("vanilla")) throw new ConfigException("Vanilla Biome unspecified!", getID());
|
if(!yaml.contains("vanilla")) throw new ConfigException("Vanilla Biome unspecified!", getID());
|
||||||
vanillaBiome = org.bukkit.block.Biome.valueOf(getString("vanilla"));
|
vanillaBiome = org.bukkit.block.Biome.valueOf(yaml.getString("vanilla"));
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
throw new ConfigException("Invalid Vanilla biome: \"" + getString("vanilla") + "\"", getID());
|
throw new ConfigException("Invalid Vanilla biome: \"" + yaml.getString("vanilla") + "\"", getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Structure stuff
|
// Structure stuff
|
||||||
@ -157,7 +157,7 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
List<String> st = new ArrayList<>();
|
List<String> st = new ArrayList<>();
|
||||||
if(abstractBiome != null && abstractBiome.getStructureConfigs() != null)
|
if(abstractBiome != null && abstractBiome.getStructureConfigs() != null)
|
||||||
st = abstractBiome.getStructureConfigs();
|
st = abstractBiome.getStructureConfigs();
|
||||||
if(contains("structures")) st = getStringList("structures");
|
if(yaml.contains("structures")) st = yaml.getStringList("structures");
|
||||||
for(String s : st) {
|
for(String s : st) {
|
||||||
try {
|
try {
|
||||||
structures.add(Objects.requireNonNull(config.getStructure(s)));
|
structures.add(Objects.requireNonNull(config.getStructure(s)));
|
||||||
@ -166,14 +166,14 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String elevation = getString("elevation.equation", null);
|
String elevation = yaml.getString("elevation.equation", null);
|
||||||
boolean doElevationInterpolation = getBoolean("elevation.interpolation", true);
|
boolean doElevationInterpolation = yaml.getBoolean("elevation.interpolation", true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get UserDefinedBiome instance representing this config.
|
// 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);
|
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) {
|
} catch(ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ConfigException("Unable to parse noise equation!", getID());
|
throw new ConfigException("Unable to parse noise equation!", getID());
|
||||||
|
@ -26,13 +26,13 @@ public class BiomeFloraConfig extends TerraConfigSection {
|
|||||||
|
|
||||||
public BiomeFloraConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeFloraConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
ConfigurationSection cfg = parent.getConfigurationSection("flora.items");
|
ConfigurationSection cfg = parent.getYaml().getConfigurationSection("flora.items");
|
||||||
if(cfg == null) return;
|
if(cfg == null) return;
|
||||||
floraSimplex = parent.getBoolean("flora.simplex.enable", false);
|
floraSimplex = parent.getYaml().getBoolean("flora.simplex.enable", false);
|
||||||
floraAttempts = parent.getInt("flora.attempts", 1);
|
floraAttempts = parent.getYaml().getInt("flora.attempts", 1);
|
||||||
floraChance = parent.getInt("flora.chance", 0);
|
floraChance = parent.getYaml().getInt("flora.chance", 0);
|
||||||
double floraFreq = parent.getDouble("flora.simplex.frequency", 0.1);
|
double floraFreq = parent.getYaml().getDouble("flora.simplex.frequency", 0.1);
|
||||||
int floraSeed = parent.getInt("flora.simplex.seed", 2403);
|
int floraSeed = parent.getYaml().getInt("flora.simplex.seed", 2403);
|
||||||
if(floraSimplex) {
|
if(floraSimplex) {
|
||||||
floraNoise = new FastNoiseLite(floraSeed);
|
floraNoise = new FastNoiseLite(floraSeed);
|
||||||
floraNoise.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
floraNoise.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
||||||
|
@ -22,8 +22,8 @@ public class BiomeOceanConfig extends TerraConfigSection {
|
|||||||
|
|
||||||
public BiomeOceanConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeOceanConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
seaLevel = parent.getInt("ocean.level", 62);
|
seaLevel = parent.getYaml().getInt("ocean.level", 62);
|
||||||
String oceanN = parent.getString("ocean.palette");
|
String oceanN = parent.getYaml().getString("ocean.palette");
|
||||||
if(oceanN != null) {
|
if(oceanN != null) {
|
||||||
if(oceanN.startsWith("BLOCK:")) {
|
if(oceanN.startsWith("BLOCK:")) {
|
||||||
try {
|
try {
|
||||||
|
@ -19,7 +19,7 @@ public class BiomeOreConfig extends TerraConfigSection {
|
|||||||
|
|
||||||
public BiomeOreConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeOreConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
ConfigurationSection c = parent.getConfigurationSection("ores");
|
ConfigurationSection c = parent.getYaml().getConfigurationSection("ores");
|
||||||
if(c == null) return;
|
if(c == null) return;
|
||||||
Map<String, Object> cfg = c.getValues(false);
|
Map<String, Object> cfg = c.getValues(false);
|
||||||
try {
|
try {
|
||||||
|
@ -21,7 +21,7 @@ public class BiomePaletteConfig extends TerraConfigSection {
|
|||||||
|
|
||||||
public BiomePaletteConfig(TerraConfig parent, String key) throws InvalidConfigurationException {
|
public BiomePaletteConfig(TerraConfig parent, String key) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
List<Map<?, ?>> cfg = parent.getMapList(key);
|
List<Map<?, ?>> cfg = parent.getYaml().getMapList(key);
|
||||||
if(cfg.size() == 0) return;
|
if(cfg.size() == 0) return;
|
||||||
paletteMap = new TreeMap<>();
|
paletteMap = new TreeMap<>();
|
||||||
for(Map<?, ?> e : cfg) {
|
for(Map<?, ?> e : cfg) {
|
||||||
|
@ -26,10 +26,10 @@ public class BiomeSlabConfig extends TerraConfigSection {
|
|||||||
|
|
||||||
public BiomeSlabConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeSlabConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
slabThreshold = parent.getDouble("slabs.threshold", 0.1D);
|
slabThreshold = parent.getYaml().getDouble("slabs.threshold", 0.1D);
|
||||||
slabs = getSlabPalettes(parent.getMapList("slabs.palettes"));
|
slabs = getSlabPalettes(parent.getYaml().getMapList("slabs.palettes"));
|
||||||
if(parent.contains("slabs.stair-palettes") && parent.getBoolean("slabs.use-stairs-if-available", false)) {
|
if(parent.getYaml().contains("slabs.stair-palettes") && parent.getYaml().getBoolean("slabs.use-stairs-if-available", false)) {
|
||||||
stairs = getSlabPalettes(parent.getMapList("slabs.stair-palettes"));
|
stairs = getSlabPalettes(parent.getYaml().getMapList("slabs.stair-palettes"));
|
||||||
} else stairs = new HashMap<>();
|
} else stairs = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class BiomeSnowConfig extends TerraConfigSection {
|
|||||||
public BiomeSnowConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeSnowConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
snowHeights = new int[256];
|
snowHeights = new int[256];
|
||||||
List<Map<?, ?>> maps = parent.getMapList("snow");
|
List<Map<?, ?>> maps = parent.getYaml().getMapList("snow");
|
||||||
if(maps.size() == 0) return;
|
if(maps.size() == 0) return;
|
||||||
try {
|
try {
|
||||||
for(Map<?, ?> e : maps) {
|
for(Map<?, ?> e : maps) {
|
||||||
|
@ -21,11 +21,11 @@ public class BiomeTreeConfig extends TerraConfigSection {
|
|||||||
|
|
||||||
public BiomeTreeConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeTreeConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
ConfigurationSection c = parent.getConfigurationSection("trees.items");
|
ConfigurationSection c = parent.getYaml().getConfigurationSection("trees.items");
|
||||||
if(c == null) return;
|
if(c == null) return;
|
||||||
Map<String, Object> cfg = c.getValues(false);
|
Map<String, Object> cfg = c.getValues(false);
|
||||||
if(cfg.size() == 0) return;
|
if(cfg.size() == 0) return;
|
||||||
treeDensity = parent.getInt("trees.density", 0);
|
treeDensity = parent.getYaml().getInt("trees.density", 0);
|
||||||
|
|
||||||
for(Map.Entry<String, Object> e : cfg.entrySet()) {
|
for(Map.Entry<String, Object> e : cfg.entrySet()) {
|
||||||
try {
|
try {
|
||||||
|
@ -38,11 +38,11 @@ public class StructureConfig extends TerraConfig {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public StructureConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public StructureConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
if(!contains("id")) throw new ConfigException("No ID specified!", "null");
|
if(!yaml.contains("id")) throw new ConfigException("No ID specified!", "null");
|
||||||
id = getString("id");
|
id = yaml.getString("id");
|
||||||
if(!contains("files")) throw new ConfigException("No files specified!", getID());
|
if(!yaml.contains("files")) throw new ConfigException("No files specified!", getID());
|
||||||
try {
|
try {
|
||||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("files")).getValues(false).entrySet()) {
|
for(Map.Entry<String, Object> e : Objects.requireNonNull(yaml.getConfigurationSection("files")).getValues(false).entrySet()) {
|
||||||
try {
|
try {
|
||||||
File structureFile = new File(config.getDataFolder() + File.separator + "structures" + File.separator + "data", e.getKey() + ".tstructure");
|
File structureFile = new File(config.getDataFolder() + File.separator + "structures" + File.separator + "data", e.getKey() + ".tstructure");
|
||||||
structure.add(Structure.load(structureFile), (Integer) e.getValue());
|
structure.add(Structure.load(structureFile), (Integer) e.getValue());
|
||||||
@ -58,10 +58,10 @@ public class StructureConfig extends TerraConfig {
|
|||||||
if(ConfigUtil.debug) {
|
if(ConfigUtil.debug) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
throw new NotFoundException("Structure", getString("file"), getID());
|
throw new NotFoundException("Structure", yaml.getString("file"), getID());
|
||||||
}
|
}
|
||||||
if(contains("loot")) {
|
if(yaml.contains("loot")) {
|
||||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("loot")).getValues(false).entrySet()) {
|
for(Map.Entry<String, Object> e : Objects.requireNonNull(yaml.getConfigurationSection("loot")).getValues(false).entrySet()) {
|
||||||
File lootFile = new File(config.getDataFolder() + File.separator + "structures" + File.separator + "loot", e.getValue().toString() + ".json");
|
File lootFile = new File(config.getDataFolder() + File.separator + "structures" + File.separator + "loot", e.getValue().toString() + ".json");
|
||||||
try {
|
try {
|
||||||
loot.put(Integer.valueOf(e.getKey()), new LootTable(FileUtils.readFileToString(lootFile)));
|
loot.put(Integer.valueOf(e.getKey()), new LootTable(FileUtils.readFileToString(lootFile)));
|
||||||
@ -80,8 +80,8 @@ public class StructureConfig extends TerraConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
features = new ArrayList<>();
|
features = new ArrayList<>();
|
||||||
if(contains("features")) {
|
if(yaml.contains("features")) {
|
||||||
for(Map<?, ?> map : getMapList("features")) {
|
for(Map<?, ?> map : yaml.getMapList("features")) {
|
||||||
for(Map.Entry<?, ?> entry : map.entrySet()) {
|
for(Map.Entry<?, ?> entry : map.entrySet()) {
|
||||||
if(entry.getKey().equals("ENTITY_FEATURE"))
|
if(entry.getKey().equals("ENTITY_FEATURE"))
|
||||||
features.add(new EntityFeatureConfig((Map<String, Object>) entry.getValue()).getFeature());
|
features.add(new EntityFeatureConfig((Map<String, Object>) entry.getValue()).getFeature());
|
||||||
@ -89,9 +89,9 @@ public class StructureConfig extends TerraConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn = new GridSpawn(getInt("spawn.width", 500), getInt("spawn.padding", 100));
|
spawn = new GridSpawn(yaml.getInt("spawn.width", 500), yaml.getInt("spawn.padding", 100));
|
||||||
searchStart = new Range(getInt("spawn.start.min", 72), getInt("spawn.start.max", 72));
|
searchStart = new Range(yaml.getInt("spawn.start.min", 72), yaml.getInt("spawn.start.max", 72));
|
||||||
bound = new Range(getInt("spawn.bound.min", 48), getInt("spawn.bound.max", 72));
|
bound = new Range(yaml.getInt("spawn.bound.min", 48), yaml.getInt("spawn.bound.max", 72));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,28 +1,20 @@
|
|||||||
package com.dfsek.terra.config.jackson;
|
package com.dfsek.terra.config.jackson;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer;
|
||||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class BlockDataDeserializer extends StdDeserializer<BlockData> {
|
public class BlockDataDeserializer extends FromStringDeserializer<BlockData> {
|
||||||
protected BlockDataDeserializer(Class<BlockData> vc) {
|
protected BlockDataDeserializer() {
|
||||||
super(vc);
|
super(BlockData.class);
|
||||||
}
|
|
||||||
|
|
||||||
protected BlockDataDeserializer(JavaType valueType) {
|
|
||||||
super(valueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BlockDataDeserializer(StdDeserializer<BlockData> src) {
|
|
||||||
super(src);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("RedundantThrows")
|
||||||
@Override
|
@Override
|
||||||
public BlockData deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
protected BlockData _deserialize(String value, DeserializationContext ctxt) throws IOException {
|
||||||
return null;
|
return Bukkit.createBlockData(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,24 @@
|
|||||||
package com.dfsek.terra.config.jackson;
|
package com.dfsek.terra.config.jackson;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParseException;
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer;
|
||||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class MaterialDeserializer extends StdDeserializer<Material> {
|
public class MaterialDeserializer extends FromStringDeserializer<Material> {
|
||||||
protected MaterialDeserializer(Class<Material> vc) {
|
protected MaterialDeserializer() {
|
||||||
super(vc);
|
super(Material.class);
|
||||||
}
|
|
||||||
|
|
||||||
protected MaterialDeserializer(JavaType valueType) {
|
|
||||||
super(valueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MaterialDeserializer(StdDeserializer<Material> src) {
|
|
||||||
super(src);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
protected Material _deserialize(String value, DeserializationContext ctxt) throws IOException {
|
||||||
try {
|
try {
|
||||||
return Bukkit.createBlockData(Objects.requireNonNull(p.getValueAsString())).getMaterial();
|
return Bukkit.createBlockData(value).getMaterial();
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
throw new JsonParseException(p, "This is not a valid block.", e);
|
throw new JsonParseException(ctxt.getParser(), "This is not a valid block.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,121 @@
|
|||||||
package com.dfsek.terra.config.jackson;
|
package com.dfsek.terra.config.jackson;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.JsonToken;
|
||||||
|
import com.fasterxml.jackson.databind.AnnotationIntrospector;
|
||||||
|
import com.fasterxml.jackson.databind.BeanProperty;
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
import com.fasterxml.jackson.databind.KeyDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.deser.ContextualKeyDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.deser.NullValueProvider;
|
||||||
|
import com.fasterxml.jackson.databind.deser.std.ContainerDeserializerBase;
|
||||||
|
import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
|
||||||
import org.polydev.gaea.math.ProbabilityCollection;
|
import org.polydev.gaea.math.ProbabilityCollection;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ProbabilityCollectionDeserializer<T> extends StdDeserializer<ProbabilityCollection<T>> {
|
public class ProbabilityCollectionDeserializer extends ContainerDeserializerBase<ProbabilityCollection<Object>> implements ContextualDeserializer {
|
||||||
private static final ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
protected ProbabilityCollectionDeserializer(Class<ProbabilityCollection<java.lang.String>> vc) {
|
protected final TypeDeserializer _valueTypeDeserializer;
|
||||||
super(vc);
|
protected KeyDeserializer _keyDeserializer;
|
||||||
}
|
protected JsonDeserializer<?> _valueDeserializer;
|
||||||
|
|
||||||
protected ProbabilityCollectionDeserializer(JavaType valueType) {
|
public ProbabilityCollectionDeserializer(JavaType type, KeyDeserializer keyDeser, JsonDeserializer<?> valueDeser,
|
||||||
super(valueType);
|
TypeDeserializer valueTypeDeser, NullValueProvider nuller) {
|
||||||
}
|
super(type, nuller, null);
|
||||||
|
_keyDeserializer = keyDeser;
|
||||||
protected ProbabilityCollectionDeserializer(StdDeserializer<ProbabilityCollection<java.lang.String>> src) {
|
_valueDeserializer = valueDeser;
|
||||||
super(src);
|
_valueTypeDeserializer = valueTypeDeser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProbabilityCollection<T> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
|
||||||
JsonNode rootNode = p.getCodec().readTree(p);
|
BeanProperty property) throws JsonMappingException {
|
||||||
|
KeyDeserializer keyDeser = _keyDeserializer;
|
||||||
ProbabilityCollection<T> collection = new ProbabilityCollection<>();
|
if(keyDeser == null) {
|
||||||
|
keyDeser = ctxt.findKeyDeserializer(_containerType.getKeyType(), property);
|
||||||
Iterator<Map.Entry<String, JsonNode>> it = rootNode.fields();
|
} else {
|
||||||
while(it.hasNext()) {
|
if(keyDeser instanceof ContextualKeyDeserializer) {
|
||||||
Map.Entry<String, JsonNode> currentNode = it.next();
|
keyDeser = ((ContextualKeyDeserializer) keyDeser).createContextual(ctxt, property);
|
||||||
|
}
|
||||||
collection.add(mapper.readValue(currentNode.getKey(), new TypeReference<T>() {
|
|
||||||
}), currentNode.getValue().numberValue().intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return collection;
|
JsonDeserializer<?> valueDeser = _valueDeserializer;
|
||||||
|
// [databind#125]: May have a content converter
|
||||||
|
if(property != null) {
|
||||||
|
valueDeser = findConvertingContentDeserializer(ctxt, property, valueDeser);
|
||||||
|
}
|
||||||
|
final JavaType vt = _containerType.getContentType();
|
||||||
|
if(valueDeser == null) {
|
||||||
|
valueDeser = ctxt.findContextualValueDeserializer(vt, property);
|
||||||
|
} else { // if directly assigned, probably not yet contextual, so:
|
||||||
|
valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt);
|
||||||
|
}
|
||||||
|
TypeDeserializer vtd = _valueTypeDeserializer;
|
||||||
|
if(vtd != null) {
|
||||||
|
vtd = vtd.forProperty(property);
|
||||||
|
}
|
||||||
|
AnnotationIntrospector intr = ctxt.getAnnotationIntrospector();
|
||||||
|
return withResolved(keyDeser, vtd, valueDeser,
|
||||||
|
findContentNullProvider(ctxt, property, valueDeser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ProbabilityCollectionDeserializer withResolved(KeyDeserializer keyDeser, TypeDeserializer valueTypeDeser,
|
||||||
|
JsonDeserializer<?> valueDeser, NullValueProvider nuller) {
|
||||||
|
if((_keyDeserializer == keyDeser) && (_valueDeserializer == valueDeser)
|
||||||
|
&& (_valueTypeDeserializer == valueTypeDeser) && (_nullProvider == nuller)) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return new ProbabilityCollectionDeserializer(_containerType, keyDeser, valueDeser, valueTypeDeser, nuller);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public JsonDeserializer<Object> getContentDeserializer() {
|
||||||
|
return (JsonDeserializer<Object>) _valueDeserializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public ProbabilityCollection<Object> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||||
|
// Ok: must point to START_OBJECT, FIELD_NAME or END_OBJECT
|
||||||
|
JsonToken t = p.getCurrentToken();
|
||||||
|
if(t != JsonToken.START_OBJECT) {
|
||||||
|
return (ProbabilityCollection<Object>) ctxt.handleUnexpectedToken(getValueType(ctxt), t, p, null);
|
||||||
|
}
|
||||||
|
final ProbabilityCollection<Object> result = new ProbabilityCollection<>();
|
||||||
|
_readAndBind(p, ctxt, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void _readAndBind(JsonParser p, DeserializationContext ctxt,
|
||||||
|
ProbabilityCollection<Object> result) throws IOException {
|
||||||
|
final KeyDeserializer keyDes = _keyDeserializer;
|
||||||
|
|
||||||
|
String keyStr;
|
||||||
|
if(p.isExpectedStartObjectToken()) {
|
||||||
|
keyStr = p.nextFieldName();
|
||||||
|
} else {
|
||||||
|
JsonToken t = p.getCurrentToken();
|
||||||
|
if(t == JsonToken.END_OBJECT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctxt.reportWrongTokenException(this, JsonToken.FIELD_NAME, null);
|
||||||
|
keyStr = p.getCurrentName();
|
||||||
|
}
|
||||||
|
|
||||||
|
while(keyStr != null) {
|
||||||
|
Object key = keyDes.deserializeKey(keyStr, ctxt);
|
||||||
|
int value = _parseIntPrimitive(ctxt, p.nextToken().asString());
|
||||||
|
result.add(key, value);
|
||||||
|
|
||||||
|
|
||||||
|
keyStr = p.nextFieldName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.dfsek.terra.config.jackson;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.*;
|
||||||
|
import com.fasterxml.jackson.databind.deser.Deserializers;
|
||||||
|
import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.type.MapLikeType;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.polydev.gaea.math.ProbabilityCollection;
|
||||||
|
|
||||||
|
|
||||||
|
public class TerraDeserializers extends Deserializers.Base {
|
||||||
|
public TerraDeserializers() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonDeserializer<?> findEnumDeserializer(Class<?> type, DeserializationConfig config,
|
||||||
|
BeanDescription beanDesc) throws JsonMappingException {
|
||||||
|
if (type.isAssignableFrom(Material.class))
|
||||||
|
return new MaterialDeserializer();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config,
|
||||||
|
BeanDescription beanDesc) throws JsonMappingException {
|
||||||
|
if (type.hasRawClass(BlockData.class))
|
||||||
|
return new BlockDataDeserializer();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config,
|
||||||
|
BeanDescription beanDesc, KeyDeserializer keyDeserializer,
|
||||||
|
TypeDeserializer elementTypeDeserializer,
|
||||||
|
JsonDeserializer<?> elementDeserializer) throws JsonMappingException {
|
||||||
|
Class<?> raw = type.getRawClass();
|
||||||
|
if (ProbabilityCollection.class.isAssignableFrom(raw))
|
||||||
|
return new ProbabilityCollectionDeserializer(type, keyDeserializer, elementDeserializer, elementTypeDeserializer, null);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasDeserializerFor(DeserializationConfig config, Class<?> valueType) {
|
||||||
|
return (valueType == ProbabilityCollection.class)
|
||||||
|
|| false;
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,25 @@
|
|||||||
package com.dfsek.terra.config.jackson;
|
package com.dfsek.terra.config.jackson;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.util.VersionUtil;
|
import com.fasterxml.jackson.core.Version;
|
||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
import com.fasterxml.jackson.databind.Module;
|
||||||
|
|
||||||
public class TerraModule extends SimpleModule {
|
public class TerraModule extends Module {
|
||||||
|
|
||||||
public TerraModule() {
|
public TerraModule() {
|
||||||
super("TerraModule", VersionUtil.parseVersion("@projectVersion@", "@projectGroupId@", "@projectArtifactId@"));
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() {
|
||||||
|
return "TerraModule";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Version version() {
|
||||||
|
return new Version(0, 0, 0, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setupModule(SetupContext context) {
|
||||||
|
context.addDeserializers(new TerraDeserializers());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
package com.dfsek.terra.generation.entities;
|
|
||||||
|
|
||||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
|
||||||
import com.dfsek.terra.generation.deserelized.GenerationEntity;
|
|
||||||
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 GenerationEntity {
|
|
||||||
private final UserDefinedCarver carver;
|
|
||||||
private final String id;
|
|
||||||
private final Set<Material> update;
|
|
||||||
private final Map<Material, Set<Material>> shift;
|
|
||||||
private final Map<Integer, ProbabilityCollection<BlockData>> inner;
|
|
||||||
private final Map<Integer, ProbabilityCollection<BlockData>> outer;
|
|
||||||
private final Map<Integer, ProbabilityCollection<BlockData>> top;
|
|
||||||
private final Map<Integer, ProbabilityCollection<BlockData>> bottom;
|
|
||||||
private final boolean updateOcean;
|
|
||||||
private final boolean replaceIsBlacklistInner;
|
|
||||||
private final boolean replaceIsBlacklistOuter;
|
|
||||||
private final boolean replaceIsBlacklistTop;
|
|
||||||
private final boolean replaceIsBlacklistBottom;
|
|
||||||
private final Set<Material> replaceableInner;
|
|
||||||
private final Set<Material> replaceableOuter;
|
|
||||||
private final Set<Material> replaceableTop;
|
|
||||||
private final Set<Material> replaceableBottom;
|
|
||||||
|
|
||||||
public Carver(UserDefinedCarver carver, String id, Set<Material> update, Map<Material, Set<Material>> shift,
|
|
||||||
Map<Integer, ProbabilityCollection<BlockData>> inner, Map<Integer, ProbabilityCollection<BlockData>> outer,
|
|
||||||
Map<Integer, ProbabilityCollection<BlockData>> top, Map<Integer, ProbabilityCollection<BlockData>> bottom,
|
|
||||||
boolean updateOcean, ReplaceableCarverConfig config) {
|
|
||||||
this.carver = carver;
|
|
||||||
this.id = id;
|
|
||||||
this.update = update;
|
|
||||||
this.shift = shift;
|
|
||||||
this.inner = inner;
|
|
||||||
this.outer = outer;
|
|
||||||
this.top = top;
|
|
||||||
this.bottom = bottom;
|
|
||||||
this.updateOcean = updateOcean;
|
|
||||||
this.replaceIsBlacklistInner = config.replaceIsBlacklistInner;
|
|
||||||
this.replaceIsBlacklistOuter = config.replaceIsBlacklistOuter;
|
|
||||||
this.replaceIsBlacklistTop = config.replaceIsBlacklistTop;
|
|
||||||
this.replaceIsBlacklistBottom = config.replaceIsBlacklistBottom;
|
|
||||||
this.replaceableInner = config.replaceableInner;
|
|
||||||
this.replaceableOuter = config.replaceableOuter;
|
|
||||||
this.replaceableTop = config.replaceableTop;
|
|
||||||
this.replaceableBottom = config.replaceableBottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generate(Location location, Random random, JavaPlugin plugin) {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidLocation(Location location, JavaPlugin plugin) {
|
|
||||||
return false; //TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ReplaceableCarverConfig {
|
|
||||||
private final boolean replaceIsBlacklistInner;
|
|
||||||
private final boolean replaceIsBlacklistOuter;
|
|
||||||
private final boolean replaceIsBlacklistTop;
|
|
||||||
private final boolean replaceIsBlacklistBottom;
|
|
||||||
private final Set<Material> replaceableInner;
|
|
||||||
private final Set<Material> replaceableOuter;
|
|
||||||
private final Set<Material> replaceableTop;
|
|
||||||
private final Set<Material> replaceableBottom;
|
|
||||||
|
|
||||||
public ReplaceableCarverConfig(boolean replaceIsBlacklistInner, boolean replaceIsBlacklistOuter, boolean replaceIsBlacklistTop, boolean replaceIsBlacklistBottom, Set<Material> replaceableInner, Set<Material> replaceableOuter, Set<Material> replaceableTop, Set<Material> replaceableBottom) {
|
|
||||||
this.replaceIsBlacklistInner = replaceIsBlacklistInner;
|
|
||||||
this.replaceIsBlacklistOuter = replaceIsBlacklistOuter;
|
|
||||||
this.replaceIsBlacklistTop = replaceIsBlacklistTop;
|
|
||||||
this.replaceIsBlacklistBottom = replaceIsBlacklistBottom;
|
|
||||||
this.replaceableInner = replaceableInner;
|
|
||||||
this.replaceableOuter = replaceableOuter;
|
|
||||||
this.replaceableTop = replaceableTop;
|
|
||||||
this.replaceableBottom = replaceableBottom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user