Search in sources :

Example 1 with DataPersistenceFlagTracker

use of com.denizenscript.denizen.utilities.flags.DataPersistenceFlagTracker in project Denizen-For-Bukkit by DenizenScript.

the class EntityFlags method getPropertyString.

@Override
public String getPropertyString() {
    AbstractFlagTracker tracker = entity.getFlagTracker();
    if (!(tracker instanceof DataPersistenceFlagTracker)) {
        return null;
    }
    Collection<String> flagNames = tracker.listAllFlags();
    if (flagNames.isEmpty()) {
        return null;
    }
    MapTag flags = new MapTag();
    for (String name : flagNames) {
        flags.putObject(name, ((DataPersistenceFlagTracker) tracker).getRootMap(name));
    }
    return flags.toString();
}
Also used : DataPersistenceFlagTracker(com.denizenscript.denizen.utilities.flags.DataPersistenceFlagTracker) AbstractFlagTracker(com.denizenscript.denizencore.flags.AbstractFlagTracker) MapTag(com.denizenscript.denizencore.objects.core.MapTag)

Example 2 with DataPersistenceFlagTracker

use of com.denizenscript.denizen.utilities.flags.DataPersistenceFlagTracker in project Denizen-For-Bukkit by DenizenScript.

the class EntityFlags method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("flag_map") && mechanism.requireObject(MapTag.class)) {
        MapTagFlagTracker flags = new MapTagFlagTracker(mechanism.valueAsType(MapTag.class));
        AbstractFlagTracker tracker = entity.getFlagTracker();
        if (!(tracker instanceof DataPersistenceFlagTracker)) {
            return;
        }
        for (String flagName : flags.map.keys()) {
            ((DataPersistenceFlagTracker) tracker).setRootMap(flagName, flags.getRootMap(flagName));
        }
        entity.reapplyTracker(tracker);
    }
}
Also used : DataPersistenceFlagTracker(com.denizenscript.denizen.utilities.flags.DataPersistenceFlagTracker) AbstractFlagTracker(com.denizenscript.denizencore.flags.AbstractFlagTracker) MapTagFlagTracker(com.denizenscript.denizencore.flags.MapTagFlagTracker) MapTag(com.denizenscript.denizencore.objects.core.MapTag)

Aggregations

DataPersistenceFlagTracker (com.denizenscript.denizen.utilities.flags.DataPersistenceFlagTracker)2 AbstractFlagTracker (com.denizenscript.denizencore.flags.AbstractFlagTracker)2 MapTag (com.denizenscript.denizencore.objects.core.MapTag)2 MapTagFlagTracker (com.denizenscript.denizencore.flags.MapTagFlagTracker)1