Skip to content

Commit

Permalink
Add protection around unknown blockconfig.yml entries. GRASS>SHORT_GRASS
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jan 2, 2024
1 parent 8217464 commit 5f83a81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/main/java/world/bentobox/level/config/BlockConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ private void loadWorlds(YamlConfiguration blockValues2) {
if (bWorld != null) {
ConfigurationSection worldValues = worlds.getConfigurationSection(world);
for (String material : Objects.requireNonNull(worldValues).getKeys(false)) {
Material mat = Material.valueOf(material);
Map<Material, Integer> values = worldBlockValues.getOrDefault(bWorld, new EnumMap<>(Material.class));
values.put(mat, worldValues.getInt(material));
worldBlockValues.put(bWorld, values);
try {
Material mat = Material.valueOf(material);
Map<Material, Integer> values = worldBlockValues.getOrDefault(bWorld,
new EnumMap<>(Material.class));
values.put(mat, worldValues.getInt(material));
worldBlockValues.put(bWorld, values);
} catch (Exception e) {
addon.logError(
"Unknown material (" + material + ") in blockconfig.yml worlds section. Skipping...");
}
}
} else {
addon.logWarning("Level Addon: No such world in blockconfig.yml : " + world);
Expand Down Expand Up @@ -97,7 +103,7 @@ private Map<Material, Integer> loadBlockLimits(YamlConfiguration blockValues2) {
Material mat = Material.valueOf(material);
bl.put(mat, limits.getInt(material, 0));
} catch (Exception e) {
addon.logWarning("Unknown material (" + material + ") in blockconfig.yml Limits section. Skipping...");
addon.logError("Unknown material (" + material + ") in blockconfig.yml Limits section. Skipping...");
}
}
return bl;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/blockconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ blocks:
GRANITE_SLAB: 1
GRANITE_STAIRS: 1
GRANITE_WALL: 1
GRASS: 4
SHORT_GRASS: 4
GRASS_BLOCK: 4
GRAVEL: 1
GRAY_BANNER: 2
Expand Down

0 comments on commit 5f83a81

Please sign in to comment.