use of com.denizenscript.denizen.npc.traits.PushableTrait in project Denizen-For-Bukkit by DenizenScript.
the class PushableCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
NPCTag denizenNPC = Utilities.getEntryNPC(scriptEntry);
if (denizenNPC == null) {
Debug.echoError("No valid NPC attached to this queue!");
return;
}
PushableTrait trait = denizenNPC.getPushableTrait();
ElementTag state = scriptEntry.getElement("state");
DurationTag delay = scriptEntry.getObjectTag("delay");
ElementTag returnable = scriptEntry.getElement("return");
if (state == null && delay == null && returnable == null) {
state = new ElementTag("TOGGLE");
}
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), denizenNPC, state, delay, returnable);
}
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