use of net.citizensnpcs.api.util.DataKey in project Citizens2 by CitizensDev.
the class Anchors method load.
@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]));
}
}
}
use of net.citizensnpcs.api.util.DataKey in project Citizens2 by CitizensDev.
the class Text method load.
@Override
public void load(DataKey key) throws NPCLoadException {
text.clear();
// TODO: legacy, remove later
for (DataKey sub : key.getIntegerSubKeys()) {
text.add(sub.getString(""));
}
for (DataKey sub : key.getRelative("text").getIntegerSubKeys()) {
text.add(sub.getString(""));
}
if (text.isEmpty()) {
populateDefaultText();
}
talkClose = key.getBoolean("talk-close", talkClose);
realisticLooker = key.getBoolean("realistic-looking", realisticLooker);
randomTalker = key.getBoolean("random-talker", randomTalker);
range = key.getDouble("range", range);
delay = key.getInt("delay", delay);
itemInHandPattern = key.getString("talkitem", itemInHandPattern);
}
use of net.citizensnpcs.api.util.DataKey in project Citizens2 by CitizensDev.
the class GuidedWaypointProvider method load.
@Override
public void load(DataKey key) {
for (DataKey root : key.getRelative("availablewaypoints").getIntegerSubKeys()) {
Waypoint waypoint = PersistenceLoader.load(Waypoint.class, root);
if (waypoint == null)
continue;
available.add(waypoint);
}
for (DataKey root : key.getRelative("helperwaypoints").getIntegerSubKeys()) {
Waypoint waypoint = PersistenceLoader.load(Waypoint.class, root);
if (waypoint == null)
continue;
helpers.add(waypoint);
}
rebuildTree();
}
use of net.citizensnpcs.api.util.DataKey in project Citizens2 by CitizensDev.
the class GuidedWaypointProvider method save.
@Override
public void save(DataKey key) {
key.removeKey("availablewaypoints");
DataKey root = key.getRelative("availablewaypoints");
for (int i = 0; i < available.size(); ++i) {
PersistenceLoader.save(available.get(i), root.getRelative(i));
}
key.removeKey("helperwaypoints");
root = key.getRelative("helperwaypoints");
for (int i = 0; i < helpers.size(); ++i) {
PersistenceLoader.save(helpers.get(i), root.getRelative(i));
}
}
use of net.citizensnpcs.api.util.DataKey in project Citizens2 by CitizensDev.
the class LinearWaypointProvider method load.
@Override
public void load(DataKey key) {
for (DataKey root : key.getRelative("points").getIntegerSubKeys()) {
Waypoint waypoint = PersistenceLoader.load(Waypoint.class, root);
if (waypoint == null)
continue;
waypoints.add(waypoint);
}
}
Aggregations