Skip to content

Commit

Permalink
Fixed building and switched event library
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim203 committed Aug 13, 2022
1 parent ab6e0d1 commit 13046a8
Show file tree
Hide file tree
Showing 25 changed files with 180 additions and 609 deletions.
3 changes: 1 addition & 2 deletions api/base/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
dependencies {
api("org.geysermc.cumulus", "cumulus", Versions.cumulusVersion)
api("org.geysermc.event", "events", Versions.eventsVersion)
}

provided("net.kyori", "event-api", Versions.eventVersion)
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ public interface GeyserApi extends GeyserApiBase {
@Override
@Nullable GeyserConnection connectionByXuid(@NonNull String xuid);

/**
* {@inheritDoc}
*/
@Override
@Nullable GeyserConnection connectionByUsername(@NonNull String username);

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,71 +26,18 @@
package org.geysermc.geyser.api.event;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.event.Event;
import org.geysermc.event.bus.OwnedEventBus;
import org.geysermc.geyser.api.extension.Extension;

import java.util.Set;
import java.util.function.Consumer;

/**
* Represents a bus capable of subscribing
* or "listening" to events and firing them.
*/
public interface EventBus {

/**
* Subscribes to the given event see {@link EventSubscription}.
*
* The difference between this method and {@link ExtensionEventBus#subscribe(Class, Consumer)}
* is that this method takes in an extension parameter which allows for
* the event to be unsubscribed upon extension disable and reloads.
*
* @param extension the extension to subscribe the event to
* @param eventClass the class of the event
* @param consumer the consumer for handling the event
* @param <T> the event class
* @return the event subscription
*/
@NonNull
<T extends Event> EventSubscription<T> subscribe(@NonNull Extension extension, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> consumer);

/**
* Unsubscribes the given {@link EventSubscription}.
*
* @param subscription the event subscription
*/
<T extends Event> void unsubscribe(@NonNull EventSubscription<T> subscription);

/**
* Registers events for the given listener.
*
* @param extension the extension registering the event
* @param eventHolder the listener
*/
void register(@NonNull Extension extension, @NonNull Object eventHolder);

/**
* Unregisters all events from a given {@link Extension}.
*
* @param extension the extension
*/
void unregisterAll(@NonNull Extension extension);

/**
* Fires the given {@link Event} and returns the result.
*
* @param event the event to fire
*
* @return true if the event successfully fired
*/
boolean fire(@NonNull Event event);

/**
* Gets the subscriptions for the given event class.
*
* @param eventClass the event class
* @param <T> the value
* @return the subscriptions for the event class
*/
public interface EventBus extends OwnedEventBus<Extension, Event, EventSubscriber<? extends Event>> {
@Override
@NonNull
<T extends Event> Set<EventSubscription<T>> subscriptions(@NonNull Class<T> eventClass);
<T extends Event> Set<? extends EventSubscriber<T>> subscribers(@NonNull Class<T> eventClass);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,16 @@

package org.geysermc.geyser.api.event;

import org.geysermc.event.Event;
import org.geysermc.event.subscribe.OwnedSubscriber;
import org.geysermc.geyser.api.extension.Extension;

/**
* Represents a cancellable event.
* Represents a subscribed listener to a {@link Event}. Wraps around
* the event and is capable of unsubscribing from the event or give
* information about it.
*
* @param <T> the class of the event
*/
public interface Cancellable {

/**
* Gets if the event is cancelled.
*
* @return if the event is cancelled
*/
boolean isCancelled();

/**
* Cancels the event.
*
* @param cancelled if the event is cancelled
*/
void setCancelled(boolean cancelled);
public interface EventSubscriber<T extends Event> extends OwnedSubscriber<Extension, T> {
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,15 @@
package org.geysermc.geyser.api.event;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.event.Event;

import java.util.function.Consumer;
import java.util.Set;

/**
* An {@link EventBus} with additional methods that implicitly
* set the extension instance.
*
*/
public interface ExtensionEventBus extends EventBus {

/**
* Subscribes to the given event see {@link EventSubscription}.
*
* @param eventClass the class of the event
* @param consumer the consumer for handling the event
* @param <T> the event class
* @return the event subscription
*/
@NonNull
<T extends Event> EventSubscription<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> consumer);

/**
* Registers events for the given listener.
*
* @param eventHolder the listener
*/
void register(@NonNull Object eventHolder);

/**
* Unregisters all events for this extension.
*/
void unregisterAll();
public interface ExtensionEventBus extends org.geysermc.event.bus.EventBus<Event, EventSubscriber<? extends Event>> {
@Override
@NonNull <T extends Event> Set<? extends EventSubscriber<T>> subscribers(@NonNull Class<T> eventClass);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,8 @@

package org.geysermc.geyser.api.event;

/**
* Represents an event.
*/
public interface Event {
import org.geysermc.event.Event;
import org.geysermc.event.subscribe.Subscriber;

/**
* Gets if the event is async.
*
* @return if the event is async
*/
default boolean isAsync() {
return false;
}
public interface ExtensionEventSubscriber<T extends Event> extends Subscriber<T> {
}
103 changes: 0 additions & 103 deletions api/geyser/src/main/java/org/geysermc/geyser/api/event/Subscribe.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
package org.geysermc.geyser.api.event.connection;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.event.Event;
import org.geysermc.geyser.api.connection.GeyserConnection;
import org.geysermc.geyser.api.event.Event;

/**
* An event that contains a {@link GeyserConnection}.
Expand Down

0 comments on commit 13046a8

Please sign in to comment.