mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Update kyori/event dependency
This commit is contained in:
parent
2ddae5a96c
commit
cc9bb34873
@ -7,7 +7,7 @@ dependencies {
|
|||||||
exclude(module: 'guava')
|
exclude(module: 'guava')
|
||||||
exclude(module: 'gson')
|
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: 'checker-qual')
|
||||||
exclude(module: 'guava')
|
exclude(module: 'guava')
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,8 @@ public enum Dependency {
|
|||||||
EVENT(
|
EVENT(
|
||||||
"net{}kyori",
|
"net{}kyori",
|
||||||
"event-api",
|
"event-api",
|
||||||
"2.0.1",
|
"2.0.2",
|
||||||
"4XVmowvKHCmO38ZO2jeZKh/mD00xBg73zau79s4kTe4=",
|
"+69FXQhgPlBtg/OvEiB+hvpbdGyUquj4cORHV1gnN1w=",
|
||||||
Relocation.of("eventbus", "net{}kyori{}event")
|
Relocation.of("eventbus", "net{}kyori{}event")
|
||||||
),
|
),
|
||||||
CAFFEINE(
|
CAFFEINE(
|
||||||
|
@ -25,23 +25,20 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.event;
|
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.EventBus;
|
||||||
import me.lucko.luckperms.api.event.EventHandler;
|
import me.lucko.luckperms.api.event.EventHandler;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
|
||||||
|
|
||||||
import net.kyori.event.EventSubscriber;
|
import net.kyori.event.EventSubscriber;
|
||||||
import net.kyori.event.SimpleEventBus;
|
import net.kyori.event.SimpleEventBus;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@ -122,11 +119,7 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@Nonnull Class<T> eventClass) {
|
public <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@Nonnull Class<T> eventClass) {
|
||||||
Set<LuckPermsEventHandler<?>> handlers = this.bus.getHandlers();
|
return this.bus.getHandlers(eventClass);
|
||||||
handlers.removeIf(h -> !h.getEventClass().isAssignableFrom(eventClass));
|
|
||||||
|
|
||||||
//noinspection unchecked
|
|
||||||
return (Set) ImmutableSet.copyOf(handlers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,19 +153,15 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterAll() {
|
public void unregisterAll() {
|
||||||
unregisterMatching(Predicates.alwaysTrue());
|
super.unregisterAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<LuckPermsEventHandler<?>> getHandlers() {
|
public <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(Class<T> eventClass) {
|
||||||
Set<LuckPermsEventHandler<?>> handlers = new HashSet<>();
|
//noinspection unchecked
|
||||||
|
return super.subscribers().values().stream()
|
||||||
// bit of a hack
|
.filter(s -> s instanceof EventHandler && ((EventHandler<?>) s).getEventClass().isAssignableFrom(eventClass))
|
||||||
unregisterMatching(sub -> {
|
.map(s -> ((EventHandler<T>) s))
|
||||||
handlers.add((LuckPermsEventHandler<?>) sub);
|
.collect(Collectors.toSet());
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return handlers;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user