Search in sources :

Example 1 with LanternKey

use of org.lanternpowered.server.data.key.LanternKey in project LanternServer by LanternPowered.

the class CompositeValueStoreHelper method hasListeners.

protected static boolean hasListeners(ICompositeValueStore store, Iterable<Key<?>> keys) {
    if (!(store instanceof DataHolder)) {
        return false;
    }
    for (Key<?> key : keys) {
        final DataHolder dataHolder = (DataHolder) store;
        final List<RegisteredListener<ChangeDataHolderEvent.ValueChange>> listeners = ((LanternKey) key).getListeners();
        for (RegisteredListener<ChangeDataHolderEvent.ValueChange> listener : listeners) {
            if (((KeyEventListener) listener.getHandler()).getDataHolderPredicate().test(dataHolder)) {
                return true;
            }
        }
    }
    return false;
}
Also used : DataHolder(org.spongepowered.api.data.DataHolder) LanternKey(org.lanternpowered.server.data.key.LanternKey) RegisteredListener(org.lanternpowered.server.event.RegisteredListener) ChangeDataHolderEvent(org.spongepowered.api.event.data.ChangeDataHolderEvent)

Aggregations

LanternKey (org.lanternpowered.server.data.key.LanternKey)1 RegisteredListener (org.lanternpowered.server.event.RegisteredListener)1 DataHolder (org.spongepowered.api.data.DataHolder)1 ChangeDataHolderEvent (org.spongepowered.api.event.data.ChangeDataHolderEvent)1