Search in sources :

Example 1 with EntityEvent

use of org.lanternpowered.server.entity.event.EntityEvent in project LanternServer by LanternPowered.

the class AbstractEntityProtocol method processEvents.

@Nullable
private TempEvents processEvents(boolean death, boolean alive) {
    if (!death && !alive) {
        return null;
    }
    List<EntityEvent> aliveList = null;
    synchronized (this.entityEvents) {
        if (!this.entityEvents.isEmpty()) {
            aliveList = new ArrayList<>(this.entityEvents);
            this.entityEvents.clear();
        }
    }
    if (aliveList == null) {
        return null;
    }
    List<EntityEvent> deathOrAliveList = null;
    if (death) {
        for (EntityEvent event : aliveList) {
            if (event.type() == EntityEventType.DEATH_OR_ALIVE) {
                if (deathOrAliveList == null) {
                    deathOrAliveList = new ArrayList<>();
                }
                deathOrAliveList.add(event);
            }
        }
    }
    return new TempEvents(deathOrAliveList, aliveList);
}
Also used : EntityEvent(org.lanternpowered.server.entity.event.EntityEvent) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)1 EntityEvent (org.lanternpowered.server.entity.event.EntityEvent)1