Skip to content

Commit

Permalink
Improved refactor of RecipeManager
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Nov 1, 2019
1 parent 697feef commit 680097c
Showing 1 changed file with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void processEntries(String type, ConfigurationSection biomeSection, Yaml
}
ConfigurationSection temp = biomes.getConfigurationSection("biomes." + type + ".plants");
// Load plants
loadPlants(type, temp, biomes, b);
loadPlants(temp, b);

// Load mobs!
loadMobs(type, temp, biomes, b);
Expand Down Expand Up @@ -139,18 +139,16 @@ private BiomeRecipe getBiomeRecipe(ConfigurationSection biomeRecipe, String type
return b;
}

private void loadPlants(String type, ConfigurationSection temp, YamlConfiguration biomes, BiomeRecipe b) {
private void loadPlants(ConfigurationSection temp, BiomeRecipe b) {
// # Plant Material: Probability in %:Block Material on what they grow
if (temp != null) {
HashMap<String,Object> plants = (HashMap<String,Object>)temp.getValues(false);
if (plants != null) {
for (Entry<String, Object> s: plants.entrySet()) {
Material plantMaterial = Material.valueOf(s.getKey());
String[] split = ((String)s.getValue()).split(":");
int plantProbability = Integer.parseInt(split[0]);
Material plantGrowOn = Material.valueOf(split[1]);
b.addPlants(plantMaterial, plantProbability, plantGrowOn);
}
for (Entry<String, Object> s: plants.entrySet()) {
Material plantMaterial = Material.valueOf(s.getKey());
String[] split = ((String)s.getValue()).split(":");
int plantProbability = Integer.parseInt(split[0]);
Material plantGrowOn = Material.valueOf(split[1]);
b.addPlants(plantMaterial, plantProbability, plantGrowOn);
}
}

Expand Down Expand Up @@ -182,12 +180,7 @@ private void loadMobs(String type, ConfigurationSection temp, YamlConfiguration
// Mob EntityType: Probability:Spawn on Material
temp = biomes.getConfigurationSection("biomes." + type + ".mobs");
if (temp != null) {
HashMap<String,Object> mobs = (HashMap<String,Object>)temp.getValues(false);
if (mobs != null) {
for (Entry<String, Object> s: mobs.entrySet()) {
parseMob(s,b);
}
}
((HashMap<String,Object>)temp.getValues(false)).entrySet().forEach(s -> parseMob(s,b));
}

}
Expand Down

0 comments on commit 680097c

Please sign in to comment.