mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fixed building and switched event library
This commit is contained in:
parent
ab6e0d1e16
commit
13046a8602
25 changed files with 193 additions and 622 deletions
|
|
@ -67,9 +67,6 @@ dependencies {
|
|||
implementation("net.kyori", "adventure-text-serializer-legacy", Versions.adventureVersion)
|
||||
implementation("net.kyori", "adventure-text-serializer-plain", Versions.adventureVersion)
|
||||
|
||||
// Kyori Misc
|
||||
implementation("net.kyori", "event-api", Versions.eventVersion)
|
||||
|
||||
// Test
|
||||
testImplementation("junit", "junit", Versions.junitVersion)
|
||||
|
||||
|
|
|
|||
|
|
@ -467,18 +467,6 @@ public class GeyserImpl implements GeyserApi {
|
|||
this.eventBus.fire(new GeyserPostInitializeEvent(this.extensionManager, this.eventBus));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable GeyserSession connectionByUsername(@NonNull String username) {
|
||||
for (GeyserSession session : sessionManager.getAllSessions()) {
|
||||
if (session.bedrockUsername().equals(username) || session.getProtocol().getProfile().getName().equals(
|
||||
username)) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<GeyserSession> onlineConnections() {
|
||||
return sessionManager.getAllSessions();
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.event;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.kyori.event.EventSubscriber;
|
||||
import org.geysermc.geyser.api.event.Event;
|
||||
import org.geysermc.geyser.api.event.EventBus;
|
||||
import org.geysermc.geyser.api.event.EventSubscription;
|
||||
import org.geysermc.geyser.api.event.Subscribe;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
|
||||
@Getter
|
||||
@Accessors(fluent = true)
|
||||
@RequiredArgsConstructor
|
||||
public abstract class AbstractEventSubscription<T extends Event> implements EventSubscription<T>, EventSubscriber<T> {
|
||||
protected final EventBus eventBus;
|
||||
protected final Class<T> eventClass;
|
||||
protected final Extension owner;
|
||||
protected final Subscribe.PostOrder order;
|
||||
@Getter(AccessLevel.NONE) private boolean active;
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribe() {
|
||||
if (!this.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.active = false;
|
||||
this.eventBus.unsubscribe(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int postOrder() {
|
||||
return this.order.postOrder();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.event.Event;
|
||||
import org.geysermc.geyser.api.event.EventBus;
|
||||
import org.geysermc.geyser.api.event.Subscribe;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Getter
|
||||
@Accessors(fluent = true)
|
||||
public class GeneratedEventSubscription<T extends Event> extends AbstractEventSubscription<T> {
|
||||
private final Object eventHolder;
|
||||
private final BiConsumer<Object, ? super T> eventConsumer;
|
||||
|
||||
public GeneratedEventSubscription(EventBus eventBus, Class<T> eventClass, Extension owner, Subscribe.PostOrder order, Object eventHolder, BiConsumer<Object, ? super T> eventConsumer) {
|
||||
super(eventBus, eventClass, owner, order);
|
||||
|
||||
this.eventHolder = eventHolder;
|
||||
this.eventConsumer = eventConsumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NonNull T event) throws Throwable {
|
||||
try {
|
||||
this.eventConsumer.accept(this.eventHolder, event);
|
||||
} catch (Throwable ex) {
|
||||
this.owner.logger().warning("Unable to fire event " + event.getClass().getSimpleName() + " with subscription " + this.eventConsumer.getClass().getSimpleName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,97 +25,40 @@
|
|||
|
||||
package org.geysermc.geyser.event;
|
||||
|
||||
import net.kyori.event.EventSubscriber;
|
||||
import net.kyori.event.SimpleEventBus;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.event.Event;
|
||||
import org.geysermc.event.Event;
|
||||
import org.geysermc.event.bus.impl.OwnedEventBusImpl;
|
||||
import org.geysermc.event.subscribe.OwnedSubscriber;
|
||||
import org.geysermc.event.subscribe.Subscribe;
|
||||
import org.geysermc.geyser.api.event.EventBus;
|
||||
import org.geysermc.geyser.api.event.EventSubscription;
|
||||
import org.geysermc.geyser.api.event.Subscribe;
|
||||
import org.geysermc.geyser.api.event.EventSubscriber;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
import org.lanternpowered.lmbda.LambdaFactory;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GeyserEventBus implements EventBus {
|
||||
private static final MethodHandles.Lookup CALLER = MethodHandles.lookup();
|
||||
@SuppressWarnings("unchecked")
|
||||
public final class GeyserEventBus extends OwnedEventBusImpl<Extension, Event, EventSubscriber<? extends Event>>
|
||||
implements EventBus {
|
||||
@Override
|
||||
protected <L, T extends Event, B extends OwnedSubscriber<Extension, T>> B makeSubscription(
|
||||
Extension owner, Class<T> eventClass, Subscribe subscribe,
|
||||
L listener, BiConsumer<L, T> handler) {
|
||||
return (B) new GeyserEventSubscriber<>(
|
||||
owner, eventClass, subscribe.postOrder(), subscribe.ignoreCancelled(), listener, handler
|
||||
);
|
||||
}
|
||||
|
||||
private final SimpleEventBus<Event> bus = new SimpleEventBus<>(Event.class);
|
||||
@Override
|
||||
protected <T extends Event, B extends OwnedSubscriber<Extension, T>> B makeSubscription(
|
||||
Extension owner, Class<T> eventClass, Consumer<T> handler) {
|
||||
return (B) new GeyserEventSubscriber<>(owner, eventClass, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Override
|
||||
public <T extends Event> EventSubscription<T> subscribe(@NonNull Extension extension, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> consumer) {
|
||||
return this.subscribe(eventClass, consumer, extension, Subscribe.PostOrder.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Event> void unsubscribe(@NonNull EventSubscription<T> subscription) {
|
||||
this.bus.unregister((AbstractEventSubscription<T>) subscription);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void register(@NonNull Extension extension, @NonNull Object eventHolder) {
|
||||
for (Method method : eventHolder.getClass().getMethods()) {
|
||||
if (!method.isAnnotationPresent(Subscribe.class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (method.getParameterCount() > 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Event.class.isAssignableFrom(method.getParameters()[0].getType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Subscribe subscribe = method.getAnnotation(Subscribe.class);
|
||||
|
||||
try {
|
||||
Class<? extends Event> type = (Class<? extends Event>) method.getParameters()[0].getType();
|
||||
this.subscribe(type, eventHolder, LambdaFactory.createBiConsumer(CALLER.unreflect(method)), extension, subscribe.postOrder());
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterAll(@NonNull Extension extension) {
|
||||
this.bus.unregister((Predicate<EventSubscriber<?>>) subscriber -> extension.equals(((AbstractEventSubscription<?>) subscriber).owner()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(@NonNull Event event) {
|
||||
return this.bus.post(event).wasSuccessful();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@NonNull
|
||||
@Override
|
||||
public <T extends Event> Set<EventSubscription<T>> subscriptions(@NonNull Class<T> eventClass) {
|
||||
return bus.subscribers().values()
|
||||
.stream()
|
||||
.filter(sub -> sub instanceof EventSubscription && ((EventSubscription<?>) sub).eventClass().isAssignableFrom(eventClass))
|
||||
.map(sub -> ((EventSubscription<T>) sub))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private <T extends Event> EventSubscription<T> subscribe(Class<T> eventClass, Consumer<? super T> handler, Extension extension, Subscribe.PostOrder postOrder) {
|
||||
BaseEventSubscription<T> eventSubscription = new BaseEventSubscription<>(this, eventClass, extension, postOrder, handler);
|
||||
this.bus.register(eventClass, eventSubscription);
|
||||
return eventSubscription;
|
||||
}
|
||||
|
||||
private <T extends Event> EventSubscription<T> subscribe(Class<T> eventClass, Object eventHolder, BiConsumer<Object, ? super T> handler, Extension extension, Subscribe.PostOrder postOrder) {
|
||||
GeneratedEventSubscription<T> eventSubscription = new GeneratedEventSubscription<>(this, eventClass, extension, postOrder, eventHolder, handler);
|
||||
this.bus.register(eventClass, eventSubscription);
|
||||
return eventSubscription;
|
||||
public <T extends Event> Set<? extends EventSubscriber<T>> subscribers(@NonNull Class<T> eventClass) {
|
||||
return castGenericSet(super.subscribers(eventClass));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,34 +25,23 @@
|
|||
|
||||
package org.geysermc.geyser.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.event.Event;
|
||||
import org.geysermc.geyser.api.event.EventBus;
|
||||
import org.geysermc.geyser.api.event.Subscribe;
|
||||
import org.geysermc.event.Event;
|
||||
import org.geysermc.event.PostOrder;
|
||||
import org.geysermc.event.subscribe.impl.OwnedSubscriberImpl;
|
||||
import org.geysermc.geyser.api.event.ExtensionEventSubscriber;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Getter
|
||||
@Accessors(fluent = true)
|
||||
public class BaseEventSubscription<T extends Event> extends AbstractEventSubscription<T> {
|
||||
private final Consumer<? super T> eventConsumer;
|
||||
|
||||
public BaseEventSubscription(EventBus eventBus, Class<T> eventClass, Extension owner, Subscribe.PostOrder order, Consumer<? super T> eventConsumer) {
|
||||
super(eventBus, eventClass, owner, order);
|
||||
|
||||
this.eventConsumer = eventConsumer;
|
||||
public final class GeyserEventSubscriber<E extends Event> extends OwnedSubscriberImpl<Extension, E>
|
||||
implements ExtensionEventSubscriber<E> {
|
||||
GeyserEventSubscriber(Extension owner, Class<E> eventClass, Consumer<E> handler) {
|
||||
super(owner, eventClass, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NonNull T event) throws Throwable {
|
||||
try {
|
||||
this.eventConsumer.accept(event);
|
||||
} catch (Throwable ex) {
|
||||
this.owner.logger().warning("Unable to fire event " + event.getClass().getSimpleName() + " with subscription " + this.eventConsumer.getClass().getSimpleName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
<H> GeyserEventSubscriber(Extension owner, Class<E> eventClass, PostOrder postOrder, boolean ignoreCancelled,
|
||||
H handlerInstance, BiConsumer<H, E> handler) {
|
||||
super(owner, eventClass, postOrder, ignoreCancelled, handlerInstance, handler);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.event.type;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCustomItemsEvent;
|
||||
import org.geysermc.geyser.api.item.custom.CustomItemData;
|
||||
import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class DefineCustomItemsEvent implements GeyserDefineCustomItemsEvent {
|
||||
private final Multimap<String, CustomItemData> customItems;
|
||||
private final List<NonVanillaCustomItemData> nonVanillaCustomItems;
|
||||
|
||||
public DefineCustomItemsEvent(Multimap<String, CustomItemData> customItems, List<NonVanillaCustomItemData> nonVanillaCustomItems) {
|
||||
this.customItems = customItems;
|
||||
this.nonVanillaCustomItems = nonVanillaCustomItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a multimap of all the already registered custom items indexed by the item's extended java item's identifier.
|
||||
*
|
||||
* @return a multimap of all the already registered custom items
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Collection<CustomItemData>> getExistingCustomItems() {
|
||||
return Collections.unmodifiableMap(this.customItems.asMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of the already registered non-vanilla custom items.
|
||||
*
|
||||
* @return the list of the already registered non-vanilla custom items
|
||||
*/
|
||||
@Override
|
||||
public List<NonVanillaCustomItemData> getExistingNonVanillaCustomItems() {
|
||||
return Collections.unmodifiableList(this.nonVanillaCustomItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a custom item with a base Java item. This is used to register items with custom textures and properties
|
||||
* based on NBT data.
|
||||
*
|
||||
* @param identifier the base (java) item
|
||||
* @param customItemData the custom item data to register
|
||||
* @return if the item was registered
|
||||
*/
|
||||
public abstract boolean register(@NonNull String identifier, @NonNull CustomItemData customItemData);
|
||||
|
||||
/**
|
||||
* Registers a custom item with no base item. This is used for mods.
|
||||
*
|
||||
* @param customItemData the custom item data to register
|
||||
* @return if the item was registered
|
||||
*/
|
||||
public abstract boolean register(@NonNull NonVanillaCustomItemData customItemData);
|
||||
}
|
||||
|
|
@ -26,62 +26,50 @@
|
|||
package org.geysermc.geyser.extension.event;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.event.Event;
|
||||
import org.geysermc.event.Event;
|
||||
import org.geysermc.event.bus.impl.EventBusImpl;
|
||||
import org.geysermc.event.subscribe.Subscribe;
|
||||
import org.geysermc.event.subscribe.Subscriber;
|
||||
import org.geysermc.geyser.api.event.EventBus;
|
||||
import org.geysermc.geyser.api.event.EventSubscription;
|
||||
import org.geysermc.geyser.api.event.EventSubscriber;
|
||||
import org.geysermc.geyser.api.event.ExtensionEventBus;
|
||||
import org.geysermc.geyser.api.event.ExtensionEventSubscriber;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public record GeyserExtensionEventBus(EventBus eventBus,
|
||||
Extension extension) implements ExtensionEventBus {
|
||||
@NonNull
|
||||
public record GeyserExtensionEventBus(EventBus eventBus, Extension extension) implements ExtensionEventBus {
|
||||
@Override
|
||||
public <T extends Event> EventSubscription<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> consumer) {
|
||||
return this.eventBus.subscribe(this.extension, eventClass, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(@NonNull Object eventHolder) {
|
||||
this.eventBus.register(this.extension, eventHolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterAll() {
|
||||
this.eventBus.unregisterAll(this.extension);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T extends Event> EventSubscription<T> subscribe(@NonNull Extension extension, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> consumer) {
|
||||
return this.eventBus.subscribe(extension, eventClass, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Event> void unsubscribe(@NonNull EventSubscription<T> subscription) {
|
||||
this.eventBus.unsubscribe(subscription);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(@NonNull Extension extension, @NonNull Object eventHolder) {
|
||||
this.eventBus.register(extension, eventHolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterAll(@NonNull Extension extension) {
|
||||
this.eventBus.unregisterAll(extension);
|
||||
public void unsubscribe(@NonNull EventSubscriber<? extends Event> subscription) {
|
||||
eventBus.unsubscribe(subscription);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(@NonNull Event event) {
|
||||
return this.eventBus.fire(event);
|
||||
return eventBus.fire(event);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T extends Event> Set<EventSubscription<T>> subscriptions(@NonNull Class<T> eventClass) {
|
||||
return this.eventBus.subscriptions(eventClass);
|
||||
public @NonNull <T extends Event> Set<? extends EventSubscriber<T>> subscribers(@NonNull Class<T> eventClass) {
|
||||
return eventBus.subscribers(eventClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(@NonNull Object listener) {
|
||||
eventBus.register(extension, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Event, U extends Subscriber<T>> @NonNull U subscribe(
|
||||
@NonNull Class<T> eventClass, @NonNull Consumer<T> consumer) {
|
||||
return eventBus.subscribe(extension, eventClass, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterAll() {
|
||||
eventBus.unregisterAll(extension);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCustomItemsEvent;
|
|||
import org.geysermc.geyser.api.item.custom.CustomItemData;
|
||||
import org.geysermc.geyser.api.item.custom.CustomItemOptions;
|
||||
import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
|
||||
import org.geysermc.geyser.event.type.DefineCustomItemsEvent;
|
||||
import org.geysermc.geyser.inventory.item.StoredItemMappings;
|
||||
import org.geysermc.geyser.item.GeyserCustomMappingData;
|
||||
import org.geysermc.geyser.item.mappings.MappingsConfigReader;
|
||||
|
|
@ -108,7 +109,7 @@ public class ItemRegistryPopulator {
|
|||
});
|
||||
|
||||
nonVanillaCustomItems = new ObjectArrayList<>();
|
||||
GeyserImpl.getInstance().eventBus().fire(new GeyserDefineCustomItemsEvent(customItems, nonVanillaCustomItems) {
|
||||
GeyserImpl.getInstance().eventBus().fire(new DefineCustomItemsEvent(customItems, nonVanillaCustomItems) {
|
||||
@Override
|
||||
public boolean register(@NonNull String identifier, @NonNull CustomItemData customItemData) {
|
||||
if (CustomItemRegistryPopulator.initialCheck(identifier, customItemData, items)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue