use of com.denizenscript.denizen.npc.traits.SittingTrait in project Denizen-For-Bukkit by DenizenScript.
the class SitCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
LocationTag location = scriptEntry.getObjectTag("location");
NPCTag npc = Utilities.getEntryNPC(scriptEntry);
if (!(npc.getEntity() instanceof Player || npc.getEntity() instanceof Sittable)) {
Debug.echoError("Entities of type " + npc.getEntityType().getName() + " cannot sit.");
return;
}
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), npc, location);
}
Entity entity = npc.getEntity();
if (entity instanceof Sittable) {
((Sittable) entity).setSitting(true);
} else {
SittingTrait trait = npc.getCitizen().getOrAddTrait(SittingTrait.class);
if (location != null) {
trait.sit(location);
} else {
trait.sit();
}
}
}
use of com.denizenscript.denizen.npc.traits.SittingTrait in project Denizen-For-Bukkit by DenizenScript.
the class StandCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
NPCTag npc = Utilities.getEntryNPC(scriptEntry);
if (!(npc.getEntity() instanceof Player || npc.getEntity() instanceof Sittable || npc.getEntity() instanceof Villager)) {
Debug.echoError("Entities of type " + npc.getEntityType().name() + " cannot sit or sleep.");
return;
}
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("npc", Utilities.getEntryNPC(scriptEntry)));
}
Entity entity = npc.getEntity();
if (entity instanceof Sittable) {
((Sittable) entity).setSitting(false);
} else {
if (npc.getCitizen().hasTrait(SittingTrait.class)) {
SittingTrait trait = npc.getCitizen().getOrAddTrait(SittingTrait.class);
trait.stand();
npc.getCitizen().removeTrait(SittingTrait.class);
}
if (npc.getCitizen().hasTrait(SleepingTrait.class)) {
SleepingTrait trait = npc.getCitizen().getOrAddTrait(SleepingTrait.class);
trait.wakeUp();
npc.getCitizen().removeTrait(SleepingTrait.class);
}
}
}
Aggregations