add error handle for set manager

This commit is contained in:
Indyuce 2019-08-29 16:46:30 +02:00
parent a4612a1c82
commit 6443f85b4b

View File

@ -3,12 +3,14 @@ package net.Indyuce.mmoitems.manager;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.ItemSet;
public class SetManager {
private Map<String, ItemSet> itemSets = new HashMap<>();
private final Map<String, ItemSet> itemSets = new HashMap<>();
public SetManager() {
reload();
@ -17,10 +19,13 @@ public class SetManager {
public void reload() {
ConfigFile config = new ConfigFile("item-sets");
// reload item sets and cache them into a map
itemSets.clear();
for (String id : config.getConfig().getKeys(false))
itemSets.put(id, new ItemSet(config.getConfig().getConfigurationSection(id)));
try {
itemSets.put(id, new ItemSet(config.getConfig().getConfigurationSection(id)));
} catch (IllegalArgumentException exception) {
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load item set '" + id + "': " + exception.getMessage());
}
}
public Collection<ItemSet> getAll() {