mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
Begin work on config cleanup
This commit is contained in:
parent
b820d11f49
commit
65d50d7def
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@ -51,5 +51,10 @@
|
|||||||
<option name="name" value="gaea-local" />
|
<option name="name" value="gaea-local" />
|
||||||
<option name="url" value="file:$PROJECT_DIR$/../Gaea/repo" />
|
<option name="url" value="file:$PROJECT_DIR$/../Gaea/repo" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="CodeMC" />
|
||||||
|
<option name="name" value="CodeMC" />
|
||||||
|
<option name="url" value="https://repo.codemc.org/repository/maven-public" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
14
pom.xml
14
pom.xml
@ -33,6 +33,10 @@
|
|||||||
<pattern>org.apache.commons</pattern>
|
<pattern>org.apache.commons</pattern>
|
||||||
<shadedPattern>com.dfsek.terra.lib.commons</shadedPattern>
|
<shadedPattern>com.dfsek.terra.lib.commons</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.bstats.bukkit</pattern>
|
||||||
|
<shadedPattern>com.dfsek.terra.lib.bstats</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
@ -64,6 +68,10 @@
|
|||||||
<id>enginehub-maven</id>
|
<id>enginehub-maven</id>
|
||||||
<url>http://maven.enginehub.org/repo/</url>
|
<url>http://maven.enginehub.org/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>CodeMC</id>
|
||||||
|
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -106,6 +114,12 @@
|
|||||||
<version>RELEASE</version>
|
<version>RELEASE</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -3,6 +3,7 @@ package com.dfsek.terra;
|
|||||||
import com.dfsek.terra.command.TerraCommand;
|
import com.dfsek.terra.command.TerraCommand;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -14,7 +15,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Terra extends JavaPlugin {
|
public class Terra extends JavaPlugin {
|
||||||
private static FileConfiguration config;
|
|
||||||
private static Terra instance;
|
private static Terra instance;
|
||||||
|
|
||||||
public static Terra getInstance() {
|
public static Terra getInstance() {
|
||||||
@ -29,6 +29,8 @@ public class Terra extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
Metrics metrics = new Metrics(this, 9017);
|
||||||
|
metrics.addCustomChart(new Metrics.SingleLineChart("worlds", TerraWorld::numWorlds));
|
||||||
Debug.setMain(this);
|
Debug.setMain(this);
|
||||||
ConfigUtil.loadConfig(this);
|
ConfigUtil.loadConfig(this);
|
||||||
|
|
||||||
@ -38,7 +40,6 @@ public class Terra extends JavaPlugin {
|
|||||||
c.setTabCompleter(command);
|
c.setTabCompleter(command);
|
||||||
|
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
config = getConfig();
|
|
||||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, TerraChunkGenerator::saveAll, ConfigUtil.dataSave, ConfigUtil.dataSave);
|
Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, TerraChunkGenerator::saveAll, ConfigUtil.dataSave, ConfigUtil.dataSave);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.dfsek.terra.biome.BiomeZone;
|
|||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.biome.UserDefinedGrid;
|
import com.dfsek.terra.biome.UserDefinedGrid;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
import com.dfsek.terra.config.base.WorldConfig;
|
||||||
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
||||||
@ -18,7 +18,7 @@ public class TerraWorld {
|
|||||||
private static final Map<World, TerraWorld> map = new HashMap<>();
|
private static final Map<World, TerraWorld> map = new HashMap<>();
|
||||||
private final TerraBiomeGrid grid;
|
private final TerraBiomeGrid grid;
|
||||||
private final BiomeZone zone;
|
private final BiomeZone zone;
|
||||||
private final TerraConfig config;
|
private final ConfigPack config;
|
||||||
private final WorldConfig worldConfig;
|
private final WorldConfig worldConfig;
|
||||||
private TerraWorld(World w) {
|
private TerraWorld(World w) {
|
||||||
worldConfig = new WorldConfig(w, Terra.getInstance());
|
worldConfig = new WorldConfig(w, Terra.getInstance());
|
||||||
@ -50,7 +50,7 @@ public class TerraWorld {
|
|||||||
grid = new TerraBiomeGrid(w, config.freq1, config.freq2, zone, config);
|
grid = new TerraBiomeGrid(w, config.freq1, config.freq2, zone, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TerraWorld getWorld(World w) {
|
public static synchronized TerraWorld getWorld(World w) {
|
||||||
return map.computeIfAbsent(w, TerraWorld::new);
|
return map.computeIfAbsent(w, TerraWorld::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class TerraWorld {
|
|||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerraConfig getConfig() {
|
public ConfigPack getConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,11 @@ public class TerraWorld {
|
|||||||
return zone;
|
return zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void invalidate() {
|
public static synchronized void invalidate() {
|
||||||
map.clear();
|
map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int numWorlds() {
|
||||||
|
return map.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
package com.dfsek.terra.biome;
|
package com.dfsek.terra.biome;
|
||||||
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.polydev.gaea.biome.Biome;
|
import org.polydev.gaea.biome.Biome;
|
||||||
import org.polydev.gaea.biome.BiomeGrid;
|
import org.polydev.gaea.biome.BiomeGrid;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class TerraBiomeGrid extends BiomeGrid {
|
public class TerraBiomeGrid extends BiomeGrid {
|
||||||
private static int failNum = 0;
|
private static int failNum = 0;
|
||||||
private CoordinatePerturb perturb;
|
private CoordinatePerturb perturb;
|
||||||
@ -21,7 +16,7 @@ public class TerraBiomeGrid extends BiomeGrid {
|
|||||||
private final BiomeZone zone;
|
private final BiomeZone zone;
|
||||||
private final boolean perturbPaletteOnly;
|
private final boolean perturbPaletteOnly;
|
||||||
|
|
||||||
public TerraBiomeGrid(World w, float freq1, float freq2, BiomeZone zone, TerraConfig c) {
|
public TerraBiomeGrid(World w, float freq1, float freq2, BiomeZone zone, ConfigPack c) {
|
||||||
super(w, freq1, freq2);
|
super(w, freq1, freq2);
|
||||||
if(c.biomeBlend) {
|
if(c.biomeBlend) {
|
||||||
perturb = new CoordinatePerturb(c.blendFreq, c.blendAmp, w.getSeed());
|
perturb = new CoordinatePerturb(c.blendFreq, c.blendAmp, w.getSeed());
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
package com.dfsek.terra.carving;
|
package com.dfsek.terra.carving;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
|
||||||
import org.polydev.gaea.math.Range;
|
import org.polydev.gaea.math.Range;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
import org.polydev.gaea.world.carving.Carver;
|
import org.polydev.gaea.world.carving.Carver;
|
||||||
import org.polydev.gaea.world.carving.Worm;
|
import org.polydev.gaea.world.carving.Worm;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class UserDefinedCarver extends Carver {
|
public class UserDefinedCarver extends Carver {
|
||||||
@ -47,7 +42,7 @@ public class UserDefinedCarver extends Carver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
||||||
TerraConfig c = TerraWorld.getWorld(w).getConfig();
|
ConfigPack c = TerraWorld.getWorld(w).getConfig();
|
||||||
return new Random(random.nextLong()+hash).nextInt(100) < c.getBiome((UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
|
return new Random(random.nextLong()+hash).nextInt(100) < c.getBiome((UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ConfigLoader {
|
public class ConfigLoader {
|
||||||
public static <T extends TerraConfigObject> Map<String, T> load(JavaPlugin main, Path file, TerraConfig config, Class<T> clazz) {
|
public static <T extends TerraConfig> Map<String, T> load(JavaPlugin main, Path file, ConfigPack config, Class<T> clazz) {
|
||||||
long l = System.nanoTime();
|
long l = System.nanoTime();
|
||||||
Map<String, T> configs = new HashMap<>();
|
Map<String, T> configs = new HashMap<>();
|
||||||
file.toFile().mkdirs();
|
file.toFile().mkdirs();
|
||||||
@ -27,7 +27,7 @@ public class ConfigLoader {
|
|||||||
paths.filter(path -> FilenameUtils.wildcardMatch(path.toFile().getName(), "*.yml"))
|
paths.filter(path -> FilenameUtils.wildcardMatch(path.toFile().getName(), "*.yml"))
|
||||||
.forEach(path -> {
|
.forEach(path -> {
|
||||||
try {
|
try {
|
||||||
Constructor<T> c = clazz.getConstructor(File.class, TerraConfig.class);
|
Constructor<T> c = clazz.getConstructor(File.class, ConfigPack.class);
|
||||||
T o = c.newInstance(path.toFile(), config);
|
T o = c.newInstance(path.toFile(), config);
|
||||||
if(ids.contains(o.getID())) Bukkit.getLogger().severe("Duplicate ID found in file: " + path.toString());
|
if(ids.contains(o.getID())) Bukkit.getLogger().severe("Duplicate ID found in file: " + path.toString());
|
||||||
ids.add(o.getID());
|
ids.add(o.getID());
|
||||||
|
191
src/main/java/com/dfsek/terra/config/ConfigPack.java
Normal file
191
src/main/java/com/dfsek/terra/config/ConfigPack.java
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
package com.dfsek.terra.config;
|
||||||
|
|
||||||
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
|
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||||
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
|
import com.dfsek.terra.config.genconfig.biome.AbstractBiomeConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.FloraConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.PaletteConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.StructureConfig;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ConfigPack extends YamlConfiguration {
|
||||||
|
private static final Map<String, ConfigPack> configs = new HashMap<>();
|
||||||
|
private final Map<String, OreConfig> ores;
|
||||||
|
private final Map<String, PaletteConfig> palettes;
|
||||||
|
private final Map<String, CarverConfig> carvers;
|
||||||
|
private final Map<String, FloraConfig> flora;
|
||||||
|
private final Map<String, StructureConfig> structures;
|
||||||
|
private final Map<String, AbstractBiomeConfig> abstractBiomes;
|
||||||
|
private final Map<String, BiomeConfig> biomes;
|
||||||
|
private final Map<String, BiomeGridConfig> grids;
|
||||||
|
private final File dataFolder;
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
|
||||||
|
public List<String> biomeList;
|
||||||
|
|
||||||
|
public float zoneFreq;
|
||||||
|
public float freq1;
|
||||||
|
public float freq2;
|
||||||
|
|
||||||
|
public int blendAmp;
|
||||||
|
public boolean biomeBlend;
|
||||||
|
public float blendFreq;
|
||||||
|
public boolean perturbPaletteOnly;
|
||||||
|
|
||||||
|
public ConfigPack(JavaPlugin main, File file) throws IOException, InvalidConfigurationException {
|
||||||
|
long l = System.nanoTime();
|
||||||
|
load(new File(file, "config.yml"));
|
||||||
|
dataFolder = file;
|
||||||
|
Logger logger = main.getLogger();
|
||||||
|
|
||||||
|
if(!contains("id")) throw new ConfigException("No ID specified!", "null");
|
||||||
|
this.id = getString("id");
|
||||||
|
|
||||||
|
ores = ConfigLoader.load(main, new File(file, "ores").toPath(), this, OreConfig.class);
|
||||||
|
|
||||||
|
palettes = ConfigLoader.load(main, new File(file, "palettes").toPath(), this, PaletteConfig.class);
|
||||||
|
|
||||||
|
carvers = ConfigLoader.load(main, new File(file, "carving").toPath(), this, CarverConfig.class);
|
||||||
|
|
||||||
|
flora = ConfigLoader.load(main, new File(file, "flora").toPath(), this, FloraConfig.class);
|
||||||
|
|
||||||
|
structures = ConfigLoader.load(main, new File(file, "structures").toPath(), this, StructureConfig.class);
|
||||||
|
|
||||||
|
abstractBiomes = ConfigLoader.load(main, new File(file, "abstract" + File.separator + "biomes").toPath(), this, AbstractBiomeConfig.class);
|
||||||
|
|
||||||
|
biomes = ConfigLoader.load(main, new File(file, "biomes").toPath(), this, BiomeConfig.class);
|
||||||
|
|
||||||
|
grids = ConfigLoader.load(main, new File(file, "grids").toPath(), this, BiomeGridConfig.class);
|
||||||
|
|
||||||
|
zoneFreq = 1f/getInt("frequencies.zone", 1536);
|
||||||
|
freq1 = 1f/getInt("frequencies.grid-x", 256);
|
||||||
|
freq2 = 1f/getInt("frequencies.grid-z", 512);
|
||||||
|
|
||||||
|
biomeBlend = getBoolean("blend.enable", false);
|
||||||
|
blendAmp = getInt("blend.amplitude", 8);
|
||||||
|
blendFreq = (float) getDouble("blend.frequency", 0.01);
|
||||||
|
perturbPaletteOnly = getBoolean("blend.ignore-terrain", true);
|
||||||
|
|
||||||
|
// Load BiomeGrids from BiomeZone
|
||||||
|
biomeList = getStringList("grids");
|
||||||
|
|
||||||
|
configs.put(id, this);
|
||||||
|
logger.info("\n\nLoaded config \"" + getID() + "\" in " + (System.nanoTime() - l)/1000000D + "ms\n\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, AbstractBiomeConfig> getAbstractBiomes() {
|
||||||
|
return abstractBiomes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, BiomeConfig> getBiomes() {
|
||||||
|
return biomes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, CarverConfig> getCarvers() {
|
||||||
|
return carvers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadAll(JavaPlugin main) {
|
||||||
|
configs.clear();
|
||||||
|
List<Path> subfolder;
|
||||||
|
try {
|
||||||
|
subfolder = Files.walk(new File(main.getDataFolder(), "config").toPath(), 1)
|
||||||
|
.filter(Files::isDirectory)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
} catch(IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
subfolder.remove(0);
|
||||||
|
for(Path folder : subfolder) {
|
||||||
|
ConfigPack config;
|
||||||
|
try {
|
||||||
|
config = new ConfigPack(main, folder.toFile());
|
||||||
|
configs.put(config.getID(), config);
|
||||||
|
} catch(IOException | InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getDataFolder() {
|
||||||
|
return dataFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConfigPack fromID(String id) {
|
||||||
|
return configs.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeConfig getBiome(UserDefinedBiome b) {
|
||||||
|
for(BiomeConfig biome : biomes.values()) {
|
||||||
|
if(biome.getBiome().equals(b)) return biome;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("No BiomeConfig for provided biome.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeConfig getBiome(String id) {
|
||||||
|
return biomes.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarverConfig getCarver(String id) {
|
||||||
|
return carvers.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarverConfig getCarver(UserDefinedCarver c) {
|
||||||
|
for(CarverConfig co : carvers.values()) {
|
||||||
|
if(co.getCarver().equals(c)) return co;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unable to find carver!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructureConfig getStructure(String id) {
|
||||||
|
return structures.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaletteConfig getPalette(String id) {
|
||||||
|
return palettes.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OreConfig getOre(String id) {
|
||||||
|
return ores.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBiomeIDs() {
|
||||||
|
List<String> fill = new ArrayList<>();
|
||||||
|
for(BiomeConfig b : biomes.values()) {
|
||||||
|
fill.add(b.getID());
|
||||||
|
}
|
||||||
|
return fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FloraConfig getFlora(String id) {
|
||||||
|
return flora.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeGridConfig getBiomeGrid(String id) {
|
||||||
|
return grids.get(id);
|
||||||
|
}
|
||||||
|
}
|
@ -1,193 +1,21 @@
|
|||||||
package com.dfsek.terra.config;
|
package com.dfsek.terra.config;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
|
||||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
|
||||||
import com.dfsek.terra.config.genconfig.AbstractBiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.FloraConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.PaletteConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.StructureConfig;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class TerraConfig extends YamlConfiguration {
|
public abstract class TerraConfig extends YamlConfiguration {
|
||||||
private static final Map<String, TerraConfig> configs = new HashMap<>();
|
private final ConfigPack config;
|
||||||
private final Map<String, OreConfig> ores;
|
public TerraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
private final Map<String, PaletteConfig> palettes;
|
load(file);
|
||||||
private final Map<String, CarverConfig> carvers;
|
this.config = config;
|
||||||
private final Map<String, FloraConfig> flora;
|
|
||||||
private final Map<String, StructureConfig> structures;
|
|
||||||
private final Map<String, AbstractBiomeConfig> abstractBiomes;
|
|
||||||
private final Map<String, BiomeConfig> biomes;
|
|
||||||
private final Map<String, BiomeGridConfig> grids;
|
|
||||||
private final File dataFolder;
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
|
|
||||||
public List<String> biomeList;
|
|
||||||
|
|
||||||
public float zoneFreq;
|
|
||||||
public float freq1;
|
|
||||||
public float freq2;
|
|
||||||
|
|
||||||
public int blendAmp;
|
|
||||||
public boolean biomeBlend;
|
|
||||||
public float blendFreq;
|
|
||||||
public boolean perturbPaletteOnly;
|
|
||||||
|
|
||||||
public TerraConfig(JavaPlugin main, File file) throws IOException, InvalidConfigurationException {
|
|
||||||
long l = System.nanoTime();
|
|
||||||
load(new File(file, "config.yml"));
|
|
||||||
dataFolder = file;
|
|
||||||
Logger logger = main.getLogger();
|
|
||||||
|
|
||||||
if(!contains("id")) throw new ConfigException("No ID specified!", "null");
|
|
||||||
this.id = getString("id");
|
|
||||||
|
|
||||||
ores = ConfigLoader.load(main, new File(file, "ores").toPath(), this, OreConfig.class);
|
|
||||||
|
|
||||||
palettes = ConfigLoader.load(main, new File(file, "palettes").toPath(), this, PaletteConfig.class);
|
|
||||||
|
|
||||||
carvers = ConfigLoader.load(main, new File(file, "carving").toPath(), this, CarverConfig.class);
|
|
||||||
|
|
||||||
flora = ConfigLoader.load(main, new File(file, "flora").toPath(), this, FloraConfig.class);
|
|
||||||
|
|
||||||
structures = ConfigLoader.load(main, new File(file, "structures").toPath(), this, StructureConfig.class);
|
|
||||||
|
|
||||||
abstractBiomes = ConfigLoader.load(main, new File(file, "abstract" + File.separator + "biomes").toPath(), this, AbstractBiomeConfig.class);
|
|
||||||
|
|
||||||
biomes = ConfigLoader.load(main, new File(file, "biomes").toPath(), this, BiomeConfig.class);
|
|
||||||
|
|
||||||
grids = ConfigLoader.load(main, new File(file, "grids").toPath(), this, BiomeGridConfig.class);
|
|
||||||
|
|
||||||
zoneFreq = 1f/getInt("frequencies.zone", 1536);
|
|
||||||
freq1 = 1f/getInt("frequencies.grid-x", 256);
|
|
||||||
freq2 = 1f/getInt("frequencies.grid-z", 512);
|
|
||||||
|
|
||||||
biomeBlend = getBoolean("blend.enable", false);
|
|
||||||
blendAmp = getInt("blend.amplitude", 8);
|
|
||||||
blendFreq = (float) getDouble("blend.frequency", 0.01);
|
|
||||||
perturbPaletteOnly = getBoolean("blend.ignore-terrain", true);
|
|
||||||
|
|
||||||
// Load BiomeGrids from BiomeZone
|
|
||||||
biomeList = getStringList("grids");
|
|
||||||
|
|
||||||
configs.put(id, this);
|
|
||||||
logger.info("\n\nLoaded config \"" + getID() + "\" in " + (System.nanoTime() - l)/1000000D + "ms\n\n\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, AbstractBiomeConfig> getAbstractBiomes() {
|
public ConfigPack getConfig() {
|
||||||
return abstractBiomes;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, BiomeConfig> getBiomes() {
|
public abstract String getID();
|
||||||
return biomes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, CarverConfig> getCarvers() {
|
|
||||||
return carvers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadAll(JavaPlugin main) {
|
|
||||||
configs.clear();
|
|
||||||
List<Path> subfolder;
|
|
||||||
try {
|
|
||||||
subfolder = Files.walk(new File(main.getDataFolder(), "config").toPath(), 1)
|
|
||||||
.filter(Files::isDirectory)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
subfolder.remove(0);
|
|
||||||
for(Path folder : subfolder) {
|
|
||||||
TerraConfig config;
|
|
||||||
try {
|
|
||||||
config = new TerraConfig(main, folder.toFile());
|
|
||||||
configs.put(config.getID(), config);
|
|
||||||
} catch(IOException | InvalidConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getDataFolder() {
|
|
||||||
return dataFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TerraConfig fromID(String id) {
|
|
||||||
return configs.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BiomeConfig getBiome(UserDefinedBiome b) {
|
|
||||||
for(BiomeConfig biome : biomes.values()) {
|
|
||||||
if(biome.getBiome().equals(b)) return biome;
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("No BiomeConfig for provided biome.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public BiomeConfig getBiome(String id) {
|
|
||||||
return biomes.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarverConfig getCarver(String id) {
|
|
||||||
return carvers.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarverConfig getCarver(UserDefinedCarver c) {
|
|
||||||
for(CarverConfig co : carvers.values()) {
|
|
||||||
if(co.getCarver().equals(c)) return co;
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Unable to find carver!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public StructureConfig getStructure(String id) {
|
|
||||||
return structures.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PaletteConfig getPalette(String id) {
|
|
||||||
return palettes.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OreConfig getOre(String id) {
|
|
||||||
return ores.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getBiomeIDs() {
|
|
||||||
List<String> fill = new ArrayList<>();
|
|
||||||
for(BiomeConfig b : biomes.values()) {
|
|
||||||
fill.add(b.getID());
|
|
||||||
}
|
|
||||||
return fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FloraConfig getFlora(String id) {
|
|
||||||
return flora.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BiomeGridConfig getBiomeGrid(String id) {
|
|
||||||
return grids.get(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package com.dfsek.terra.config;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public abstract class TerraConfigObject extends YamlConfiguration {
|
|
||||||
private final TerraConfig config;
|
|
||||||
public TerraConfigObject(File file, TerraConfig config) throws IOException, InvalidConfigurationException {
|
|
||||||
load(file);
|
|
||||||
this.config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TerraConfig getConfig() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getID();
|
|
||||||
}
|
|
14
src/main/java/com/dfsek/terra/config/TerraConfigSection.java
Normal file
14
src/main/java/com/dfsek/terra/config/TerraConfigSection.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.dfsek.terra.config;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public abstract class TerraConfigSection {
|
||||||
|
private final TerraConfig parent;
|
||||||
|
public TerraConfigSection(@NotNull TerraConfig parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
@NotNull
|
||||||
|
public TerraConfig getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
}
|
@ -1,33 +1,20 @@
|
|||||||
package com.dfsek.terra.config.base;
|
package com.dfsek.terra.config.base;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.BiomeZone;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
|
||||||
import com.dfsek.terra.config.ConfigLoader;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.genconfig.AbstractBiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.FloraConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.PaletteConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.StructureConfig;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public final class ConfigUtil {
|
public final class ConfigUtil {
|
||||||
public static boolean debug;
|
public static boolean debug;
|
||||||
@ -44,7 +31,7 @@ public final class ConfigUtil {
|
|||||||
Logger logger = main.getLogger();
|
Logger logger = main.getLogger();
|
||||||
logger.info("Loading config values");
|
logger.info("Loading config values");
|
||||||
|
|
||||||
TerraConfig.loadAll(main);
|
ConfigPack.loadAll(main);
|
||||||
TerraWorld.invalidate();
|
TerraWorld.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
package com.dfsek.terra.config.base;
|
package com.dfsek.terra.config.base;
|
||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedGrid;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
|
||||||
import com.dfsek.terra.image.ImageLoader;
|
import com.dfsek.terra.image.ImageLoader;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -18,16 +12,13 @@ import org.polydev.gaea.commons.io.FileUtils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class WorldConfig {
|
public class WorldConfig {
|
||||||
|
|
||||||
|
|
||||||
public boolean fromImage;
|
public boolean fromImage;
|
||||||
public TerraConfig config;
|
public ConfigPack config;
|
||||||
public ImageLoader.Channel biomeXChannel;
|
public ImageLoader.Channel biomeXChannel;
|
||||||
public ImageLoader.Channel biomeZChannel;
|
public ImageLoader.Channel biomeZChannel;
|
||||||
public ImageLoader.Channel zoneChannel;
|
public ImageLoader.Channel zoneChannel;
|
||||||
@ -35,7 +26,7 @@ public class WorldConfig {
|
|||||||
public ImageLoader imageLoader;
|
public ImageLoader imageLoader;
|
||||||
|
|
||||||
|
|
||||||
private TerraConfig tConfig;
|
private ConfigPack tConfig;
|
||||||
|
|
||||||
|
|
||||||
public WorldConfig(World w, JavaPlugin main) {
|
public WorldConfig(World w, JavaPlugin main) {
|
||||||
@ -56,7 +47,7 @@ public class WorldConfig {
|
|||||||
fromImage = config.getBoolean("image.use-image", false);
|
fromImage = config.getBoolean("image.use-image", false);
|
||||||
|
|
||||||
|
|
||||||
tConfig = TerraConfig.fromID(config.getString("config"));
|
tConfig = ConfigPack.fromID(config.getString("config"));
|
||||||
|
|
||||||
// Load image stuff
|
// Load image stuff
|
||||||
try {
|
try {
|
||||||
@ -89,7 +80,7 @@ public class WorldConfig {
|
|||||||
main.getLogger().info("World load complete. Time elapsed: " + ((double) (System.nanoTime() - start)) / 1000000 + "ms");
|
main.getLogger().info("World load complete. Time elapsed: " + ((double) (System.nanoTime() - start)) / 1000000 + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerraConfig getConfig() {
|
public ConfigPack getConfig() {
|
||||||
return tConfig;
|
return tConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package com.dfsek.terra.config.genconfig;
|
|||||||
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.biome.UserDefinedGrid;
|
import com.dfsek.terra.biome.UserDefinedGrid;
|
||||||
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
import com.dfsek.terra.config.base.WorldConfig;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
@ -12,19 +12,17 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class BiomeGridConfig extends TerraConfigObject {
|
public class BiomeGridConfig extends TerraConfig {
|
||||||
private final String gridID;
|
private final String gridID;
|
||||||
private final UserDefinedBiome[][] gridRaw;
|
private final UserDefinedBiome[][] gridRaw;
|
||||||
private final int sizeX;
|
private final int sizeX;
|
||||||
private final int sizeZ;
|
private final int sizeZ;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BiomeGridConfig(File file, TerraConfig config) throws IOException, InvalidConfigurationException {
|
public BiomeGridConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
load(file);
|
load(file);
|
||||||
if(!contains("id")) throw new ConfigException("Grid ID unspecified!", "null");
|
if(!contains("id")) throw new ConfigException("Grid ID unspecified!", "null");
|
||||||
@ -65,7 +63,7 @@ public class BiomeGridConfig extends TerraConfigObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UserDefinedGrid getGrid(World w, WorldConfig wc) {
|
public UserDefinedGrid getGrid(World w, WorldConfig wc) {
|
||||||
TerraConfig c = wc.getConfig();
|
ConfigPack c = wc.getConfig();
|
||||||
return new UserDefinedGrid(w, c.freq1, c.freq2, gridRaw, wc);
|
return new UserDefinedGrid(w, c.freq1, c.freq2, gridRaw, wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ package com.dfsek.terra.config.genconfig;
|
|||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||||
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -23,7 +23,7 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
public class CarverConfig extends TerraConfigObject {
|
public class CarverConfig extends TerraConfig {
|
||||||
private final UserDefinedCarver carver;
|
private final UserDefinedCarver carver;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Set<Material> replaceableInner;
|
private final Set<Material> replaceableInner;
|
||||||
@ -42,7 +42,7 @@ public class CarverConfig extends TerraConfigObject {
|
|||||||
private final boolean replaceIsBlacklistBottom;
|
private final boolean replaceIsBlacklistBottom;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public CarverConfig(File file, TerraConfig config) throws IOException, InvalidConfigurationException {
|
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
load(file);
|
load(file);
|
||||||
if(!contains("id")) throw new ConfigException("No ID specified for Carver!", "null");
|
if(!contains("id")) throw new ConfigException("No ID specified for Carver!", "null");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig;
|
||||||
|
|
||||||
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class FloraConfig extends TerraConfigObject implements Flora {
|
public class FloraConfig extends TerraConfig implements 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;
|
||||||
@ -31,7 +31,7 @@ public class FloraConfig extends TerraConfigObject implements Flora {
|
|||||||
Set<Material> spawnable;
|
Set<Material> spawnable;
|
||||||
Set<Material> replaceable;
|
Set<Material> replaceable;
|
||||||
|
|
||||||
public FloraConfig(File file, TerraConfig config) throws IOException, InvalidConfigurationException {
|
public FloraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
load(file);
|
load(file);
|
||||||
if(!contains("id")) throw new ConfigException("Flora ID unspecified!", "null");
|
if(!contains("id")) throw new ConfigException("Flora ID unspecified!", "null");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig;
|
||||||
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -14,15 +14,11 @@ import org.polydev.gaea.math.FastNoise;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class OreConfig extends TerraConfigObject {
|
public class OreConfig extends TerraConfig {
|
||||||
private final BlockData oreData;
|
private final BlockData oreData;
|
||||||
private final int min;
|
private final int min;
|
||||||
private final int max;
|
private final int max;
|
||||||
@ -31,7 +27,7 @@ public class OreConfig extends TerraConfigObject {
|
|||||||
private final String id;
|
private final String id;
|
||||||
private final boolean update;
|
private final boolean update;
|
||||||
Set<Material> replaceable;
|
Set<Material> replaceable;
|
||||||
public OreConfig(File file, TerraConfig 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(!contains("id")) throw new ConfigException("Ore ID not found!", "null");
|
||||||
this.id = getString("id");
|
this.id = getString("id");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -19,11 +19,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class PaletteConfig extends TerraConfigObject {
|
public class PaletteConfig extends TerraConfig {
|
||||||
private final Palette<BlockData> palette;
|
private final Palette<BlockData> palette;
|
||||||
private final String paletteID;
|
private final String paletteID;
|
||||||
private boolean useNoise = false;
|
private boolean useNoise = false;
|
||||||
public PaletteConfig(File file, TerraConfig 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(!contains("id")) throw new ConfigException("Palette ID unspecified!", "null");
|
||||||
this.paletteID = getString("id");
|
this.paletteID = getString("id");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
@ -20,14 +20,14 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class StructureConfig extends TerraConfigObject {
|
public class StructureConfig extends TerraConfig {
|
||||||
private final ProbabilityCollection<GaeaStructure> structure = new ProbabilityCollection<>();
|
private final ProbabilityCollection<GaeaStructure> structure = new ProbabilityCollection<>();
|
||||||
private final GridSpawn spawn;
|
private final GridSpawn spawn;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Range searchStart;
|
private final Range searchStart;
|
||||||
private final Range bound;
|
private final Range bound;
|
||||||
StructurePopulator.SearchType type;
|
StructurePopulator.SearchType type;
|
||||||
public StructureConfig(File file, TerraConfig 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(!contains("id")) throw new ConfigException("No ID specified!", "null");
|
||||||
id = getString("id");
|
id = getString("id");
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig.biome;
|
||||||
|
|
||||||
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfigUtil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
@ -14,7 +15,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class AbstractBiomeConfig extends TerraConfigObject {
|
public class AbstractBiomeConfig extends TerraConfig {
|
||||||
private final String biomeID;
|
private final String biomeID;
|
||||||
private final int floraChance;
|
private final int floraChance;
|
||||||
private final int treeChance;
|
private final int treeChance;
|
||||||
@ -30,14 +31,15 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
|||||||
private final float floraFreq;
|
private final float floraFreq;
|
||||||
private final String oceanPalette;
|
private final String oceanPalette;
|
||||||
private final int seaLevel;
|
private final int seaLevel;
|
||||||
private List<Map<?, ?>> paletteData;
|
|
||||||
private Map<String, Object> floraData;
|
private Map<String, Object> floraData;
|
||||||
private Map<String, Object> oreData;
|
private Map<String, Object> oreData;
|
||||||
private Map<String, Object> treeData;
|
private Map<String, Object> treeData;
|
||||||
private List<Map<?, ?>> carvingData;
|
private List<Map<?, ?>> carvingData;
|
||||||
private List<String> structureConfigs;
|
private List<String> structureConfigs;
|
||||||
|
private BiomePaletteConfig palette;
|
||||||
|
private BiomeFloraConfig flora;
|
||||||
|
|
||||||
public AbstractBiomeConfig(File file, TerraConfig config) throws IOException, InvalidConfigurationException {
|
public AbstractBiomeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
load(file);
|
load(file);
|
||||||
if(!contains("id")) throw new ConfigException("Abstract Biome ID unspecified!", "null");
|
if(!contains("id")) throw new ConfigException("Abstract Biome ID unspecified!", "null");
|
||||||
@ -45,9 +47,9 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
|||||||
|
|
||||||
if(contains("carving")) carvingData = getMapList("carving");
|
if(contains("carving")) carvingData = getMapList("carving");
|
||||||
|
|
||||||
if(contains("palette")) paletteData = getMapList("palette");
|
if(contains("palette")) palette = new BiomePaletteConfig(this);
|
||||||
|
|
||||||
if(contains("flora")) floraData = Objects.requireNonNull(getConfigurationSection("flora")).getValues(false);
|
if(contains("flora")) flora = new BiomeFloraConfig(this);
|
||||||
|
|
||||||
if(contains("trees")) treeData = Objects.requireNonNull(getConfigurationSection("trees")).getValues(false);
|
if(contains("trees")) treeData = Objects.requireNonNull(getConfigurationSection("trees")).getValues(false);
|
||||||
|
|
||||||
@ -131,8 +133,12 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
|||||||
return floraSimplex;
|
return floraSimplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<?, ?>> getPaletteData() {
|
public BiomePaletteConfig getPaletteData() {
|
||||||
return paletteData;
|
return palette;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeFloraConfig getFlora() {
|
||||||
|
return flora;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getFloraData() {
|
public Map<String, Object> getFloraData() {
|
@ -1,16 +1,19 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig.biome;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
|
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.StructureConfig;
|
||||||
import org.polydev.gaea.math.Range;
|
import org.polydev.gaea.math.Range;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
import com.dfsek.terra.generation.UserDefinedDecorator;
|
||||||
import com.dfsek.terra.generation.UserDefinedGenerator;
|
import com.dfsek.terra.generation.UserDefinedGenerator;
|
||||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -39,14 +42,14 @@ import java.util.Objects;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
public class BiomeConfig extends TerraConfigObject {
|
public class BiomeConfig extends TerraConfig {
|
||||||
private static final Palette<BlockData> oceanDefault = new RandomPalette<BlockData>(new Random(0)).add(Material.WATER.createBlockData(), 1);
|
private static final Palette<BlockData> oceanDefault = new RandomPalette<BlockData>(new Random(0)).add(Material.WATER.createBlockData(), 1);
|
||||||
private final UserDefinedBiome biome;
|
private final UserDefinedBiome biome;
|
||||||
private final String biomeID;
|
private final String biomeID;
|
||||||
private Map<OreConfig, Range> ores;
|
private Map<OreConfig, Range> ores;
|
||||||
private Map<OreConfig, Range> oreHeights;
|
private Map<OreConfig, Range> oreHeights;
|
||||||
private final Map<CarverConfig, Integer> carvers;
|
private final Map<CarverConfig, Integer> carvers;
|
||||||
private Map<Flora, Range> floraHeights;
|
private final BiomeFloraConfig flora;
|
||||||
private String eq;
|
private String eq;
|
||||||
private int floraAttempts;
|
private int floraAttempts;
|
||||||
private Map<Material, Palette<BlockData>> slabs;
|
private Map<Material, Palette<BlockData>> slabs;
|
||||||
@ -57,10 +60,10 @@ public class BiomeConfig extends TerraConfigObject {
|
|||||||
private final Palette<BlockData> ocean;
|
private final Palette<BlockData> ocean;
|
||||||
private int seaLevel;
|
private int seaLevel;
|
||||||
private final List<StructureConfig> structures;
|
private final List<StructureConfig> structures;
|
||||||
private final TerraConfig config;
|
private final ConfigPack config;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked, rawtypes")
|
@SuppressWarnings("unchecked, rawtypes")
|
||||||
public BiomeConfig(File file, TerraConfig config) throws InvalidConfigurationException, IOException {
|
public BiomeConfig(File file, ConfigPack config) throws InvalidConfigurationException, IOException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
load(file);
|
load(file);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@ -84,40 +87,11 @@ public class BiomeConfig extends TerraConfigObject {
|
|||||||
|
|
||||||
TreeMap<Integer, Palette<BlockData>> paletteMap;
|
TreeMap<Integer, Palette<BlockData>> paletteMap;
|
||||||
// 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.
|
||||||
List<Map<?, ?>> paletteData;
|
if(extending && abstractBiome.getPaletteData() != null && ! contains("palette")) {
|
||||||
try {
|
paletteMap = abstractBiome.getPaletteData().getPaletteMap();
|
||||||
if(extending && abstractBiome.getPaletteData() != null && ! contains("palette")) {
|
Debug.info("Using super palette");
|
||||||
paletteData = abstractBiome.getPaletteData();
|
} else paletteMap = new BiomePaletteConfig(this).getPaletteMap();
|
||||||
Debug.info("Using super palette");
|
if(paletteMap == null) throw new ConfigException("No Palette specified in biome or super biome.", getID());
|
||||||
} else paletteData = getMapList("palette");
|
|
||||||
} catch(NullPointerException e) {
|
|
||||||
paletteData = null;
|
|
||||||
}
|
|
||||||
if(paletteData != null) {
|
|
||||||
paletteMap = new TreeMap<>();
|
|
||||||
for(Map<?, ?> e : paletteData) {
|
|
||||||
for(Map.Entry<?, ?> entry : e.entrySet()) {
|
|
||||||
try {
|
|
||||||
if(((String) entry.getKey()).startsWith("BLOCK:")) {
|
|
||||||
try {
|
|
||||||
paletteMap.put((Integer) entry.getValue(), new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1));
|
|
||||||
} catch(IllegalArgumentException ex) {
|
|
||||||
throw new ConfigException("BlockData " + entry.getKey() + " is invalid! (Palettes)", getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
paletteMap.put((Integer) entry.getValue(), config.getPalette((String) entry.getKey()).getPalette());
|
|
||||||
} catch(NullPointerException ex) {
|
|
||||||
throw new NotFoundException("Palette", (String) entry.getKey(), getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(ClassCastException ex) {
|
|
||||||
throw new ConfigException("Unable to parse Palette configuration! Check YAML syntax.", getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else 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.
|
||||||
List<Map<?, ?>> carvingData;
|
List<Map<?, ?>> carvingData;
|
||||||
@ -184,44 +158,10 @@ public class BiomeConfig extends TerraConfigObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if flora should be handled by super biome.
|
// Check if flora should be handled by super biome.
|
||||||
ProbabilityCollection<Flora> flora = new ProbabilityCollection<>();
|
if(extending && abstractBiome.getFloraData() != null && ! contains("flora")) {
|
||||||
Map<String, Object> floraData;
|
flora = abstractBiome.getFlora();
|
||||||
try {
|
Debug.info("Using super flora (" + flora.getFlora().size() + " entries, " + floraChance + " % chance)");
|
||||||
if(extending && abstractBiome.getFloraData() != null && ! contains("flora")) {
|
} else flora = new BiomeFloraConfig(this);
|
||||||
floraData = abstractBiome.getFloraData();
|
|
||||||
Debug.info("Using super flora (" + flora.size() + " entries, " + floraChance + " % chance)");
|
|
||||||
} else floraData = Objects.requireNonNull(getConfigurationSection("flora")).getValues(false);
|
|
||||||
} catch(NullPointerException e) {
|
|
||||||
floraData = null;
|
|
||||||
}
|
|
||||||
if(floraData != null) {
|
|
||||||
floraHeights = new HashMap<>();
|
|
||||||
try {
|
|
||||||
for(Map.Entry<String, Object> e : floraData.entrySet()) {
|
|
||||||
Map<?, ?> val = ((ConfigurationSection) e.getValue()).getValues(false);
|
|
||||||
Map<?, ?> y = ((ConfigurationSection) val.get("y")).getValues(false);
|
|
||||||
try {
|
|
||||||
Debug.info("Adding " + e.getKey() + " to biome's flora list with weight " + e.getValue());
|
|
||||||
Flora floraObj = FloraType.valueOf(e.getKey());
|
|
||||||
flora.add(floraObj, (Integer) val.get("weight"));
|
|
||||||
floraHeights.put(floraObj, new Range((Integer) y.get("min"), (Integer) y.get("max")));
|
|
||||||
} catch(IllegalArgumentException ex) {
|
|
||||||
try {
|
|
||||||
Debug.info("[Terra] Is custom flora: true");
|
|
||||||
Flora floraCustom = getConfig().getFlora(e.getKey());
|
|
||||||
if(floraCustom == null) throw new NotFoundException("Flora", e.getKey(), getID());
|
|
||||||
flora.add(floraCustom, (Integer) val.get("weight"));
|
|
||||||
floraHeights.put(floraCustom, new Range((Integer) y.get("min"), (Integer) y.get("max")));
|
|
||||||
} catch(NullPointerException ex2) {
|
|
||||||
throw new NotFoundException("Flora", e.getKey(), getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(ClassCastException e) {
|
|
||||||
if(ConfigUtil.debug) e.printStackTrace();
|
|
||||||
throw new ConfigException("Unable to parse Flora configuration! Check YAML syntax.", getID());
|
|
||||||
}
|
|
||||||
} else flora = new ProbabilityCollection<>();
|
|
||||||
|
|
||||||
// Check if trees should be handled by super biome.
|
// Check if trees should be handled by super biome.
|
||||||
Map<String, Object> treeData;
|
Map<String, Object> treeData;
|
||||||
@ -244,7 +184,7 @@ public class BiomeConfig extends TerraConfigObject {
|
|||||||
if(eq == null || eq.equals("")) throw new ConfigException("Could not find noise equation! Biomes must include a noise equation, or extend an abstract biome with one.", getID());
|
if(eq == null || eq.equals("")) throw new ConfigException("Could not find noise equation! Biomes must include a noise equation, or extend an abstract biome with one.", getID());
|
||||||
|
|
||||||
// Create decorator for this config.
|
// Create decorator for this config.
|
||||||
UserDefinedDecorator dec = new UserDefinedDecorator(flora, trees, floraChance, treeChance, treeDensity);
|
UserDefinedDecorator dec = new UserDefinedDecorator(flora.getFlora(), trees, floraChance, treeChance, treeDensity);
|
||||||
|
|
||||||
// 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;
|
||||||
@ -378,7 +318,7 @@ public class BiomeConfig extends TerraConfigObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Range getFloraHeights(Flora f) {
|
public Range getFloraHeights(Flora f) {
|
||||||
return floraHeights.computeIfAbsent(f, input -> new Range(-1, -1));
|
return flora.getFloraHeights().computeIfAbsent(f, input -> new Range(-1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig.biome;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.TerraConfigObject;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -18,7 +18,7 @@ import java.util.Map;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BiomeConfigUtil {
|
public class BiomeConfigUtil {
|
||||||
protected static Map<Material, Palette<BlockData>> getSlabPalettes(List<Map<?, ?>> paletteConfigSection, TerraConfigObject config) throws InvalidConfigurationException {
|
protected static Map<Material, Palette<BlockData>> getSlabPalettes(List<Map<?, ?>> paletteConfigSection, TerraConfig config) throws InvalidConfigurationException {
|
||||||
Map<Material, Palette<BlockData>> paletteMap = new HashMap<>();
|
Map<Material, Palette<BlockData>> paletteMap = new HashMap<>();
|
||||||
|
|
||||||
for(Map<?, ?> e : paletteConfigSection) {
|
for(Map<?, ?> e : paletteConfigSection) {
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.dfsek.terra.config.genconfig.biome;
|
||||||
|
|
||||||
|
import com.dfsek.terra.Debug;
|
||||||
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
|
import com.dfsek.terra.config.TerraConfigSection;
|
||||||
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.polydev.gaea.math.ProbabilityCollection;
|
||||||
|
import org.polydev.gaea.math.Range;
|
||||||
|
import org.polydev.gaea.world.Flora;
|
||||||
|
import org.polydev.gaea.world.FloraType;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class BiomeFloraConfig extends TerraConfigSection {
|
||||||
|
private final ProbabilityCollection<Flora> flora = new ProbabilityCollection<>();
|
||||||
|
private final Map<Flora, Range> floraHeights = new HashMap<>();
|
||||||
|
public BiomeFloraConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
|
super(parent);
|
||||||
|
ConfigurationSection cfg = parent.getConfigurationSection("flora");
|
||||||
|
if(cfg == null) return;
|
||||||
|
try {
|
||||||
|
for(Map.Entry<String, Object> e : cfg.getValues(false).entrySet()) {
|
||||||
|
Map<?, ?> val = ((ConfigurationSection) e.getValue()).getValues(false);
|
||||||
|
Map<?, ?> y = ((ConfigurationSection) val.get("y")).getValues(false);
|
||||||
|
try {
|
||||||
|
Debug.info("Adding " + e.getKey() + " to biome's flora list with weight " + e.getValue());
|
||||||
|
Flora floraObj = FloraType.valueOf(e.getKey());
|
||||||
|
flora.add(floraObj, (Integer) val.get("weight"));
|
||||||
|
floraHeights.put(floraObj, new Range((Integer) y.get("min"), (Integer) y.get("max")));
|
||||||
|
} catch(IllegalArgumentException ex) {
|
||||||
|
try {
|
||||||
|
Debug.info("[Terra] Is custom flora: true");
|
||||||
|
Flora floraCustom = parent.getConfig().getFlora(e.getKey());
|
||||||
|
if(floraCustom == null) throw new NotFoundException("Flora", e.getKey(), parent.getID());
|
||||||
|
flora.add(floraCustom, (Integer) val.get("weight"));
|
||||||
|
floraHeights.put(floraCustom, new Range((Integer) y.get("min"), (Integer) y.get("max")));
|
||||||
|
} catch(NullPointerException ex2) {
|
||||||
|
throw new NotFoundException("Flora", e.getKey(), parent.getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(ClassCastException e) {
|
||||||
|
if(ConfigUtil.debug) e.printStackTrace();
|
||||||
|
throw new ConfigException("Unable to parse Flora configuration! Check YAML syntax.", parent.getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProbabilityCollection<Flora> getFlora() {
|
||||||
|
return flora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Flora, Range> getFloraHeights() {
|
||||||
|
return floraHeights;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.dfsek.terra.config.genconfig.biome;
|
||||||
|
|
||||||
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
|
import com.dfsek.terra.config.TerraConfigSection;
|
||||||
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.polydev.gaea.math.ProbabilityCollection;
|
||||||
|
import org.polydev.gaea.world.palette.Palette;
|
||||||
|
import org.polydev.gaea.world.palette.RandomPalette;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
public class BiomePaletteConfig extends TerraConfigSection {
|
||||||
|
private final TreeMap<Integer, Palette<BlockData>> paletteMap = new TreeMap<>();
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public BiomePaletteConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
|
super(parent);
|
||||||
|
List<Map<?, ?>> cfg = parent.getMapList("palette");
|
||||||
|
if(cfg.size() == 0) throw new ConfigException("Palette unspecified.", parent.getID());
|
||||||
|
for(Map<?, ?> e : cfg) {
|
||||||
|
for(Map.Entry<?, ?> entry : e.entrySet()) {
|
||||||
|
try {
|
||||||
|
if(((String) entry.getKey()).startsWith("BLOCK:")) {
|
||||||
|
try {
|
||||||
|
paletteMap.put((Integer) entry.getValue(), new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1));
|
||||||
|
} catch(IllegalArgumentException ex) {
|
||||||
|
throw new ConfigException("BlockData " + entry.getKey() + " is invalid! (Palettes)", parent.getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
paletteMap.put((Integer) entry.getValue(), parent.getConfig().getPalette((String) entry.getKey()).getPalette());
|
||||||
|
} catch(NullPointerException ex) {
|
||||||
|
throw new NotFoundException("Palette", (String) entry.getKey(), parent.getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(ClassCastException ex) {
|
||||||
|
throw new ConfigException("Unable to parse Palette configuration! Check YAML syntax.", parent.getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TreeMap<Integer, Palette<BlockData>> getPaletteMap() {
|
||||||
|
return paletteMap;
|
||||||
|
}
|
||||||
|
}
|
@ -3,11 +3,9 @@ package com.dfsek.terra.generation;
|
|||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import com.dfsek.terra.population.CavePopulator;
|
import com.dfsek.terra.population.CavePopulator;
|
||||||
import com.dfsek.terra.population.FloraPopulator;
|
import com.dfsek.terra.population.FloraPopulator;
|
||||||
import com.dfsek.terra.population.OrePopulator;
|
import com.dfsek.terra.population.OrePopulator;
|
||||||
@ -22,7 +20,6 @@ import org.bukkit.block.data.BlockData;
|
|||||||
import org.bukkit.block.data.Waterlogged;
|
import org.bukkit.block.data.Waterlogged;
|
||||||
import org.bukkit.block.data.type.Stairs;
|
import org.bukkit.block.data.type.Stairs;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.polydev.gaea.biome.Biome;
|
import org.polydev.gaea.biome.Biome;
|
||||||
@ -33,7 +30,6 @@ import org.polydev.gaea.math.ChunkInterpolator;
|
|||||||
import org.polydev.gaea.math.FastNoise;
|
import org.polydev.gaea.math.FastNoise;
|
||||||
import org.polydev.gaea.population.PopulationManager;
|
import org.polydev.gaea.population.PopulationManager;
|
||||||
import org.polydev.gaea.world.palette.Palette;
|
import org.polydev.gaea.world.palette.Palette;
|
||||||
import org.polydev.gaea.world.palette.RandomPalette;
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -63,7 +59,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
|||||||
if(needsLoad) load(world);
|
if(needsLoad) load(world);
|
||||||
StructureSpawnRequirement.putNoise(world, fastNoise); // Assign noise to world to be used for structures.
|
StructureSpawnRequirement.putNoise(world, fastNoise); // Assign noise to world to be used for structures.
|
||||||
ChunkData chunk = createChunkData(world);
|
ChunkData chunk = createChunkData(world);
|
||||||
TerraConfig config = TerraWorld.getWorld(world).getConfig();
|
ConfigPack config = TerraWorld.getWorld(world).getConfig();
|
||||||
int xOrig = (chunkX << 4);
|
int xOrig = (chunkX << 4);
|
||||||
int zOrig = (chunkZ << 4);
|
int zOrig = (chunkZ << 4);
|
||||||
for(byte x = 0; x < 16; x++) {
|
for(byte x = 0; x < 16; x++) {
|
||||||
|
@ -2,10 +2,7 @@ package com.dfsek.terra.image;
|
|||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
|
@ -2,9 +2,8 @@ package com.dfsek.terra.population;
|
|||||||
|
|
||||||
import com.dfsek.terra.TerraProfiler;
|
import com.dfsek.terra.TerraProfiler;
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -31,7 +30,7 @@ public class CavePopulator extends BlockPopulator {
|
|||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
if(ConfigUtil.masterDisableCaves) return;
|
if(ConfigUtil.masterDisableCaves) return;
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("CaveTime")) {
|
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("CaveTime")) {
|
||||||
TerraConfig config = TerraWorld.getWorld(world).getConfig();
|
ConfigPack config = TerraWorld.getWorld(world).getConfig();
|
||||||
for(CarverConfig c : config.getCarvers().values()) {
|
for(CarverConfig c : config.getCarvers().values()) {
|
||||||
Map<Location, Material> shiftCandidate = new HashMap<>();
|
Map<Location, Material> shiftCandidate = new HashMap<>();
|
||||||
Set<Block> updateNeeded = new HashSet<>();
|
Set<Block> updateNeeded = new HashSet<>();
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.dfsek.terra.population;
|
package com.dfsek.terra.population;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
|
||||||
import com.dfsek.terra.TerraProfiler;
|
import com.dfsek.terra.TerraProfiler;
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||||
import com.dfsek.terra.config.genconfig.FloraConfig;
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -25,7 +23,7 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
|||||||
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
|
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
|
||||||
TerraWorld tw = TerraWorld.getWorld(world);
|
TerraWorld tw = TerraWorld.getWorld(world);
|
||||||
TerraBiomeGrid grid = tw.getGrid();
|
TerraBiomeGrid grid = tw.getGrid();
|
||||||
TerraConfig config = tw.getConfig();
|
ConfigPack config = tw.getConfig();
|
||||||
for(int x = 0; x < 16; x++) {
|
for(int x = 0; x < 16; x++) {
|
||||||
for(int z = 0; z < 16; z++) {
|
for(int z = 0; z < 16; z++) {
|
||||||
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
|
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
package com.dfsek.terra.population;
|
package com.dfsek.terra.population;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
|
||||||
import org.polydev.gaea.math.Range;
|
import org.polydev.gaea.math.Range;
|
||||||
import com.dfsek.terra.TerraProfiler;
|
import com.dfsek.terra.TerraProfiler;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.polydev.gaea.biome.Biome;
|
import org.polydev.gaea.biome.Biome;
|
||||||
@ -25,7 +21,7 @@ public class OrePopulator extends GaeaBlockPopulator {
|
|||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) {
|
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) {
|
||||||
TerraConfig config = TerraWorld.getWorld(world).getConfig();
|
ConfigPack config = TerraWorld.getWorld(world).getConfig();
|
||||||
Biome b = TerraWorld.getWorld(world).getGrid().getBiome((chunk.getX() << 4)+8, (chunk.getZ() << 4) + 8, GenerationPhase.POPULATE);
|
Biome b = TerraWorld.getWorld(world).getGrid().getBiome((chunk.getX() << 4)+8, (chunk.getZ() << 4) + 8, GenerationPhase.POPULATE);
|
||||||
for(Map.Entry<OreConfig, Range> e : config.getBiome((UserDefinedBiome) b).getOres().entrySet()) {
|
for(Map.Entry<OreConfig, Range> e : config.getBiome((UserDefinedBiome) b).getOres().entrySet()) {
|
||||||
int num = e.getValue().get(random);
|
int num = e.getValue().get(random);
|
||||||
|
@ -4,13 +4,10 @@ import com.dfsek.terra.TerraProfiler;
|
|||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.StructureConfig;
|
import com.dfsek.terra.config.genconfig.StructureConfig;
|
||||||
import com.dfsek.terra.structure.GaeaStructure;
|
import com.dfsek.terra.structure.GaeaStructure;
|
||||||
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -31,7 +28,7 @@ public class StructurePopulator extends BlockPopulator {
|
|||||||
int cz = (chunk.getZ() << 4);
|
int cz = (chunk.getZ() << 4);
|
||||||
TerraWorld tw = TerraWorld.getWorld(world);
|
TerraWorld tw = TerraWorld.getWorld(world);
|
||||||
TerraBiomeGrid grid = tw.getGrid();
|
TerraBiomeGrid grid = tw.getGrid();
|
||||||
TerraConfig config = tw.getConfig();
|
ConfigPack config = tw.getConfig();
|
||||||
UserDefinedBiome b = (UserDefinedBiome) grid.getBiome(cx+ 8, cz + 8, GenerationPhase.POPULATE);
|
UserDefinedBiome b = (UserDefinedBiome) grid.getBiome(cx+ 8, cz + 8, GenerationPhase.POPULATE);
|
||||||
structure: for(StructureConfig conf : config.getBiome(b).getStructures()) {
|
structure: for(StructureConfig conf : config.getBiome(b).getStructures()) {
|
||||||
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package com.dfsek.terra.structure;
|
package com.dfsek.terra.structure;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.polydev.gaea.biome.Generator;
|
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
import org.polydev.gaea.math.FastNoise;
|
import org.polydev.gaea.math.FastNoise;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user