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();
}
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);
}
}
Aggregations