Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Add a base interface for events
Dieser Commit ist enthalten in:
Ursprung
e65c4102a6
Commit
e6e35d3754
9
api/src/main/java/com/velocitypowered/api/event/Event.java
Normale Datei
9
api/src/main/java/com/velocitypowered/api/event/Event.java
Normale Datei
@ -0,0 +1,9 @@
|
|||||||
|
package com.velocitypowered.api.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for all events in the Velocity API. This interface primarily exists to mark which
|
||||||
|
* classes are events in the API.
|
||||||
|
*/
|
||||||
|
public interface Event {
|
||||||
|
|
||||||
|
}
|
@ -15,7 +15,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
* similar), or pass events through to an external system to be handled.
|
* similar), or pass events through to an external system to be handled.
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface EventHandler<E> {
|
public interface EventHandler<E extends Event> {
|
||||||
|
|
||||||
@Nullable EventTask execute(E event);
|
@Nullable EventTask execute(E event);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ public interface EventManager {
|
|||||||
* @param handler the handler to register
|
* @param handler the handler to register
|
||||||
* @param <E> the event type to handle
|
* @param <E> the event type to handle
|
||||||
*/
|
*/
|
||||||
default <E> void register(Object plugin, Class<E> eventClass, EventHandler<E> handler) {
|
default <E extends Event> void register(Object plugin, Class<E> eventClass,
|
||||||
|
EventHandler<E> handler) {
|
||||||
register(plugin, eventClass, PostOrder.NORMAL, handler);
|
register(plugin, eventClass, PostOrder.NORMAL, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public interface EventManager {
|
|||||||
* @param handler the handler to register
|
* @param handler the handler to register
|
||||||
* @param <E> the event type to handle
|
* @param <E> the event type to handle
|
||||||
*/
|
*/
|
||||||
<E> void register(Object plugin, Class<E> eventClass, short postOrder,
|
<E extends Event> void register(Object plugin, Class<E> eventClass, short postOrder,
|
||||||
EventHandler<E> handler);
|
EventHandler<E> handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +58,7 @@ public interface EventManager {
|
|||||||
* @param event the event to fire
|
* @param event the event to fire
|
||||||
* @return a {@link CompletableFuture} representing the posted event
|
* @return a {@link CompletableFuture} representing the posted event
|
||||||
*/
|
*/
|
||||||
<E> CompletableFuture<E> fire(E event);
|
<E extends Event> CompletableFuture<E> fire(E event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts the specified event to the event bus and discards the result.
|
* Posts the specified event to the event bus and discards the result.
|
||||||
@ -65,7 +66,7 @@ public interface EventManager {
|
|||||||
* @param event the event to fire
|
* @param event the event to fire
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("FutureReturnValueIgnored")
|
@SuppressWarnings("FutureReturnValueIgnored")
|
||||||
default void fireAndForget(Object event) {
|
default void fireAndForget(Event event) {
|
||||||
// Calling fire(Object) and not handling it is intentional.
|
// Calling fire(Object) and not handling it is intentional.
|
||||||
fire(event);
|
fire(event);
|
||||||
}
|
}
|
||||||
@ -92,5 +93,5 @@ public interface EventManager {
|
|||||||
* @param handler the handler to register
|
* @param handler the handler to register
|
||||||
* @param <E> the event type to handle
|
* @param <E> the event type to handle
|
||||||
*/
|
*/
|
||||||
<E> void unregister(Object plugin, EventHandler<E> handler);
|
<E extends Event> void unregister(Object plugin, EventHandler<E> handler);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
/**
|
/**
|
||||||
* Indicates an event that has a result attached to it.
|
* Indicates an event that has a result attached to it.
|
||||||
*/
|
*/
|
||||||
public interface ResultedEvent<R extends ResultedEvent.Result> {
|
public interface ResultedEvent<R extends ResultedEvent.Result> extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result associated with this event.
|
* Returns the result associated with this event.
|
||||||
|
@ -8,13 +8,14 @@
|
|||||||
package com.velocitypowered.api.event.command;
|
package com.velocitypowered.api.event.command;
|
||||||
|
|
||||||
import com.mojang.brigadier.tree.RootCommandNode;
|
import com.mojang.brigadier.tree.RootCommandNode;
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows plugins to modify the packet indicating commands available on the server to a
|
* Allows plugins to modify the packet indicating commands available on the server to a
|
||||||
* Minecraft 1.13+ client.
|
* Minecraft 1.13+ client.
|
||||||
*/
|
*/
|
||||||
public interface PlayerAvailableCommandsEvent {
|
public interface PlayerAvailableCommandsEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
|
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.connection;
|
package com.velocitypowered.api.event.connection;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
||||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired when a server list ping request is sent by a remote client.
|
* This event is fired when a server list ping request is sent by a remote client.
|
||||||
*/
|
*/
|
||||||
public interface ProxyPingEvent {
|
public interface ProxyPingEvent extends Event {
|
||||||
|
|
||||||
InboundConnection connection();
|
InboundConnection connection();
|
||||||
|
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.connection;
|
package com.velocitypowered.api.event.connection;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.server.QueryResponse;
|
import com.velocitypowered.api.proxy.server.QueryResponse;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired if proxy is getting queried over GS4 Query protocol.
|
* This event is fired if proxy is getting queried over GS4 Query protocol.
|
||||||
*/
|
*/
|
||||||
public interface ProxyQueryEvent {
|
public interface ProxyQueryEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the kind of query the remote client is performing.
|
* Returns the kind of query the remote client is performing.
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.lifecycle;
|
package com.velocitypowered.api.event.lifecycle;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired by the proxy after plugins have been loaded but before the proxy starts
|
* This event is fired by the proxy after plugins have been loaded but before the proxy starts
|
||||||
* accepting connections.
|
* accepting connections.
|
||||||
*/
|
*/
|
||||||
public interface ProxyInitializeEvent {
|
public interface ProxyInitializeEvent extends Event {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.lifecycle;
|
package com.velocitypowered.api.event.lifecycle;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired when the proxy is reloaded by the user using {@code /velocity reload}.
|
* This event is fired when the proxy is reloaded by the user using {@code /velocity reload}.
|
||||||
*/
|
*/
|
||||||
public interface ProxyReloadEvent {
|
public interface ProxyReloadEvent extends Event {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.lifecycle;
|
package com.velocitypowered.api.event.lifecycle;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired by the proxy after the proxy has stopped accepting connections but before the
|
* This event is fired by the proxy after the proxy has stopped accepting connections but before the
|
||||||
* proxy process exits.
|
* proxy process exits.
|
||||||
*/
|
*/
|
||||||
public interface ProxyShutdownEvent {
|
public interface ProxyShutdownEvent extends Event {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.lifecycle.network;
|
package com.velocitypowered.api.event.lifecycle.network;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.network.ListenerType;
|
import com.velocitypowered.api.network.ListenerType;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired by the proxy after a listener starts accepting connections.
|
* This event is fired by the proxy after a listener starts accepting connections.
|
||||||
*/
|
*/
|
||||||
public interface ListenerBoundEvent {
|
public interface ListenerBoundEvent extends Event {
|
||||||
|
|
||||||
SocketAddress address();
|
SocketAddress address();
|
||||||
|
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.lifecycle.network;
|
package com.velocitypowered.api.event.lifecycle.network;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.network.ListenerType;
|
import com.velocitypowered.api.network.ListenerType;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired by the proxy before the proxy stops accepting connections.
|
* This event is fired by the proxy before the proxy stops accepting connections.
|
||||||
*/
|
*/
|
||||||
public interface ListenerClosedEvent {
|
public interface ListenerClosedEvent extends Event {
|
||||||
|
|
||||||
SocketAddress address();
|
SocketAddress address();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.permission;
|
package com.velocitypowered.api.event.permission;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.permission.PermissionFunction;
|
import com.velocitypowered.api.permission.PermissionFunction;
|
||||||
import com.velocitypowered.api.permission.PermissionProvider;
|
import com.velocitypowered.api.permission.PermissionProvider;
|
||||||
import com.velocitypowered.api.permission.PermissionSubject;
|
import com.velocitypowered.api.permission.PermissionSubject;
|
||||||
@ -17,7 +18,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
*
|
*
|
||||||
* <p>This event is only called once per subject, on initialisation.</p>
|
* <p>This event is only called once per subject, on initialisation.</p>
|
||||||
*/
|
*/
|
||||||
public interface PermissionsSetupEvent {
|
public interface PermissionsSetupEvent extends Event {
|
||||||
|
|
||||||
PermissionSubject subject();
|
PermissionSubject subject();
|
||||||
|
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired when a player disconnects from the proxy. Operations on the provided player,
|
* This event is fired when a player disconnects from the proxy. Operations on the provided player,
|
||||||
* aside from basic data retrieval operations, may behave in undefined ways.
|
* aside from basic data retrieval operations, may behave in undefined ways.
|
||||||
*/
|
*/
|
||||||
public interface DisconnectEvent {
|
public interface DisconnectEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -15,7 +16,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
* This event is fired after the {@link PreLoginEventImpl} in order to set up the game profile for
|
* This event is fired after the {@link PreLoginEventImpl} in order to set up the game profile for
|
||||||
* the user. This can be used to configure a custom profile for a user, i.e. skin replacement.
|
* the user. This can be used to configure a custom profile for a user, i.e. skin replacement.
|
||||||
*/
|
*/
|
||||||
public interface GameProfileRequestEvent {
|
public interface GameProfileRequestEvent extends Event {
|
||||||
|
|
||||||
InboundConnection connection();
|
InboundConnection connection();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
import com.velocitypowered.api.proxy.messages.PluginChannelId;
|
import com.velocitypowered.api.proxy.messages.PluginChannelId;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -15,7 +16,7 @@ import java.util.List;
|
|||||||
* This event is fired when a client ({@link Player}) sends a plugin message through the
|
* This event is fired when a client ({@link Player}) sends a plugin message through the
|
||||||
* register channel.
|
* register channel.
|
||||||
*/
|
*/
|
||||||
public interface PlayerChannelRegisterEvent {
|
public interface PlayerChannelRegisterEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -15,7 +16,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
* Fired when a player has finished connecting to the proxy and we need to choose the first server
|
* Fired when a player has finished connecting to the proxy and we need to choose the first server
|
||||||
* to connect to.
|
* to connect to.
|
||||||
*/
|
*/
|
||||||
public interface PlayerChooseInitialServerEvent {
|
public interface PlayerChooseInitialServerEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
import com.velocitypowered.api.proxy.player.ClientSettings;
|
import com.velocitypowered.api.proxy.player.ClientSettings;
|
||||||
|
|
||||||
public interface PlayerClientSettingsChangedEvent {
|
public interface PlayerClientSettingsChangedEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
import com.velocitypowered.api.util.ModInfo;
|
import com.velocitypowered.api.util.ModInfo;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ import com.velocitypowered.api.util.ModInfo;
|
|||||||
* This event is fired when a modded client sends its mods to the proxy while connecting to a
|
* This event is fired when a modded client sends its mods to the proxy while connecting to a
|
||||||
* server.
|
* server.
|
||||||
*/
|
*/
|
||||||
public interface PlayerModInfoEvent {
|
public interface PlayerModInfoEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
|
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired when the status of a resource pack sent to the player by the server is
|
* This event is fired when the status of a resource pack sent to the player by the server is
|
||||||
* changed.
|
* changed.
|
||||||
*/
|
*/
|
||||||
public interface PlayerResourcePackStatusEvent {
|
public interface PlayerResourcePackStatusEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player affected by the change in resource pack status.
|
* Returns the player affected by the change in resource pack status.
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired once the player has been fully initialized and is about to connect to their
|
* This event is fired once the player has been fully initialized and is about to connect to their
|
||||||
* first server.
|
* first server.
|
||||||
*/
|
*/
|
||||||
public interface PostLoginEvent {
|
public interface PostLoginEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -15,7 +16,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
* This event is fired once the player has successfully connected to the target server and the
|
* This event is fired once the player has successfully connected to the target server and the
|
||||||
* connection to the previous server has been de-established.
|
* connection to the previous server has been de-established.
|
||||||
*/
|
*/
|
||||||
public interface ServerConnectedEvent {
|
public interface ServerConnectedEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -15,7 +16,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
* Fired after the player has connected to a server. The server the player is now connected to is
|
* Fired after the player has connected to a server. The server the player is now connected to is
|
||||||
* available in {@link Player#connectedServer()}.
|
* available in {@link Player#connectedServer()}.
|
||||||
*/
|
*/
|
||||||
public interface ServerPostConnectEvent {
|
public interface ServerPostConnectEvent extends Event {
|
||||||
|
|
||||||
Player player();
|
Player player();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.proxy.connection.Player;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ import java.util.List;
|
|||||||
* This event is fired after a tab complete response is sent by the remote server, for clients on
|
* This event is fired after a tab complete response is sent by the remote server, for clients on
|
||||||
* 1.12.2 and below. You have the opportunity to modify the response sent to the remote player.
|
* 1.12.2 and below. You have the opportunity to modify the response sent to the remote player.
|
||||||
*/
|
*/
|
||||||
public interface TabCompleteEvent {
|
public interface TabCompleteEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player requesting the tab completion.
|
* Returns the player requesting the tab completion.
|
||||||
|
@ -10,7 +10,34 @@ package com.velocitypowered.api.util;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
* This file is derived from the FastUUID project (https://github.com/jchambers/fast-uuid). The
|
||||||
|
* original copyright notice is reproduced below:
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 Jon Chambers
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
* This is a modified FastUUID implementation. The primary difference is that it does not dash its
|
* This is a modified FastUUID implementation. The primary difference is that it does not dash its
|
||||||
* UUIDs. As the native Java 9+ UUID.toString() implementation dashes its UUIDs, we use the FastUUID
|
* UUIDs. As the native Java 9+ UUID.toString() implementation dashes its UUIDs, we use the FastUUID
|
||||||
* internal method, which ought to be faster than a String.replace().
|
* internal method, which ought to be faster than a String.replace().
|
||||||
|
@ -27,6 +27,7 @@ import com.google.common.collect.Multimap;
|
|||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import com.velocitypowered.api.event.Continuation;
|
import com.velocitypowered.api.event.Continuation;
|
||||||
|
import com.velocitypowered.api.event.Event;
|
||||||
import com.velocitypowered.api.event.EventHandler;
|
import com.velocitypowered.api.event.EventHandler;
|
||||||
import com.velocitypowered.api.event.EventManager;
|
import com.velocitypowered.api.event.EventManager;
|
||||||
import com.velocitypowered.api.event.EventTask;
|
import com.velocitypowered.api.event.EventTask;
|
||||||
@ -107,7 +108,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
final PluginContainer plugin;
|
final PluginContainer plugin;
|
||||||
final short order;
|
final short order;
|
||||||
final Class<?> eventType;
|
final Class<?> eventType;
|
||||||
final EventHandler<Object> handler;
|
final EventHandler<Event> handler;
|
||||||
final AsyncType asyncType;
|
final AsyncType asyncType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,7 +118,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
final Object instance;
|
final Object instance;
|
||||||
|
|
||||||
public HandlerRegistration(final PluginContainer plugin, final short order,
|
public HandlerRegistration(final PluginContainer plugin, final short order,
|
||||||
final Class<?> eventType, final Object instance, final EventHandler<Object> handler,
|
final Class<?> eventType, final Object instance, final EventHandler<Event> handler,
|
||||||
final AsyncType asyncType) {
|
final AsyncType asyncType) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.order = order;
|
this.order = order;
|
||||||
@ -320,14 +321,14 @@ public class VelocityEventManager implements EventManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <E> void register(final Object plugin, final Class<E> eventClass,
|
public <E extends Event> void register(final Object plugin, final Class<E> eventClass,
|
||||||
final short order, final EventHandler<E> handler) {
|
final short order, final EventHandler<E> handler) {
|
||||||
final PluginContainer pluginContainer = pluginManager.ensurePluginContainer(plugin);
|
final PluginContainer pluginContainer = pluginManager.ensurePluginContainer(plugin);
|
||||||
requireNonNull(eventClass, "eventClass");
|
requireNonNull(eventClass, "eventClass");
|
||||||
requireNonNull(handler, "handler");
|
requireNonNull(handler, "handler");
|
||||||
|
|
||||||
final HandlerRegistration registration = new HandlerRegistration(pluginContainer, order,
|
final HandlerRegistration registration = new HandlerRegistration(pluginContainer, order,
|
||||||
eventClass, handler, (EventHandler<Object>) handler, AsyncType.SOMETIMES);
|
eventClass, handler, (EventHandler<Event>) handler, AsyncType.SOMETIMES);
|
||||||
register(Collections.singletonList(registration));
|
register(Collections.singletonList(registration));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +350,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
throw new VerifyException("Event type is not present and there are no errors");
|
throw new VerifyException("Event type is not present and there are no errors");
|
||||||
}
|
}
|
||||||
|
|
||||||
final EventHandler<Object> handler = event -> untargetedHandler.execute(listener, event);
|
final EventHandler<Event> handler = event -> untargetedHandler.execute(listener, event);
|
||||||
registrations.add(new HandlerRegistration(pluginContainer, info.order,
|
registrations.add(new HandlerRegistration(pluginContainer, info.order,
|
||||||
info.eventType, listener, handler, info.asyncType));
|
info.eventType, listener, handler, info.asyncType));
|
||||||
}
|
}
|
||||||
@ -372,7 +373,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void unregister(final Object plugin, final EventHandler<E> handler) {
|
public <E extends Event> void unregister(final Object plugin, final EventHandler<E> handler) {
|
||||||
unregisterListener(plugin, handler);
|
unregisterListener(plugin, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +401,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireAndForget(final Object event) {
|
public void fireAndForget(final Event event) {
|
||||||
requireNonNull(event, "event");
|
requireNonNull(event, "event");
|
||||||
final HandlersCache handlersCache = this.handlersCache.get(event.getClass());
|
final HandlersCache handlersCache = this.handlersCache.get(event.getClass());
|
||||||
if (handlersCache == null) {
|
if (handlersCache == null) {
|
||||||
@ -411,7 +412,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> CompletableFuture<E> fire(final E event) {
|
public <E extends Event> CompletableFuture<E> fire(final E event) {
|
||||||
requireNonNull(event, "event");
|
requireNonNull(event, "event");
|
||||||
final HandlersCache handlersCache = this.handlersCache.get(event.getClass());
|
final HandlersCache handlersCache = this.handlersCache.get(event.getClass());
|
||||||
if (handlersCache == null) {
|
if (handlersCache == null) {
|
||||||
@ -423,7 +424,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <E> void fire(final @Nullable CompletableFuture<E> future,
|
private <E extends Event> void fire(final @Nullable CompletableFuture<E> future,
|
||||||
final E event, final HandlersCache handlersCache) {
|
final E event, final HandlersCache handlersCache) {
|
||||||
if (handlersCache.asyncType == AsyncType.ALWAYS) {
|
if (handlersCache.asyncType == AsyncType.ALWAYS) {
|
||||||
// We already know that the event needs to be handled async, so
|
// We already know that the event needs to be handled async, so
|
||||||
@ -452,7 +453,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ContinuationTask<E> implements Continuation, Runnable {
|
final class ContinuationTask<E extends Event> implements Continuation, Runnable {
|
||||||
|
|
||||||
private final EventTask.WithContinuation task;
|
private final EventTask.WithContinuation task;
|
||||||
private final int index;
|
private final int index;
|
||||||
@ -545,7 +546,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <E> void fire(final @Nullable CompletableFuture<E> future, final E event,
|
private <E extends Event> void fire(final @Nullable CompletableFuture<E> future, final E event,
|
||||||
final int offset, final boolean currentlyAsync, final HandlerRegistration[] registrations) {
|
final int offset, final boolean currentlyAsync, final HandlerRegistration[] registrations) {
|
||||||
for (int i = offset; i < registrations.length; i++) {
|
for (int i = offset; i < registrations.length; i++) {
|
||||||
final HandlerRegistration registration = registrations[i];
|
final HandlerRegistration registration = registrations[i];
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren