use of net.aufdemrand.denizen.npc.traits.PushableTrait in project Denizen-For-Bukkit by DenizenScript.
the class PushableCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dNPC denizenNPC = ((BukkitScriptEntryData) scriptEntry.entryData).getNPC();
if (denizenNPC == null) {
throw new CommandExecutionException("No valid NPC attached to this queue!");
}
PushableTrait trait = denizenNPC.getPushableTrait();
Element state = scriptEntry.getElement("state");
Duration delay = scriptEntry.getdObject("delay");
Element returnable = scriptEntry.getElement("return");
if (state == null && delay == null && returnable == null) {
state = new Element("TOGGLE");
}
dB.report(scriptEntry, getName(), (state != null ? state.debug() : "") + (delay != null ? delay.debug() : "") + (returnable != null ? returnable.debug() : ""));
if (delay != null) {
trait.setDelay(delay.getSecondsAsInt());
}
if (returnable != null) {
trait.setReturnable(returnable.asBoolean());
}
if (state != null) {
switch(Toggle.valueOf(state.asString().toUpperCase())) {
case TRUE:
case ON:
trait.setPushable(true);
break;
case FALSE:
case OFF:
trait.setPushable(false);
break;
case TOGGLE:
trait.setPushable(!trait.isPushable());
break;
}
}
}
Aggregations