Search in sources :

Example 1 with DestructEntityEvent

use of org.spongepowered.api.event.entity.DestructEntityEvent in project LanternServer by LanternPowered.

the class LanternEntity method remove.

public void remove(RemoveState removeState) {
    checkNotNull(removeState, "removeState");
    if (this.removeState == removeState) {
        return;
    }
    this.removeState = removeState;
    if (removeState == RemoveState.DESTROYED) {
        setVehicle(null);
        clearPassengers();
        // don't do it if the entity is dead.
        if (!isDead()) {
            setDead(true);
            final CauseStack causeStack = CauseStack.current();
            // TODO: Message channel?
            final DestructEntityEvent event = SpongeEventFactory.createDestructEntityEvent(causeStack.getCurrentCause(), MessageChannel.TO_NONE, Optional.empty(), new MessageEvent.MessageFormatter(), this, false);
            postDestructEvent(event);
        }
    }
}
Also used : CauseStack(org.lanternpowered.server.event.CauseStack) DestructEntityEvent(org.spongepowered.api.event.entity.DestructEntityEvent) MessageEvent(org.spongepowered.api.event.message.MessageEvent)

Aggregations

CauseStack (org.lanternpowered.server.event.CauseStack)1 DestructEntityEvent (org.spongepowered.api.event.entity.DestructEntityEvent)1 MessageEvent (org.spongepowered.api.event.message.MessageEvent)1