Esempio n. 1
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));
 }
Esempio n. 2
0
 @Override
 public void loadFromKey(DataKey root) {
   List<String> list = new ArrayList<String>();
   for (DataKey key : root.getRelative("npc.default.text").getSubKeys())
     list.add(key.getString(""));
   value = list;
 }
Esempio n. 3
0
 // Save settings for this NPC. These values will be added to the citizens
 // saves.yml under this NPC.
 public void save(DataKey key) {
   //		key.setBoolean("SomeSetting", SomeSetting);
   key.setString("NPCType", npcType.name());
   key.setString("UnitType", unitType.name());
   key.setInt("settleId", settleId);
   key.setInt("buildingId", buildingId);
   //		System.out.println("[REALMS] Trait save setting : "+key.toString());
 }
Esempio n. 4
0
 @Override
 public void save(DataKey key) {
   saveOrRemove(key.getRelative("hand"), equipment[0]);
   saveOrRemove(key.getRelative("helmet"), equipment[1]);
   saveOrRemove(key.getRelative("chestplate"), equipment[2]);
   saveOrRemove(key.getRelative("leggings"), equipment[3]);
   saveOrRemove(key.getRelative("boots"), equipment[4]);
 }
Esempio n. 5
0
 private static void saveRegions(DataKey key, Multimap<String, TaggedRegion> tags) {
   for (Entry<String, TaggedRegion> entry : tags.entries()) {
     DataKey sub = key.getRelative(entry.getKey());
     int length = sub.getInt("length", 0) + 1;
     sub.setInt("length", length);
     saveRegion(sub.getRelative(length), entry.getValue());
   }
 }
Esempio n. 6
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"));
 }
Esempio n. 7
0
 private static Collection<TaggedRegion> loadRegions(File file) {
   Collection<TaggedRegion> ret = Lists.newArrayList();
   Storage storage = new NBTStorage(file, "Schematic");
   storage.load();
   for (DataKey sub : storage.getKey("TaggedRegions").getSubKeys()) {
     String name = sub.name();
     for (DataKey sub2 : sub.getIntegerSubKeys()) {
       Location min = loadLocation(sub2.getRelative("min"));
       Location max = loadLocation(sub2.getRelative("max"));
       ret.add(new TaggedRegion(name, min, max));
     }
   }
   return ret;
 }
Esempio n. 8
0
  public void reload() {
    config.load();
    for (Setting setting : Setting.values())
      if (root.keyExists(setting.path)) setting.loadFromKey(root);

    save();
  }
Esempio n. 9
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();
  }
Esempio n. 10
0
 @Override
 public void load(DataKey key) throws NPCLoadException {
   for (DataKey sub : key.getRelative("list").getIntegerSubKeys()) {
     String[] parts = sub.getString("").split(";");
     Location location;
     try {
       location =
           new Location(
               Bukkit.getServer().getWorld(parts[1]),
               Double.valueOf(parts[2]),
               Double.valueOf(parts[3]),
               Double.valueOf(parts[4]));
       anchors.add(new Anchor(parts[0], location));
     } catch (NumberFormatException e) {
       Messaging.logTr(Messages.SKIPPING_INVALID_ANCHOR, sub.name(), e.getMessage());
     } catch (NullPointerException e) {
       // Invalid world/location/etc. Still enough data to build an
       // unloaded anchor
       anchors.add(new Anchor(parts[0], sub.getString("").split(";", 2)[1]));
     }
   }
 }
Esempio n. 11
0
 @Override
 public void load(DataKey key) {
   type = EntityType.fromName(key.getString(""));
   if (type == null) type = EntityType.PLAYER;
 }
Esempio n. 12
0
 protected void setAtKey(DataKey root) {
   root.setRaw(path, value);
 }
Esempio n. 13
0
 protected void loadFromKey(DataKey root) {
   value = root.getRaw(path);
 }
Esempio n. 14
0
 private void saveOrRemove(DataKey key, ItemStack item) {
   if (item != null) ItemStorage.saveItem(key, item);
   else {
     if (key.keyExists("")) key.removeKey("");
   }
 }
Esempio n. 15
0
 private static void saveRegion(DataKey key, TaggedRegion value) {
   saveLocation(key.getRelative("min"), value.getMin());
   saveLocation(key.getRelative("max"), value.getMax());
 }
Esempio n. 16
0
 private static void saveLocation(DataKey key, Location location) {
   key.setDouble("x", location.getX());
   key.setDouble("y", location.getY());
   key.setDouble("z", location.getZ());
 }
Esempio n. 17
0
 @Override
 public void save(DataKey key) {
   key.setString("", type.getName());
 }
Esempio n. 18
0
 private static Location loadLocation(DataKey key) {
   return new Location(null, key.getDouble("x"), key.getDouble("y"), key.getDouble("z"));
 }
Esempio n. 19
0
 public void load(DataKey key) throws NPCLoadException {
   shop = key.getString("shop", null);
 }
Esempio n. 20
0
 @Override
 public void save(DataKey key) {
   key.removeKey("list");
   for (int i = 0; i < anchors.size(); i++)
     key.setString("list." + String.valueOf(i), anchors.get(i).stringValue());
 }
Esempio n. 21
0
 public void save(DataKey key) {
   key.setString("shop", this.shop);
 }