Skip to content

Commit

Permalink
Adds error checking for MATERIALs in config.yml
Browse files Browse the repository at this point in the history
MATERIALs must be blocks otherwise the world populator will throw errors
and crash the server. This commit checks that all imported materials are
blocks and if they are not logs the error.

Updated config.yml to use correct 1.13 material names for blocks.

#11
  • Loading branch information
tastybento committed Feb 7, 2019
1 parent ae26dfa commit 168cbe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ private Map<Material, Pair<Double, Integer>> getMaterialMap(List<String> objectL
filter(splitString -> splitString.length == 4).
forEach(splitString -> {
Material material = Material.getMaterial(splitString[1]);

if (material != null)
// Material must be a block otherwise the chunk cannot be populated
if (material != null && material.isBlock())
{
materialMap.put(material,
new Pair<>(Double.parseDouble(splitString[2]), Integer.parseInt(splitString[3])));
} else {
addon.logError("Could not parse MATERIAL in config.yml: " + splitString[1] + " is not a valid block.");
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ world:
# MATERIAL:DIAMOND_ORE:100:5 - means there is 100% chace of spawing diamonds
# where max amount in pack are 5 per each subchunk!
blocks:
- MATERIAL:QUARTZ_ORE:30:5
- MATERIAL:NETHER_QUARTZ_ORE:30:5
- MATERIAL:SOUL_SAND:40:10
- MATERIAL:MAGMA_BLOCK:10:3
- MATERIAL:GLOWSTONE:20:8
- MATERIAL:NETHER_BRICK:10:5
- MATERIAL:NETHER_BRICKS:10:5
- MATERIAL:LAVA:10:1
- ENTITY:MAGMA_CUBE:0.5:1
- ENTITY:GHAST:0.1:1
Expand Down Expand Up @@ -166,7 +166,7 @@ world:
blocks:
- ENTITY:SHULKER:0.2:1
- MATERIAL:OBSIDIAN:1:1
- MATERIAL:CHORUS_FRUIT:1:3
- MATERIAL:CHORUS_PLANT:1:3
# Mob white list - these mobs will NOT be removed when logging in or doing /cave
remove-mobs-whitelist:
- WITHER
Expand Down

0 comments on commit 168cbe1

Please sign in to comment.