use of com.denizenscript.denizencore.objects.core.TimeTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemFlags method getObjectAttribute.
@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
// -->
if (attribute.startsWith("with_flag")) {
ItemTag item = new ItemTag(this.item.getItemStack().clone());
FlagCommand.FlagActionProvider provider = new FlagCommand.FlagActionProvider();
provider.tracker = item.getFlagTracker();
DataAction action = DataActionHelper.parse(provider, attribute.getParam(), attribute.context);
// -->
if (attribute.startsWith("duration", 2)) {
provider.expiration = new TimeTag(TimeTag.now().millis() + attribute.getContextObject(2).asType(DurationTag.class, attribute.context).getMillis());
attribute.fulfill(1);
}
action.execute(attribute.context);
item.reapplyTracker(provider.tracker);
return item.getObjectAttribute(attribute.fulfill(1));
}
return null;
}
use of com.denizenscript.denizencore.objects.core.TimeTag in project Denizen-For-Bukkit by DenizenScript.
the class LegacySavesUpdater method applyFlags.
public static void applyFlags(String object, AbstractFlagTracker tracker, YamlConfiguration section) {
try {
if (section == null || section.getKeys(false).isEmpty()) {
return;
}
for (StringHolder flagName : section.getKeys(false)) {
if (flagName.low.endsWith("-expiration")) {
continue;
}
TimeTag expireAt = null;
if (section.contains(flagName + "-expiration")) {
long expireTime = Long.parseLong(section.getString(flagName + "-expiration"));
expireAt = new TimeTag(expireTime);
}
Object value = section.get(flagName.str);
ObjectTag setAs = CoreUtilities.objectToTagForm(value, CoreUtilities.errorButNoDebugContext);
tracker.setFlag(flagName.low, setAs, expireAt);
}
} catch (Throwable ex) {
Debug.echoError("Error while updating legacy flags for " + object);
Debug.echoError(ex);
}
}
Aggregations