2020-10-31 15:09:13 +00:00
|
|
|
package me.totalfreedom.plex.world;
|
|
|
|
|
|
|
|
import me.totalfreedom.plex.Plex;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.generator.BlockPopulator;
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
2020-11-02 00:06:08 +00:00
|
|
|
public class ConfigurationChunkGenerator extends BlockMapChunkGenerator
|
2020-10-31 15:09:13 +00:00
|
|
|
{
|
|
|
|
private static Plex plugin = Plex.get();
|
|
|
|
|
|
|
|
public ConfigurationChunkGenerator(String worldName, BlockPopulator... populators)
|
|
|
|
{
|
2020-11-02 00:06:08 +00:00
|
|
|
super(createBlockMap(worldName), populators);
|
2020-10-31 15:09:13 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:06:08 +00:00
|
|
|
private static LinkedHashMap<Material, Integer> createBlockMap(String worldName)
|
2020-10-31 15:09:13 +00:00
|
|
|
{
|
2020-11-02 00:06:08 +00:00
|
|
|
LinkedHashMap<Material, Integer> blockMap = new LinkedHashMap<>();
|
2020-10-31 15:09:13 +00:00
|
|
|
for (String key : plugin.config.getConfigurationSection("worlds." + worldName + ".parameters").getKeys(false))
|
|
|
|
{
|
|
|
|
Material material = Material.getMaterial(key.toUpperCase());
|
|
|
|
if (material == null) continue;
|
|
|
|
int count = plugin.config.getInt("worlds." + worldName + ".parameters." + key);
|
2020-11-02 00:06:08 +00:00
|
|
|
blockMap.put(material, count);
|
2020-10-31 15:09:13 +00:00
|
|
|
}
|
2020-11-02 00:06:08 +00:00
|
|
|
return blockMap;
|
2020-10-31 15:09:13 +00:00
|
|
|
}
|
|
|
|
}
|