示例#1
0
 @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"));
 }
示例#2
0
  public void reload() {
    config.load();
    for (Setting setting : Setting.values())
      if (root.keyExists(setting.path)) setting.loadFromKey(root);

    save();
  }
示例#3
0
 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));
 }
示例#4
0
  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();
  }
示例#5
0
 private void saveOrRemove(DataKey key, ItemStack item) {
   if (item != null) ItemStorage.saveItem(key, item);
   else {
     if (key.keyExists("")) key.removeKey("");
   }
 }