Update kyori/event dependency

This commit is contained in:
Luck 2018-08-13 20:03:57 +01:00
parent 2ddae5a96c
commit cc9bb34873
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 12 additions and 23 deletions

View File

@ -7,7 +7,7 @@ dependencies {
exclude(module: 'guava')
exclude(module: 'gson')
}
compile('net.kyori:event-api:2.0.1') {
compile('net.kyori:event-api:2.0.2') {
exclude(module: 'checker-qual')
exclude(module: 'guava')
}

View File

@ -70,8 +70,8 @@ public enum Dependency {
EVENT(
"net{}kyori",
"event-api",
"2.0.1",
"4XVmowvKHCmO38ZO2jeZKh/mD00xBg73zau79s4kTe4=",
"2.0.2",
"+69FXQhgPlBtg/OvEiB+hvpbdGyUquj4cORHV1gnN1w=",
Relocation.of("eventbus", "net{}kyori{}event")
),
CAFFEINE(

View File

@ -25,23 +25,20 @@
package me.lucko.luckperms.common.event;
import com.google.common.collect.ImmutableSet;
import me.lucko.luckperms.api.event.EventBus;
import me.lucko.luckperms.api.event.EventHandler;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.utils.Predicates;
import net.kyori.event.EventSubscriber;
import net.kyori.event.SimpleEventBus;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
@ -122,11 +119,7 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
@Nonnull
@Override
public <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@Nonnull Class<T> eventClass) {
Set<LuckPermsEventHandler<?>> handlers = this.bus.getHandlers();
handlers.removeIf(h -> !h.getEventClass().isAssignableFrom(eventClass));
//noinspection unchecked
return (Set) ImmutableSet.copyOf(handlers);
return this.bus.getHandlers(eventClass);
}
/**
@ -160,19 +153,15 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
}
public void unregisterAll() {
unregisterMatching(Predicates.alwaysTrue());
super.unregisterAll();
}
public Set<LuckPermsEventHandler<?>> getHandlers() {
Set<LuckPermsEventHandler<?>> handlers = new HashSet<>();
// bit of a hack
unregisterMatching(sub -> {
handlers.add((LuckPermsEventHandler<?>) sub);
return false;
});
return handlers;
public <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(Class<T> eventClass) {
//noinspection unchecked
return super.subscribers().values().stream()
.filter(s -> s instanceof EventHandler && ((EventHandler<?>) s).getEventClass().isAssignableFrom(eventClass))
.map(s -> ((EventHandler<T>) s))
.collect(Collectors.toSet());
}
}
}