@Override public void load(DataKey key) throws NPCLoadException { if (key.keyExists("hand")) equipment[0] = ItemStorage.loadItemStack(key.getRelative("hand")); if (key.keyExists("helmet")) equipment[1] = ItemStorage.loadItemStack(key.getRelative("helmet")); if (key.keyExists("chestplate")) equipment[2] = ItemStorage.loadItemStack(key.getRelative("chestplate")); if (key.keyExists("leggings")) equipment[3] = ItemStorage.loadItemStack(key.getRelative("leggings")); if (key.keyExists("boots")) equipment[4] = ItemStorage.loadItemStack(key.getRelative("boots")); }
public void reload() { config.load(); for (Setting setting : Setting.values()) if (root.keyExists(setting.path)) setting.loadFromKey(root); save(); }
public void load() { config.load(); DataKey root = config.getKey(""); for (Setting setting : Setting.values()) if (!root.keyExists(setting.path)) root.setRaw(setting.path, setting.get()); else setting.set(root.getRaw(setting.path)); }
public Settings(File folder) { config = new YamlStorage(new File(folder, "config.yml"), "Citizens Configuration"); root = config.getKey(""); config.load(); for (Setting setting : Setting.values()) { if (!root.keyExists(setting.path)) { setting.setAtKey(root); } else setting.loadFromKey(root); } save(); }
private void saveOrRemove(DataKey key, ItemStack item) { if (item != null) ItemStorage.saveItem(key, item); else { if (key.keyExists("")) key.removeKey(""); } }