Add protection around unknown blockconfig.yml entries. GRASS>SHORT_GRASS

This commit is contained in:
tastybento 2024-01-02 11:24:07 +09:00
parent 82174649b4
commit 5f83a81f18
2 changed files with 12 additions and 6 deletions

View File

@ -60,10 +60,16 @@ public class BlockConfig {
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);
@ -97,7 +103,7 @@ public class BlockConfig {
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;

View File

@ -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