mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-08 12:21:21 +01:00
!Added IDs to WorldGenTemplates
This commit is contained in:
parent
503857569e
commit
e529ab7139
@ -10,6 +10,7 @@ import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class WorldGenTemplate {
|
||||
private final String id;
|
||||
private final double chunkChance;
|
||||
private final int minDepth, maxDepth, veinSize, veinCount;
|
||||
|
||||
@ -21,6 +22,7 @@ public class WorldGenTemplate {
|
||||
public WorldGenTemplate(ConfigurationSection config) {
|
||||
Validate.notNull(config, "Could not read gen template config");
|
||||
|
||||
id = config.getName().toLowerCase().replace(" ", "-").replace("_", "-");
|
||||
config.getStringList("replace").forEach(str -> replaceable.add(Material.valueOf(str.toUpperCase().replace("-", "_").replace(" ", "_"))));
|
||||
|
||||
for (String world : config.getStringList("worlds"))
|
||||
@ -43,6 +45,10 @@ public class WorldGenTemplate {
|
||||
veinCount = config.getInt("vein-count");
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public double getChunkChance() {
|
||||
return chunkChance;
|
||||
}
|
||||
|
@ -57,9 +57,7 @@ public class WorldGenManager implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void a(ChunkLoadEvent event) {
|
||||
if (!event.isNewChunk())
|
||||
return;
|
||||
|
||||
if (event.isNewChunk())
|
||||
assigned.forEach((block, template) -> {
|
||||
if (random.nextDouble() < template.getChunkChance())
|
||||
for (int i = 0; i < template.getVeinCount(); i++) {
|
||||
@ -89,10 +87,10 @@ public class WorldGenManager implements Listener {
|
||||
FileConfiguration config = new ConfigFile("gen-templates").getConfig();
|
||||
for (String key : config.getKeys(false))
|
||||
try {
|
||||
templates.put(key, new WorldGenTemplate(config.getConfigurationSection(key)));
|
||||
WorldGenTemplate template = new WorldGenTemplate(config.getConfigurationSection(key));
|
||||
templates.put(template.getId(), template);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "An error occured when loading gen template '" + key + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user