Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
58 lines
1.8 KiB
Java
58 lines
1.8 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package de.maxhenkel.voicechat.plugins;
|
|
|
|
import de.maxhenkel.voicechat.api.events.Event;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.function.Consumer;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class EventBuilder {
|
|
private final Map<Class<? extends Event>, List<Tuple<Integer, Consumer<? extends Event>>>> events = new HashMap<Class<? extends Event>, List<Tuple<Integer, Consumer<? extends Event>>>>();
|
|
|
|
private EventBuilder() {
|
|
}
|
|
|
|
public <T extends Event> EventBuilder addEvent(Class<T> eventClass, Consumer<T> event, int priority) {
|
|
List eventList = this.events.getOrDefault(eventClass, new ArrayList());
|
|
eventList.add(new Tuple<Integer, Consumer<T>>(priority, event));
|
|
this.events.put(eventClass, eventList);
|
|
return this;
|
|
}
|
|
|
|
public Map<Class<? extends Event>, List<Consumer<? extends Event>>> build() {
|
|
HashMap<Class<? extends Event>, List<Consumer<? extends Event>>> result = new HashMap<Class<? extends Event>, List<Consumer<? extends Event>>>();
|
|
for (Map.Entry<Class<? extends Event>, List<Tuple<Integer, Consumer<? extends Event>>>> entry : this.events.entrySet()) {
|
|
result.put(entry.getKey(), entry.getValue().stream().sorted((o1, o2) -> Integer.compare((Integer)o2.getA(), (Integer)o1.getA())).map(Tuple::getB).collect(Collectors.toList()));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static EventBuilder create() {
|
|
return new EventBuilder();
|
|
}
|
|
|
|
private static class Tuple<A, B> {
|
|
private final A a;
|
|
private final B b;
|
|
|
|
public Tuple(A a, B b) {
|
|
this.a = a;
|
|
this.b = b;
|
|
}
|
|
|
|
public A getA() {
|
|
return this.a;
|
|
}
|
|
|
|
public B getB() {
|
|
return this.b;
|
|
}
|
|
}
|
|
}
|
|
|