Search in sources :

Example 11 with DataKey

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]));
        }
    }
}
Also used : Anchor(net.citizensnpcs.util.Anchor) DataKey(net.citizensnpcs.api.util.DataKey) Location(org.bukkit.Location)

Example 12 with DataKey

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);
}
Also used : DataKey(net.citizensnpcs.api.util.DataKey)

Example 13 with DataKey

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();
}
Also used : DataKey(net.citizensnpcs.api.util.DataKey)

Example 14 with DataKey

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));
    }
}
Also used : DataKey(net.citizensnpcs.api.util.DataKey)

Example 15 with DataKey

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);
    }
}
Also used : DataKey(net.citizensnpcs.api.util.DataKey)

Aggregations

DataKey (net.citizensnpcs.api.util.DataKey)15 Trait (net.citizensnpcs.api.trait.Trait)4 MemoryDataKey (net.citizensnpcs.api.util.MemoryDataKey)4 GameProfile (com.mojang.authlib.GameProfile)2 Property (com.mojang.authlib.properties.Property)2 Anchor (net.citizensnpcs.util.Anchor)2 EventHandler (org.bukkit.event.EventHandler)2 SkullMeta (org.bukkit.inventory.meta.SkullMeta)2 AssignmentScriptContainer (com.denizenscript.denizen.scripts.containers.core.AssignmentScriptContainer)1 FlaggableObject (com.denizenscript.denizencore.flags.FlaggableObject)1 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)1 ListTag (com.denizenscript.denizencore.objects.core.ListTag)1 ScriptTag (com.denizenscript.denizencore.objects.core.ScriptTag)1 Function (com.google.common.base.Function)1 Collection (java.util.Collection)1 UUID (java.util.UUID)1 NPC (net.citizensnpcs.api.npc.NPC)1 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)1 Pose (net.citizensnpcs.util.Pose)1 Location (org.bukkit.Location)1