3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Extract interfaces for all events.

This is in preparation for moving to event-impl-gen.
Dieser Commit ist enthalten in:
Andrew Steinborn 2021-04-17 03:50:10 -04:00
Ursprung c8519949bc
Commit 730d385f02
68 geänderte Dateien mit 1539 neuen und 809 gelöschten Zeilen

Datei anzeigen

@ -100,10 +100,6 @@ test {
useJUnitPlatform()
}
test {
useJUnitPlatform()
}
publishing {
publications {
mavenJava(MavenPublication) {

Datei anzeigen

@ -7,7 +7,7 @@
package com.velocitypowered.api.command;
import com.velocitypowered.api.event.command.CommandExecuteEvent;
import com.velocitypowered.api.event.command.CommandExecuteEventImpl;
import java.util.concurrent.CompletableFuture;
/**
@ -81,7 +81,7 @@ public interface CommandManager {
/**
* Attempts to asynchronously execute a command from the given {@code cmdLine}
* without firing a {@link CommandExecuteEvent}.
* without firing a {@link CommandExecuteEventImpl}.
*
* @param source the source to execute the command for
* @param cmdLine the command to run

Datei anzeigen

@ -16,63 +16,22 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This event is fired when someone executing command.
* This event is fired when someone executes a command.
*/
public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
public interface CommandExecuteEvent extends ResultedEvent<CommandResult> {
private final CommandSource commandSource;
private final String command;
private CommandResult result;
CommandSource getCommandSource();
/**
* Constructs a CommandExecuteEvent.
* @param commandSource the source executing the command
* @param command the command being executed without first slash
*/
public CommandExecuteEvent(CommandSource commandSource, String command) {
this.commandSource = Preconditions.checkNotNull(commandSource, "commandSource");
this.command = Preconditions.checkNotNull(command, "command");
this.result = CommandResult.allowed();
}
public CommandSource getCommandSource() {
return commandSource;
}
/**
* Gets the original command being executed without first slash.
* Gets the original command being executed without the first slash.
* @return the original command being executed
*/
public String getCommand() {
return command;
}
String getCommand();
@Override
public CommandResult getResult() {
return result;
}
final class CommandResult implements ResultedEvent.Result {
@Override
public void setResult(CommandResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public String toString() {
return "CommandExecuteEvent{"
+ "commandSource=" + commandSource
+ ", command=" + command
+ ", result=" + result
+ '}';
}
/**
* Represents the result of the {@link CommandExecuteEvent}.
*/
public static final class CommandResult implements ResultedEvent.Result {
private static final CommandResult ALLOWED = new CommandResult(true, false,null);
private static final CommandResult DENIED = new CommandResult(false, false,null);
private static final CommandResult ALLOWED = new CommandResult(true, false, null);
private static final CommandResult DENIED = new CommandResult(false, false, null);
private static final CommandResult FORWARD_TO_SERVER = new CommandResult(false, true, null);
private @Nullable String command;
@ -105,6 +64,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
/**
* Allows the command to be sent, without modification.
*
* @return the allowed result
*/
public static CommandResult allowed() {
@ -113,6 +73,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
/**
* Prevents the command from being executed.
*
* @return the denied result
*/
public static CommandResult denied() {
@ -121,6 +82,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
/**
* Prevents the command from being executed, but forward command to server.
*
* @return the forward result
*/
public static CommandResult forwardToServer() {
@ -129,6 +91,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
/**
* Prevents the command from being executed on proxy, but forward command to server.
*
* @param newCommand the command without first slash to use instead
* @return a result with a new command being forwarded to server
*/
@ -139,6 +102,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
/**
* Allows the command to be executed, but silently replaced old command with another.
*
* @param newCommand the command to use instead without first slash
* @return a result with a new command
*/
@ -147,4 +111,5 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
return new CommandResult(true, false, newCommand);
}
}
}

Datei anzeigen

@ -0,0 +1,66 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.command;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.command.CommandSource;
/**
* This event is fired when someone executing command.
*/
public final class CommandExecuteEventImpl implements CommandExecuteEvent {
private final CommandSource commandSource;
private final String command;
private CommandResult result;
/**
* Constructs a CommandExecuteEvent.
* @param commandSource the source executing the command
* @param command the command being executed without first slash
*/
public CommandExecuteEventImpl(CommandSource commandSource, String command) {
this.commandSource = Preconditions.checkNotNull(commandSource, "commandSource");
this.command = Preconditions.checkNotNull(command, "command");
this.result = CommandResult.allowed();
}
@Override
public CommandSource getCommandSource() {
return commandSource;
}
/**
* Gets the original command being executed without first slash.
* @return the original command being executed
*/
@Override
public String getCommand() {
return command;
}
@Override
public CommandResult getResult() {
return result;
}
@Override
public void setResult(CommandResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public String toString() {
return "CommandExecuteEvent{"
+ "commandSource=" + commandSource
+ ", command=" + command
+ ", result=" + result
+ '}';
}
}

Datei anzeigen

@ -7,9 +7,6 @@
package com.velocitypowered.api.event.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
import com.mojang.brigadier.tree.RootCommandNode;
import com.velocitypowered.api.proxy.connection.Player;
@ -17,28 +14,9 @@ import com.velocitypowered.api.proxy.connection.Player;
* Allows plugins to modify the packet indicating commands available on the server to a
* Minecraft 1.13+ client.
*/
@Beta
public class PlayerAvailableCommandsEvent {
public interface PlayerAvailableCommandsEvent {
private final Player player;
private final RootCommandNode<?> rootNode;
Player getPlayer();
/**
* Constructs an available commands event.
* @param player the targeted player
* @param rootNode the Brigadier root node
*/
public PlayerAvailableCommandsEvent(Player player,
RootCommandNode<?> rootNode) {
this.player = checkNotNull(player, "player");
this.rootNode = checkNotNull(rootNode, "rootNode");
}
public Player getPlayer() {
return player;
}
public RootCommandNode<?> getRootNode() {
return rootNode;
}
RootCommandNode<?> getRootNode();
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
import com.mojang.brigadier.tree.RootCommandNode;
import com.velocitypowered.api.proxy.connection.Player;
/**
* Allows plugins to modify the packet indicating commands available on the server to a
* Minecraft 1.13+ client.
*/
@Beta
public class PlayerAvailableCommandsEventImpl implements PlayerAvailableCommandsEvent {
private final Player player;
private final RootCommandNode<?> rootNode;
/**
* Constructs an available commands event.
* @param player the targeted player
* @param rootNode the Brigadier root node
*/
public PlayerAvailableCommandsEventImpl(Player player,
RootCommandNode<?> rootNode) {
this.player = checkNotNull(player, "player");
this.rootNode = checkNotNull(rootNode, "rootNode");
}
@Override
public Player getPlayer() {
return player;
}
@Override
public RootCommandNode<?> getRootNode() {
return rootNode;
}
}

Datei anzeigen

@ -7,28 +7,9 @@
package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.InboundConnection;
/**
* This event is fired when a handshake is established between a client and the proxy.
*/
public final class ConnectionHandshakeEvent {
public interface ConnectionHandshakeEvent {
private final InboundConnection connection;
public ConnectionHandshakeEvent(InboundConnection connection) {
this.connection = Preconditions.checkNotNull(connection, "connection");
}
public InboundConnection getConnection() {
return connection;
}
@Override
public String toString() {
return "ConnectionHandshakeEvent{"
+ "connection=" + connection
+ '}';
}
}

Datei anzeigen

@ -0,0 +1,34 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.InboundConnection;
/**
* This event is fired when a handshake is established between a client and the proxy.
*/
public final class ConnectionHandshakeEventImpl implements ConnectionHandshakeEvent {
private final InboundConnection connection;
public ConnectionHandshakeEventImpl(InboundConnection connection) {
this.connection = Preconditions.checkNotNull(connection, "connection");
}
public InboundConnection getConnection() {
return connection;
}
@Override
public String toString() {
return "ConnectionHandshakeEvent{"
+ "connection=" + connection
+ '}';
}
}

Datei anzeigen

@ -7,40 +7,17 @@
package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.InboundConnection;
import com.velocitypowered.api.proxy.server.ServerPing;
/**
* This event is fired when a server list ping request is sent by a remote client.
*/
public final class ProxyPingEvent {
public interface ProxyPingEvent {
private final InboundConnection connection;
private ServerPing ping;
InboundConnection getConnection();
public ProxyPingEvent(InboundConnection connection, ServerPing ping) {
this.connection = Preconditions.checkNotNull(connection, "connection");
this.ping = Preconditions.checkNotNull(ping, "ping");
}
ServerPing getPing();
public InboundConnection getConnection() {
return connection;
}
public ServerPing getPing() {
return ping;
}
public void setPing(ServerPing ping) {
this.ping = Preconditions.checkNotNull(ping, "ping");
}
@Override
public String toString() {
return "ProxyPingEvent{"
+ "connection=" + connection
+ ", ping=" + ping
+ '}';
}
void setPing(ServerPing ping);
}

Datei anzeigen

@ -0,0 +1,49 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.InboundConnection;
import com.velocitypowered.api.proxy.server.ServerPing;
/**
* This event is fired when a server list ping request is sent by a remote client.
*/
public final class ProxyPingEventImpl implements ProxyPingEvent {
private final InboundConnection connection;
private ServerPing ping;
public ProxyPingEventImpl(InboundConnection connection, ServerPing ping) {
this.connection = Preconditions.checkNotNull(connection, "connection");
this.ping = Preconditions.checkNotNull(ping, "ping");
}
@Override
public InboundConnection getConnection() {
return connection;
}
@Override
public ServerPing getPing() {
return ping;
}
@Override
public void setPing(ServerPing ping) {
this.ping = Preconditions.checkNotNull(ping, "ping");
}
@Override
public String toString() {
return "ProxyPingEvent{"
+ "connection=" + connection
+ ", ping=" + ping
+ '}';
}
}

Datei anzeigen

@ -7,81 +7,46 @@
package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.server.QueryResponse;
import java.net.InetAddress;
/**
* This event is fired if proxy is getting queried over GS4 Query protocol.
*/
public final class ProxyQueryEvent {
private final QueryType queryType;
private final InetAddress querierAddress;
private QueryResponse response;
/**
* Creates a new event.
*
* @param queryType the type of query
* @param querierAddress the remote address for the query
* @param response the current query response
*/
public ProxyQueryEvent(QueryType queryType, InetAddress querierAddress, QueryResponse response) {
this.queryType = Preconditions.checkNotNull(queryType, "queryType");
this.querierAddress = Preconditions.checkNotNull(querierAddress, "querierAddress");
this.response = Preconditions.checkNotNull(response, "response");
}
public interface ProxyQueryEvent {
/**
* Returns the kind of query the remote client is performing.
*
* @return query type
*/
public QueryType getQueryType() {
return queryType;
}
QueryType getQueryType();
/**
* Get the address of the client that sent this query.
*
* @return querier address
*/
public InetAddress getQuerierAddress() {
return querierAddress;
}
InetAddress getQuerierAddress();
/**
* Returns the current query response.
*
* @return the current query response
*/
public QueryResponse getResponse() {
return response;
}
QueryResponse getResponse();
/**
* Sets a new query response.
*
* @param response the new non-null query response
*/
public void setResponse(QueryResponse response) {
this.response = Preconditions.checkNotNull(response, "response");
}
@Override
public String toString() {
return "ProxyQueryEvent{"
+ "queryType=" + queryType
+ ", querierAddress=" + querierAddress
+ ", response=" + response
+ '}';
}
void setResponse(QueryResponse response);
/**
* Represents the type of query the client is asking for.
*/
public enum QueryType {
enum QueryType {
/**
* Basic query asks only a subset of information, such as hostname, game type (hardcoded to
* <pre>MINECRAFT</pre>), map, current players, max players, proxy port and proxy hostname.

Datei anzeigen

@ -0,0 +1,85 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.server.QueryResponse;
import java.net.InetAddress;
/**
* This event is fired if proxy is getting queried over GS4 Query protocol.
*/
public final class ProxyQueryEventImpl implements ProxyQueryEvent {
private final QueryType queryType;
private final InetAddress querierAddress;
private QueryResponse response;
/**
* Creates a new event.
*
* @param queryType the type of query
* @param querierAddress the remote address for the query
* @param response the current query response
*/
public ProxyQueryEventImpl(QueryType queryType, InetAddress querierAddress, QueryResponse response) {
this.queryType = Preconditions.checkNotNull(queryType, "queryType");
this.querierAddress = Preconditions.checkNotNull(querierAddress, "querierAddress");
this.response = Preconditions.checkNotNull(response, "response");
}
/**
* Returns the kind of query the remote client is performing.
*
* @return query type
*/
@Override
public QueryType getQueryType() {
return queryType;
}
/**
* Get the address of the client that sent this query.
*
* @return querier address
*/
@Override
public InetAddress getQuerierAddress() {
return querierAddress;
}
/**
* Returns the current query response.
*
* @return the current query response
*/
@Override
public QueryResponse getResponse() {
return response;
}
/**
* Sets a new query response.
*
* @param response the new non-null query response
*/
@Override
public void setResponse(QueryResponse response) {
this.response = Preconditions.checkNotNull(response, "response");
}
@Override
public String toString() {
return "ProxyQueryEvent{"
+ "queryType=" + queryType
+ ", querierAddress=" + querierAddress
+ ", response=" + response
+ '}';
}
}

Datei anzeigen

@ -11,10 +11,6 @@ package com.velocitypowered.api.event.lifecycle;
* This event is fired by the proxy after plugins have been loaded but before the proxy starts
* accepting connections.
*/
public final class ProxyInitializeEvent {
public interface ProxyInitializeEvent {
@Override
public String toString() {
return "ProxyInitializeEvent";
}
}

Datei anzeigen

@ -0,0 +1,20 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.lifecycle;
/**
* This event is fired by the proxy after plugins have been loaded but before the proxy starts
* accepting connections.
*/
public final class ProxyInitializeEventImpl implements ProxyInitializeEvent {
@Override
public String toString() {
return "ProxyInitializeEvent";
}
}

Datei anzeigen

@ -10,10 +10,6 @@ package com.velocitypowered.api.event.lifecycle;
/**
* This event is fired when the proxy is reloaded by the user using {@code /velocity reload}.
*/
public class ProxyReloadEvent {
public interface ProxyReloadEvent {
@Override
public String toString() {
return "ProxyReloadEvent";
}
}

Datei anzeigen

@ -0,0 +1,19 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.lifecycle;
/**
* This event is fired when the proxy is reloaded by the user using {@code /velocity reload}.
*/
public class ProxyReloadEventImpl implements ProxyReloadEvent {
@Override
public String toString() {
return "ProxyReloadEvent";
}
}

Datei anzeigen

@ -11,10 +11,6 @@ package com.velocitypowered.api.event.lifecycle;
* This event is fired by the proxy after the proxy has stopped accepting connections but before the
* proxy process exits.
*/
public final class ProxyShutdownEvent {
public interface ProxyShutdownEvent {
@Override
public String toString() {
return "ProxyShutdownEvent";
}
}

Datei anzeigen

@ -0,0 +1,16 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.lifecycle;
public final class ProxyShutdownEventImpl implements ProxyShutdownEvent {
@Override
public String toString() {
return "ProxyShutdownEvent";
}
}

Datei anzeigen

@ -7,37 +7,15 @@
package com.velocitypowered.api.event.lifecycle.network;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.network.ListenerType;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
/**
* This event is fired by the proxy after a listener starts accepting connections.
*/
public final class ListenerBoundEvent {
public interface ListenerBoundEvent {
private final SocketAddress address;
private final ListenerType listenerType;
SocketAddress getAddress();
public ListenerBoundEvent(SocketAddress address, ListenerType listenerType) {
this.address = Preconditions.checkNotNull(address, "address");
this.listenerType = Preconditions.checkNotNull(listenerType, "listenerType");
}
public SocketAddress getAddress() {
return address;
}
public ListenerType getListenerType() {
return listenerType;
}
@Override
public String toString() {
return "ListenerBoundEvent{"
+ "address=" + address
+ ", listenerType=" + listenerType
+ '}';
}
}
ListenerType getListenerType();
}

Datei anzeigen

@ -0,0 +1,44 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.lifecycle.network;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.network.ListenerType;
import java.net.SocketAddress;
/**
* This event is fired by the proxy after a listener starts accepting connections.
*/
public final class ListenerBoundEventImpl implements ListenerBoundEvent {
private final SocketAddress address;
private final ListenerType listenerType;
public ListenerBoundEventImpl(SocketAddress address, ListenerType listenerType) {
this.address = Preconditions.checkNotNull(address, "address");
this.listenerType = Preconditions.checkNotNull(listenerType, "listenerType");
}
@Override
public SocketAddress getAddress() {
return address;
}
@Override
public ListenerType getListenerType() {
return listenerType;
}
@Override
public String toString() {
return "ListenerBoundEvent{"
+ "address=" + address
+ ", listenerType=" + listenerType
+ '}';
}
}

Datei anzeigen

@ -7,37 +7,15 @@
package com.velocitypowered.api.event.lifecycle.network;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.network.ListenerType;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
/**
* This event is fired by the proxy before the proxy stops accepting connections.
*/
public final class ListenerClosedEvent {
public interface ListenerClosedEvent {
private final SocketAddress address;
private final ListenerType listenerType;
SocketAddress getAddress();
public ListenerClosedEvent(SocketAddress address, ListenerType listenerType) {
this.address = Preconditions.checkNotNull(address, "address");
this.listenerType = Preconditions.checkNotNull(listenerType, "listenerType");
}
public SocketAddress getAddress() {
return address;
}
public ListenerType getListenerType() {
return listenerType;
}
@Override
public String toString() {
return "ListenerCloseEvent{"
+ "address=" + address
+ ", listenerType=" + listenerType
+ '}';
}
}
ListenerType getListenerType();
}

Datei anzeigen

@ -0,0 +1,44 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.lifecycle.network;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.network.ListenerType;
import java.net.SocketAddress;
/**
* This event is fired by the proxy before the proxy stops accepting connections.
*/
public final class ListenerClosedEventImpl implements ListenerClosedEvent {
private final SocketAddress address;
private final ListenerType listenerType;
public ListenerClosedEventImpl(SocketAddress address, ListenerType listenerType) {
this.address = Preconditions.checkNotNull(address, "address");
this.listenerType = Preconditions.checkNotNull(listenerType, "listenerType");
}
@Override
public SocketAddress getAddress() {
return address;
}
@Override
public ListenerType getListenerType() {
return listenerType;
}
@Override
public String toString() {
return "ListenerCloseEvent{"
+ "address=" + address
+ ", listenerType=" + listenerType
+ '}';
}
}

Datei anzeigen

@ -7,7 +7,6 @@
package com.velocitypowered.api.event.permission;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.permission.PermissionProvider;
import com.velocitypowered.api.permission.PermissionSubject;
@ -18,20 +17,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* <p>This event is only called once per subject, on initialisation.</p>
*/
public final class PermissionsSetupEvent {
public interface PermissionsSetupEvent {
private final PermissionSubject subject;
private final PermissionProvider defaultProvider;
private PermissionProvider provider;
public PermissionsSetupEvent(PermissionSubject subject, PermissionProvider provider) {
this.subject = Preconditions.checkNotNull(subject, "subject");
this.provider = this.defaultProvider = Preconditions.checkNotNull(provider, "provider");
}
public PermissionSubject getSubject() {
return this.subject;
}
PermissionSubject getSubject();
/**
* Uses the provider function to obtain a {@link PermissionFunction} for the subject.
@ -39,13 +27,9 @@ public final class PermissionsSetupEvent {
* @param subject the subject
* @return the obtained permission function
*/
public PermissionFunction createFunction(PermissionSubject subject) {
return this.provider.createFunction(subject);
}
PermissionFunction createFunction(PermissionSubject subject);
public PermissionProvider getProvider() {
return this.provider;
}
PermissionProvider getProvider();
/**
* Sets the {@link PermissionFunction} that should be used for the subject.
@ -55,16 +39,5 @@ public final class PermissionsSetupEvent {
*
* @param provider the provider
*/
public void setProvider(@Nullable PermissionProvider provider) {
this.provider = provider == null ? this.defaultProvider : provider;
}
@Override
public String toString() {
return "PermissionsSetupEvent{"
+ "subject=" + subject
+ ", defaultProvider=" + defaultProvider
+ ", provider=" + provider
+ '}';
}
void setProvider(@Nullable PermissionProvider provider);
}

Datei anzeigen

@ -0,0 +1,74 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.permission;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.permission.PermissionProvider;
import com.velocitypowered.api.permission.PermissionSubject;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Called when a {@link PermissionSubject}'s permissions are being setup.
*
* <p>This event is only called once per subject, on initialisation.</p>
*/
public final class PermissionsSetupEventImpl implements PermissionsSetupEvent {
private final PermissionSubject subject;
private final PermissionProvider defaultProvider;
private PermissionProvider provider;
public PermissionsSetupEventImpl(PermissionSubject subject, PermissionProvider provider) {
this.subject = Preconditions.checkNotNull(subject, "subject");
this.provider = this.defaultProvider = Preconditions.checkNotNull(provider, "provider");
}
@Override
public PermissionSubject getSubject() {
return this.subject;
}
/**
* Uses the provider function to obtain a {@link PermissionFunction} for the subject.
*
* @param subject the subject
* @return the obtained permission function
*/
@Override
public PermissionFunction createFunction(PermissionSubject subject) {
return this.provider.createFunction(subject);
}
@Override
public PermissionProvider getProvider() {
return this.provider;
}
/**
* Sets the {@link PermissionFunction} that should be used for the subject.
*
* <p>Specifying <code>null</code> will reset the provider to the default
* instance given when the event was posted.</p>
*
* @param provider the provider
*/
@Override
public void setProvider(@Nullable PermissionProvider provider) {
this.provider = provider == null ? this.defaultProvider : provider;
}
@Override
public String toString() {
return "PermissionsSetupEvent{"
+ "subject=" + subject
+ ", defaultProvider=" + defaultProvider
+ ", provider=" + provider
+ '}';
}
}

Datei anzeigen

@ -7,38 +7,13 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.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.
*/
public final class DisconnectEvent {
public interface DisconnectEvent {
private final Player player;
private final LoginStatus loginStatus;
Player getPlayer();
public DisconnectEvent(Player player, LoginStatus loginStatus) {
this.player = Preconditions.checkNotNull(player, "player");
this.loginStatus = Preconditions.checkNotNull(loginStatus, "loginStatus");
}
public Player getPlayer() {
return player;
}
public LoginStatus getLoginStatus() {
return loginStatus;
}
@Override
public String toString() {
return "DisconnectEvent{"
+ "player=" + player + ", "
+ "loginStatus=" + loginStatus
+ '}';
}
LoginStatus getLoginStatus();
public enum LoginStatus {

Datei anzeigen

@ -0,0 +1,45 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.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.
*/
public final class DisconnectEventImpl implements DisconnectEvent {
private final Player player;
private final LoginStatus loginStatus;
public DisconnectEventImpl(Player player, LoginStatus loginStatus) {
this.player = Preconditions.checkNotNull(player, "player");
this.loginStatus = Preconditions.checkNotNull(loginStatus, "loginStatus");
}
@Override
public Player getPlayer() {
return player;
}
@Override
public LoginStatus getLoginStatus() {
return loginStatus;
}
@Override
public String toString() {
return "DisconnectEvent{"
+ "player=" + player + ", "
+ "loginStatus=" + loginStatus
+ '}';
}
}

Datei anzeigen

@ -13,7 +13,7 @@ import com.velocitypowered.api.util.GameProfile;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This event is fired after the {@link PreLoginEvent} in
* 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.
*/

Datei anzeigen

@ -13,7 +13,6 @@ import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@ -22,79 +21,38 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* Velocity will notify the user (if they are already connected to a server) or disconnect them
* (if they are not on a server and no other servers are available).
*/
public final class KickedFromServerEvent implements
public interface KickedFromServerEvent extends
ResultedEvent<KickedFromServerEvent.ServerKickResult> {
private final Player player;
private final RegisteredServer server;
private final @Nullable Component originalReason;
private final boolean duringServerConnect;
private ServerKickResult result;
Player getPlayer();
/**
* Creates a {@code KickedFromServerEvent} instance.
* @param player the player affected
* @param server the server the player disconnected from
* @param originalReason the reason for being kicked, optional
* @param duringServerConnect whether or not the player was kicked during the connection process
* @param result the initial result
*/
public KickedFromServerEvent(Player player, RegisteredServer server,
net.kyori.adventure.text.@Nullable Component originalReason,
boolean duringServerConnect, ServerKickResult result) {
this.player = Preconditions.checkNotNull(player, "player");
this.server = Preconditions.checkNotNull(server, "server");
this.originalReason = originalReason;
this.duringServerConnect = duringServerConnect;
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public ServerKickResult getResult() {
return result;
}
@Override
public void setResult(@NonNull ServerKickResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
public Player getPlayer() {
return player;
}
public RegisteredServer getServer() {
return server;
}
RegisteredServer getServer();
/**
* Gets the reason the server kicked the player from the server.
*
* @return the server kicked the player from the server
*/
public Optional<Component> getServerKickReason() {
return Optional.ofNullable(originalReason);
}
Optional<Component> getServerKickReason();
/**
* Returns whether or not the player got kicked while connecting to another server.
*
* @return whether or not the player got kicked
*/
public boolean kickedDuringServerConnect() {
return duringServerConnect;
}
boolean kickedDuringServerConnect();
/**
* Represents the base interface for {@link KickedFromServerEvent} results.
*/
public interface ServerKickResult extends ResultedEvent.Result {
public interface ServerKickResult extends Result {
}
/**
* Tells the proxy to disconnect the player with the specified reason.
*/
public static final class DisconnectPlayer implements ServerKickResult {
final class DisconnectPlayer implements ServerKickResult {
private final Component component;
@ -126,13 +84,13 @@ public final class KickedFromServerEvent implements
* Tells the proxy to redirect the player to another server. No messages will be sent from the
* proxy when this result is used.
*/
public static final class RedirectPlayer implements ServerKickResult {
final class RedirectPlayer implements ServerKickResult {
private final Component message;
private final RegisteredServer server;
private RedirectPlayer(RegisteredServer server,
net.kyori.adventure.text.@Nullable Component message) {
@Nullable Component message) {
this.server = Preconditions.checkNotNull(server, "server");
this.message = message;
}
@ -171,7 +129,7 @@ public final class KickedFromServerEvent implements
* result to use if the player was trying to connect to a different server, otherwise it is
* treated like a {@link DisconnectPlayer} result.
*/
public static final class Notify implements ServerKickResult {
final class Notify implements ServerKickResult {
private final Component message;

Datei anzeigen

@ -0,0 +1,89 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Fired when a player is kicked from a server. You may either allow Velocity to kick the player
* (with an optional reason override) or redirect the player to a separate server. By default,
* Velocity will notify the user (if they are already connected to a server) or disconnect them
* (if they are not on a server and no other servers are available).
*/
public final class KickedFromServerEventImpl implements KickedFromServerEvent {
private final Player player;
private final RegisteredServer server;
private final @Nullable Component originalReason;
private final boolean duringServerConnect;
private ServerKickResult result;
/**
* Creates a {@code KickedFromServerEvent} instance.
* @param player the player affected
* @param server the server the player disconnected from
* @param originalReason the reason for being kicked, optional
* @param duringServerConnect whether or not the player was kicked during the connection process
* @param result the initial result
*/
public KickedFromServerEventImpl(Player player, RegisteredServer server,
net.kyori.adventure.text.@Nullable Component originalReason,
boolean duringServerConnect, ServerKickResult result) {
this.player = Preconditions.checkNotNull(player, "player");
this.server = Preconditions.checkNotNull(server, "server");
this.originalReason = originalReason;
this.duringServerConnect = duringServerConnect;
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public ServerKickResult getResult() {
return result;
}
@Override
public void setResult(@NonNull ServerKickResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public Player getPlayer() {
return player;
}
@Override
public RegisteredServer getServer() {
return server;
}
/**
* Gets the reason the server kicked the player from the server.
* @return the server kicked the player from the server
*/
@Override
public Optional<Component> getServerKickReason() {
return Optional.ofNullable(originalReason);
}
/**
* Returns whether or not the player got kicked while connecting to another server.
*
* @return whether or not the player got kicked
*/
@Override
public boolean kickedDuringServerConnect() {
return duringServerConnect;
}
}

Datei anzeigen

@ -7,7 +7,6 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.proxy.connection.Player;
@ -15,35 +14,13 @@ import com.velocitypowered.api.proxy.connection.Player;
* This event is fired once the player has been authenticated but before they connect to a server on
* the proxy.
*/
public final class LoginEvent implements ResultedEvent<ResultedEvent.ComponentResult> {
public interface LoginEvent extends ResultedEvent<ResultedEvent.ComponentResult> {
private final Player player;
private ComponentResult result;
public LoginEvent(Player player) {
this.player = Preconditions.checkNotNull(player, "player");
this.result = ComponentResult.allowed();
}
public Player getPlayer() {
return player;
}
Player getPlayer();
@Override
public ComponentResult getResult() {
return result;
}
ComponentResult getResult();
@Override
public void setResult(ComponentResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public String toString() {
return "LoginEvent{"
+ "player=" + player
+ ", result=" + result
+ '}';
}
void setResult(ComponentResult result);
}

Datei anzeigen

@ -0,0 +1,49 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
/**
* This event is fired once the player has been authenticated but before they connect to a server on
* the proxy.
*/
public final class LoginEventImpl implements LoginEvent {
private final Player player;
private ComponentResult result;
public LoginEventImpl(Player player) {
this.player = Preconditions.checkNotNull(player, "player");
this.result = ComponentResult.allowed();
}
@Override
public Player getPlayer() {
return player;
}
@Override
public ComponentResult getResult() {
return result;
}
@Override
public void setResult(ComponentResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public String toString() {
return "LoginEvent{"
+ "player=" + player
+ ", result=" + result
+ '}';
}
}

Datei anzeigen

@ -7,7 +7,6 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import java.util.List;
@ -16,29 +15,9 @@ import java.util.List;
* This event is fired when a client ({@link Player}) sends a plugin message through the
* register channel.
*/
public final class PlayerChannelRegisterEvent {
public interface PlayerChannelRegisterEvent {
private final Player player;
private final List<ChannelIdentifier> channels;
Player getPlayer();
public PlayerChannelRegisterEvent(Player player, List<ChannelIdentifier> channels) {
this.player = Preconditions.checkNotNull(player, "player");
this.channels = Preconditions.checkNotNull(channels, "channels");
}
public Player getPlayer() {
return player;
}
public List<ChannelIdentifier> getChannels() {
return channels;
}
@Override
public String toString() {
return "PlayerChannelRegisterEvent{"
+ "player=" + player
+ ", channels=" + channels
+ '}';
}
List<ChannelIdentifier> getChannels();
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import java.util.List;
/**
* This event is fired when a client ({@link Player}) sends a plugin message through the
* register channel.
*/
public final class PlayerChannelRegisterEventImpl implements PlayerChannelRegisterEvent {
private final Player player;
private final List<ChannelIdentifier> channels;
public PlayerChannelRegisterEventImpl(Player player, List<ChannelIdentifier> channels) {
this.player = Preconditions.checkNotNull(player, "player");
this.channels = Preconditions.checkNotNull(channels, "channels");
}
@Override
public Player getPlayer() {
return player;
}
@Override
public List<ChannelIdentifier> getChannels() {
return channels;
}
@Override
public String toString() {
return "PlayerChannelRegisterEvent{"
+ "player=" + player
+ ", channels=" + channels
+ '}';
}
}

Datei anzeigen

@ -14,57 +14,22 @@ import java.util.Optional;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This event is fired when a player types in a chat message.
*/
public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.ChatResult> {
public interface PlayerChatEvent extends ResultedEvent<PlayerChatEvent.ChatResult> {
private final Player player;
private final String message;
private ChatResult result;
Player getPlayer();
/**
* Constructs a PlayerChatEvent.
* @param player the player sending the message
* @param message the message being sent
*/
public PlayerChatEvent(Player player, String message) {
this.player = Preconditions.checkNotNull(player, "player");
this.message = Preconditions.checkNotNull(message, "message");
this.result = ChatResult.allowed();
}
public Player getPlayer() {
return player;
}
public String getMessage() {
return message;
}
String getMessage();
@Override
public ChatResult getResult() {
return result;
}
ChatResult getResult();
@Override
public void setResult(ChatResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public String toString() {
return "PlayerChatEvent{"
+ "player=" + player
+ ", message=" + message
+ ", result=" + result
+ '}';
}
void setResult(ChatResult result);
/**
* Represents the result of the {@link PlayerChatEvent}.
*/
public static final class ChatResult implements ResultedEvent.Result {
final class ChatResult implements Result {
private static final ChatResult ALLOWED = new ChatResult(true, null);
private static final ChatResult DENIED = new ChatResult(false, null);
@ -93,6 +58,7 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
/**
* Allows the message to be sent, without modification.
*
* @return the allowed result
*/
public static ChatResult allowed() {
@ -101,6 +67,7 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
/**
* Prevents the message from being sent.
*
* @return the denied result
*/
public static ChatResult denied() {
@ -109,6 +76,7 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
/**
* Allows the message to be sent, but silently replaced with another.
*
* @param message the message to use instead
* @return a result with a new message
*/

Datei anzeigen

@ -0,0 +1,62 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
/**
* This event is fired when a player types in a chat message.
*/
public final class PlayerChatEventImpl implements PlayerChatEvent {
private final Player player;
private final String message;
private ChatResult result;
/**
* Constructs a PlayerChatEvent.
* @param player the player sending the message
* @param message the message being sent
*/
public PlayerChatEventImpl(Player player, String message) {
this.player = Preconditions.checkNotNull(player, "player");
this.message = Preconditions.checkNotNull(message, "message");
this.result = ChatResult.allowed();
}
@Override
public Player getPlayer() {
return player;
}
@Override
public String getMessage() {
return message;
}
@Override
public ChatResult getResult() {
return result;
}
@Override
public void setResult(ChatResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public String toString() {
return "PlayerChatEvent{"
+ "player=" + player
+ ", message=" + message
+ ", result=" + result
+ '}';
}
}

Datei anzeigen

@ -7,52 +7,24 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
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
* to connect to.
*/
public class PlayerChooseInitialServerEvent {
public interface PlayerChooseInitialServerEvent {
private final Player player;
private @Nullable RegisteredServer initialServer;
Player getPlayer();
/**
* Constructs a PlayerChooseInitialServerEvent.
* @param player the player that was connected
* @param initialServer the initial server selected, may be {@code null}
*/
public PlayerChooseInitialServerEvent(Player player, @Nullable RegisteredServer initialServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.initialServer = initialServer;
}
public Player getPlayer() {
return player;
}
public Optional<RegisteredServer> getInitialServer() {
return Optional.ofNullable(initialServer);
}
Optional<RegisteredServer> getInitialServer();
/**
* Sets the new initial server.
*
* @param server the initial server the player should connect to
*/
public void setInitialServer(RegisteredServer server) {
this.initialServer = server;
}
@Override
public String toString() {
return "PlayerChooseInitialServerEvent{"
+ "player=" + player
+ ", initialServer=" + initialServer
+ '}';
}
void setInitialServer(RegisteredServer server);
}

Datei anzeigen

@ -0,0 +1,61 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
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
* to connect to.
*/
public class PlayerChooseInitialServerEventImpl implements PlayerChooseInitialServerEvent {
private final Player player;
private @Nullable RegisteredServer initialServer;
/**
* Constructs a PlayerChooseInitialServerEvent.
* @param player the player that was connected
* @param initialServer the initial server selected, may be {@code null}
*/
public PlayerChooseInitialServerEventImpl(Player player, @Nullable RegisteredServer initialServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.initialServer = initialServer;
}
@Override
public Player getPlayer() {
return player;
}
@Override
public Optional<RegisteredServer> getInitialServer() {
return Optional.ofNullable(initialServer);
}
/**
* Sets the new initial server.
* @param server the initial server the player should connect to
*/
@Override
public void setInitialServer(RegisteredServer server) {
this.initialServer = server;
}
@Override
public String toString() {
return "PlayerChooseInitialServerEvent{"
+ "player=" + player
+ ", initialServer=" + initialServer
+ '}';
}
}

Datei anzeigen

@ -7,37 +7,16 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.util.ModInfo;
/**
* This event is fired when a Forge client sends its mods to the proxy while connecting to a server.
* This event is fired when a modded client sends its mods to the proxy while connecting to a
* server.
*/
public final class PlayerModInfoEvent {
public interface PlayerModInfoEvent {
private final Player player;
private final ModInfo modInfo;
Player getPlayer();
public PlayerModInfoEvent(Player player, ModInfo modInfo) {
this.player = Preconditions.checkNotNull(player, "player");
this.modInfo = Preconditions.checkNotNull(modInfo, "modInfo");
}
public Player getPlayer() {
return player;
}
public ModInfo getModInfo() {
return modInfo;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("player", player)
.add("modInfo", modInfo)
.toString();
}
ModInfo getModInfo();
}

Datei anzeigen

@ -0,0 +1,42 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.util.ModInfo;
public final class PlayerModInfoEventImpl implements PlayerModInfoEvent {
private final Player player;
private final ModInfo modInfo;
public PlayerModInfoEventImpl(Player player, ModInfo modInfo) {
this.player = Preconditions.checkNotNull(player, "player");
this.modInfo = Preconditions.checkNotNull(modInfo, "modInfo");
}
@Override
public Player getPlayer() {
return player;
}
@Override
public ModInfo getModInfo() {
return modInfo;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("player", player)
.add("modInfo", modInfo)
.toString();
}
}

Datei anzeigen

@ -7,53 +7,32 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
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
* changed.
*/
public class PlayerResourcePackStatusEvent {
private final Player player;
private final Status status;
public PlayerResourcePackStatusEvent(Player player, Status status) {
this.player = Preconditions.checkNotNull(player, "player");
this.status = Preconditions.checkNotNull(status, "status");
}
public interface PlayerResourcePackStatusEvent {
/**
* Returns the player affected by the change in resource pack status.
*
* @return the player
*/
public Player getPlayer() {
return player;
}
Player getPlayer();
/**
* Returns the new status for the resource pack.
*
* @return the new status
*/
public Status getStatus() {
return status;
}
@Override
public String toString() {
return "PlayerResourcePackStatusEvent{"
+ "player=" + player
+ ", status=" + status
+ '}';
}
Status getStatus();
/**
* Represents the possible statuses for the resource pack.
*/
public enum Status {
enum Status {
/**
* The resource pack was applied successfully.
*/

Datei anzeigen

@ -0,0 +1,55 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
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
* changed.
*/
public class PlayerResourcePackStatusEventImpl implements PlayerResourcePackStatusEvent {
private final Player player;
private final Status status;
public PlayerResourcePackStatusEventImpl(Player player, Status status) {
this.player = Preconditions.checkNotNull(player, "player");
this.status = Preconditions.checkNotNull(status, "status");
}
/**
* Returns the player affected by the change in resource pack status.
*
* @return the player
*/
@Override
public Player getPlayer() {
return player;
}
/**
* Returns the new status for the resource pack.
*
* @return the new status
*/
@Override
public Status getStatus() {
return status;
}
@Override
public String toString() {
return "PlayerResourcePackStatusEvent{"
+ "player=" + player
+ ", status=" + status
+ '}';
}
}

Datei anzeigen

@ -7,34 +7,12 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.player.PlayerSettings;
public final class PlayerSettingsChangedEvent {
public interface PlayerSettingsChangedEvent {
private final Player player;
private final PlayerSettings playerSettings;
Player getPlayer();
public PlayerSettingsChangedEvent(Player player, PlayerSettings playerSettings) {
this.player = Preconditions.checkNotNull(player, "player");
this.playerSettings = Preconditions.checkNotNull(playerSettings, "playerSettings");
}
public Player getPlayer() {
return player;
}
public PlayerSettings getPlayerSettings() {
return playerSettings;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("player", player)
.add("playerSettings", playerSettings)
.toString();
}
PlayerSettings getPlayerSettings();
}

Datei anzeigen

@ -0,0 +1,42 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.player.PlayerSettings;
public final class PlayerSettingsChangedEventImpl implements PlayerSettingsChangedEvent {
private final Player player;
private final PlayerSettings playerSettings;
public PlayerSettingsChangedEventImpl(Player player, PlayerSettings playerSettings) {
this.player = Preconditions.checkNotNull(player, "player");
this.playerSettings = Preconditions.checkNotNull(playerSettings, "playerSettings");
}
@Override
public Player getPlayer() {
return player;
}
@Override
public PlayerSettings getPlayerSettings() {
return playerSettings;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("player", player)
.add("playerSettings", playerSettings)
.toString();
}
}

Datei anzeigen

@ -7,29 +7,13 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
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
* first server.
*/
public final class PostLoginEvent {
public interface PostLoginEvent {
private final Player player;
public PostLoginEvent(Player player) {
this.player = Preconditions.checkNotNull(player, "player");
}
public Player getPlayer() {
return player;
}
@Override
public String toString() {
return "PostLoginEvent{"
+ "player=" + player
+ '}';
}
Player getPlayer();
}

Datei anzeigen

@ -0,0 +1,36 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
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
* first server.
*/
public final class PostLoginEventImpl implements PostLoginEvent {
private final Player player;
public PostLoginEventImpl(Player player) {
this.player = Preconditions.checkNotNull(player, "player");
}
@Override
public Player getPlayer() {
return player;
}
@Override
public String toString() {
return "PostLoginEvent{"
+ "player=" + player
+ '}';
}
}

Datei anzeigen

@ -20,55 +20,23 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* authenticates the player with Mojang or before the player's proxy connection is fully established
* (for offline mode).
*/
public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLoginComponentResult> {
public interface PreLoginEvent extends ResultedEvent<PreLoginEvent.PreLoginComponentResult> {
private final InboundConnection connection;
private final String username;
private PreLoginComponentResult result;
InboundConnection getConnection();
/**
* Creates a new instance.
* @param connection the connection logging into the proxy
* @param username the player's username
*/
public PreLoginEvent(InboundConnection connection, String username) {
this.connection = Preconditions.checkNotNull(connection, "connection");
this.username = Preconditions.checkNotNull(username, "username");
this.result = PreLoginComponentResult.allowed();
}
public InboundConnection getConnection() {
return connection;
}
public String getUsername() {
return username;
}
String getUsername();
@Override
public PreLoginComponentResult getResult() {
return result;
}
PreLoginComponentResult getResult();
@Override
public void setResult(@NonNull PreLoginComponentResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public String toString() {
return "PreLoginEvent{"
+ "connection=" + connection
+ ", username='" + username + '\''
+ ", result=" + result
+ '}';
}
void setResult(@NonNull PreLoginComponentResult result);
/**
* Represents an "allowed/allowed with forced online\offline mode/denied" result with a reason
* allowed for denial.
*/
public static final class PreLoginComponentResult implements ResultedEvent.Result {
final class PreLoginComponentResult implements Result {
private static final PreLoginComponentResult ALLOWED = new PreLoginComponentResult(
Result.ALLOWED, null);

Datei anzeigen

@ -0,0 +1,65 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.InboundConnection;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* This event is fired when a player has initiated a connection with the proxy but before the proxy
* authenticates the player with Mojang or before the player's proxy connection is fully established
* (for offline mode).
*/
public final class PreLoginEventImpl implements PreLoginEvent {
private final InboundConnection connection;
private final String username;
private PreLoginComponentResult result;
/**
* Creates a new instance.
* @param connection the connection logging into the proxy
* @param username the player's username
*/
public PreLoginEventImpl(InboundConnection connection, String username) {
this.connection = Preconditions.checkNotNull(connection, "connection");
this.username = Preconditions.checkNotNull(username, "username");
this.result = PreLoginComponentResult.allowed();
}
@Override
public InboundConnection getConnection() {
return connection;
}
@Override
public String getUsername() {
return username;
}
@Override
public PreLoginComponentResult getResult() {
return result;
}
@Override
public void setResult(@NonNull PreLoginComponentResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
@Override
public String toString() {
return "PreLoginEvent{"
+ "connection=" + connection
+ ", username='" + username + '\''
+ ", result=" + result
+ '}';
}
}

Datei anzeigen

@ -7,53 +7,19 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* 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.
*/
public final class ServerConnectedEvent {
public interface ServerConnectedEvent {
private final Player player;
private final RegisteredServer server;
private final @Nullable RegisteredServer previousServer;
Player getPlayer();
/**
* Constructs a ServerConnectedEvent.
* @param player the player that was connected
* @param server the server the player was connected to
* @param previousServer the server the player was previously connected to, null if none
*/
public ServerConnectedEvent(Player player, RegisteredServer server,
@Nullable RegisteredServer previousServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.server = Preconditions.checkNotNull(server, "server");
this.previousServer = previousServer;
}
RegisteredServer getServer();
public Player getPlayer() {
return player;
}
public RegisteredServer getServer() {
return server;
}
public Optional<RegisteredServer> getPreviousServer() {
return Optional.ofNullable(previousServer);
}
@Override
public String toString() {
return "ServerConnectedEvent{"
+ "player=" + player
+ ", server=" + server
+ ", previousServer=" + previousServer
+ '}';
}
Optional<RegisteredServer> getPreviousServer();
}

Datei anzeigen

@ -0,0 +1,62 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* 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.
*/
public final class ServerConnectedEventImpl implements ServerConnectedEvent {
private final Player player;
private final RegisteredServer server;
private final @Nullable RegisteredServer previousServer;
/**
* Constructs a ServerConnectedEvent.
* @param player the player that was connected
* @param server the server the player was connected to
* @param previousServer the server the player was previously connected to, null if none
*/
public ServerConnectedEventImpl(Player player, RegisteredServer server,
@Nullable RegisteredServer previousServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.server = Preconditions.checkNotNull(server, "server");
this.previousServer = previousServer;
}
@Override
public Player getPlayer() {
return player;
}
@Override
public RegisteredServer getServer() {
return server;
}
@Override
public Optional<RegisteredServer> getPreviousServer() {
return Optional.ofNullable(previousServer);
}
@Override
public String toString() {
return "ServerConnectedEvent{"
+ "player=" + player
+ ", server=" + server
+ ", previousServer=" + previousServer
+ '}';
}
}

Datei anzeigen

@ -7,8 +7,6 @@
package com.velocitypowered.api.event.player;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -17,30 +15,9 @@ 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
* available in {@link Player#getCurrentServer()}.
*/
@Beta
public class ServerPostConnectEvent {
private final Player player;
private final RegisteredServer previousServer;
public interface ServerPostConnectEvent {
public ServerPostConnectEvent(Player player,
@Nullable RegisteredServer previousServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.previousServer = previousServer;
}
Player getPlayer();
public Player getPlayer() {
return player;
}
public @Nullable RegisteredServer getPreviousServer() {
return previousServer;
}
@Override
public String toString() {
return "ServerPostConnectEvent{"
+ "player=" + player
+ ", previousServer=" + previousServer
+ '}';
}
@Nullable RegisteredServer getPreviousServer();
}

Datei anzeigen

@ -0,0 +1,47 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
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
* available in {@link Player#getCurrentServer()}.
*/
public class ServerPostConnectEventImpl implements ServerPostConnectEvent {
private final Player player;
private final RegisteredServer previousServer;
public ServerPostConnectEventImpl(Player player,
@Nullable RegisteredServer previousServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.previousServer = previousServer;
}
@Override
public Player getPlayer() {
return player;
}
@Override
public @Nullable RegisteredServer getPreviousServer() {
return previousServer;
}
@Override
public String toString() {
return "ServerPostConnectEvent{"
+ "player=" + player
+ ", previousServer=" + previousServer
+ '}';
}
}

Datei anzeigen

@ -19,65 +19,34 @@ import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This event is fired before the player connects to a server.
*/
public final class ServerPreConnectEvent implements
ResultedEvent<ServerPreConnectEvent.ServerResult> {
private final Player player;
private final RegisteredServer originalServer;
private ServerResult result;
/**
* Creates the ServerPreConnectEvent.
* @param player the player who is connecting to a server
* @param originalServer the server the player was trying to connect to
*/
public ServerPreConnectEvent(Player player, RegisteredServer originalServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.originalServer = Preconditions.checkNotNull(originalServer, "originalServer");
this.result = ServerResult.allowed(originalServer);
}
public interface ServerPreConnectEvent extends ResultedEvent<ServerPreConnectEvent.ServerResult> {
/**
* Returns the player connecting to the server.
*
* @return the player connecting to the server
*/
public Player getPlayer() {
return player;
}
Player getPlayer();
@Override
public ServerResult getResult() {
return result;
}
ServerResult getResult();
@Override
public void setResult(ServerResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
void setResult(ServerResult result);
/**
* Returns the server that the player originally tried to connect to. To get the server the
* player will connect to, see the {@link ServerResult} of this event. To get the server the
* player is currently on when this event is fired, use {@link Player#getCurrentServer()}.
* Returns the server that the player originally tried to connect to. To get the server the player
* will connect to, see the {@link ServerResult} of this event. To get the server the player is
* currently on when this event is fired, use {@link Player#getCurrentServer()}.
*
* @return the server that the player originally tried to connect to
*/
public RegisteredServer getOriginalServer() {
return originalServer;
}
@Override
public String toString() {
return "ServerPreConnectEvent{"
+ "player=" + player
+ ", originalServer=" + originalServer
+ ", result=" + result
+ '}';
}
RegisteredServer getOriginalServer();
/**
* Represents the result of the {@link ServerPreConnectEvent}.
*/
public static class ServerResult implements ResultedEvent.Result {
class ServerResult implements Result {
private static final ServerResult DENIED = new ServerResult(null);
@ -106,8 +75,9 @@ public final class ServerPreConnectEvent implements
/**
* Returns a result that will prevent players from connecting to another server. If this result
* is used, then {@link ConnectionRequestBuilder#connect()}'s result will have the status
* {@link Status#CONNECTION_CANCELLED}.
* is used, then {@link ConnectionRequestBuilder#connect()}'s result will have the status {@link
* Status#CONNECTION_CANCELLED}.
*
* @return a result to deny conneections
*/
public static ServerResult denied() {
@ -116,6 +86,7 @@ public final class ServerPreConnectEvent implements
/**
* Allows the player to connect to the specified server.
*
* @param server the new server to connect to
* @return a result to allow the player to connect to the specified server
*/

Datei anzeigen

@ -0,0 +1,73 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.connection.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
/**
* This event is fired before the player connects to a server.
*/
public final class ServerPreConnectEventImpl implements ServerPreConnectEvent {
private final Player player;
private final RegisteredServer originalServer;
private ServerResult result;
/**
* Creates the ServerPreConnectEvent.
* @param player the player who is connecting to a server
* @param originalServer the server the player was trying to connect to
*/
public ServerPreConnectEventImpl(Player player, RegisteredServer originalServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.originalServer = Preconditions.checkNotNull(originalServer, "originalServer");
this.result = ServerResult.allowed(originalServer);
}
/**
* Returns the player connecting to the server.
* @return the player connecting to the server
*/
@Override
public Player getPlayer() {
return player;
}
@Override
public ServerResult getResult() {
return result;
}
@Override
public void setResult(ServerResult result) {
this.result = Preconditions.checkNotNull(result, "result");
}
/**
* Returns the server that the player originally tried to connect to. To get the server the
* player will connect to, see the {@link ServerResult} of this event. To get the server the
* player is currently on when this event is fired, use {@link Player#getCurrentServer()}.
* @return the server that the player originally tried to connect to
*/
@Override
public RegisteredServer getOriginalServer() {
return originalServer;
}
@Override
public String toString() {
return "ServerPreConnectEvent{"
+ "player=" + player
+ ", originalServer=" + originalServer
+ ", result=" + result
+ '}';
}
}

Datei anzeigen

@ -7,63 +7,33 @@
package com.velocitypowered.api.event.player;
import static com.google.common.base.Preconditions.checkNotNull;
import com.velocitypowered.api.proxy.connection.Player;
import java.util.ArrayList;
import java.util.List;
/**
* 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.
*/
public class TabCompleteEvent {
private final Player player;
private final String partialMessage;
private final List<String> suggestions;
/**
* Constructs a new TabCompleteEvent instance.
* @param player the player
* @param partialMessage the partial message
* @param suggestions the initial list of suggestions
*/
public TabCompleteEvent(Player player, String partialMessage, List<String> suggestions) {
this.player = checkNotNull(player, "player");
this.partialMessage = checkNotNull(partialMessage, "partialMessage");
this.suggestions = new ArrayList<>(checkNotNull(suggestions, "suggestions"));
}
public interface TabCompleteEvent {
/**
* Returns the player requesting the tab completion.
*
* @return the requesting player
*/
public Player getPlayer() {
return player;
}
Player getPlayer();
/**
* Returns the message being partially completed.
*
* @return the partial message
*/
public String getPartialMessage() {
return partialMessage;
}
String getPartialMessage();
/**
* Returns all the suggestions provided to the user, as a mutable list.
*
* @return the suggestions
*/
public List<String> getSuggestions() {
return suggestions;
}
@Override
public String toString() {
return "TabCompleteEvent{"
+ "player=" + player
+ ", partialMessage='" + partialMessage + '\''
+ ", suggestions=" + suggestions
+ '}';
}
List<String> getSuggestions();
}

Datei anzeigen

@ -0,0 +1,72 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import static com.google.common.base.Preconditions.checkNotNull;
import com.velocitypowered.api.proxy.connection.Player;
import java.util.ArrayList;
import java.util.List;
/**
* 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.
*/
public class TabCompleteEventImpl implements TabCompleteEvent {
private final Player player;
private final String partialMessage;
private final List<String> suggestions;
/**
* Constructs a new TabCompleteEvent instance.
* @param player the player
* @param partialMessage the partial message
* @param suggestions the initial list of suggestions
*/
public TabCompleteEventImpl(Player player, String partialMessage, List<String> suggestions) {
this.player = checkNotNull(player, "player");
this.partialMessage = checkNotNull(partialMessage, "partialMessage");
this.suggestions = new ArrayList<>(checkNotNull(suggestions, "suggestions"));
}
/**
* Returns the player requesting the tab completion.
* @return the requesting player
*/
@Override
public Player getPlayer() {
return player;
}
/**
* Returns the message being partially completed.
* @return the partial message
*/
@Override
public String getPartialMessage() {
return partialMessage;
}
/**
* Returns all the suggestions provided to the user, as a mutable list.
* @return the suggestions
*/
@Override
public List<String> getSuggestions() {
return suggestions;
}
@Override
public String toString() {
return "TabCompleteEvent{"
+ "player=" + player
+ ", partialMessage='" + partialMessage + '\''
+ ", suggestions=" + suggestions
+ '}';
}
}

Datei anzeigen

@ -8,7 +8,7 @@
package com.velocitypowered.api.proxy.connection;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEventImpl;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
import com.velocitypowered.api.proxy.player.ConnectionRequestBuilder;
@ -123,7 +123,7 @@ public interface Player extends CommandSource, Identified, InboundConnection,
/**
* Sends the specified resource pack from {@code url} to the user. If at all possible, send the
* resource pack using {@link #sendResourcePack(String, byte[])}. To monitor the status of the
* sent resource pack, subscribe to {@link PlayerResourcePackStatusEvent}.
* sent resource pack, subscribe to {@link PlayerResourcePackStatusEventImpl}.
*
* @param url the URL for the resource pack
*/
@ -132,7 +132,7 @@ public interface Player extends CommandSource, Identified, InboundConnection,
/**
* Sends the specified resource pack from {@code url} to the user, using the specified 20-byte
* SHA-1 hash. To monitor the status of the sent resource pack, subscribe to
* {@link PlayerResourcePackStatusEvent}.
* {@link PlayerResourcePackStatusEventImpl}.
*
* @param url the URL for the resource pack
* @param hash the SHA-1 hash value for the resource pack

Datei anzeigen

@ -23,9 +23,9 @@ import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.velocitypowered.api.event.EventManager;
import com.velocitypowered.api.event.lifecycle.ProxyInitializeEvent;
import com.velocitypowered.api.event.lifecycle.ProxyReloadEvent;
import com.velocitypowered.api.event.lifecycle.ProxyShutdownEvent;
import com.velocitypowered.api.event.lifecycle.ProxyInitializeEventImpl;
import com.velocitypowered.api.event.lifecycle.ProxyReloadEventImpl;
import com.velocitypowered.api.event.lifecycle.ProxyShutdownEventImpl;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.PluginManager;
@ -214,7 +214,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
// Go ahead and fire the proxy initialization event. We block since plugins should have a chance
// to fully initialize before we accept any connections to the server.
eventManager.fire(new ProxyInitializeEvent()).join();
eventManager.fire(new ProxyInitializeEventImpl()).join();
// init console permissions after plugins are loaded
console.setupPermissions();
@ -390,7 +390,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
ipAttemptLimiter = Ratelimiters.createWithMilliseconds(newConfiguration.getLoginRatelimit());
this.configuration = newConfiguration;
eventManager.fireAndForget(new ProxyReloadEvent());
eventManager.fireAndForget(new ProxyReloadEventImpl());
return true;
}
@ -441,7 +441,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
}
try {
eventManager.fire(new ProxyShutdownEvent()).get(10, TimeUnit.SECONDS);
eventManager.fire(new ProxyShutdownEventImpl()).get(10, TimeUnit.SECONDS);
} catch (TimeoutException e) {
timedOut = true;
} catch (ExecutionException e) {

Datei anzeigen

@ -34,6 +34,7 @@ import com.velocitypowered.api.command.RawCommand;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.event.command.CommandExecuteEvent;
import com.velocitypowered.api.event.command.CommandExecuteEvent.CommandResult;
import com.velocitypowered.api.event.command.CommandExecuteEventImpl;
import com.velocitypowered.proxy.event.VelocityEventManager;
import com.velocitypowered.proxy.util.BrigadierUtils;
import java.util.Iterator;
@ -117,7 +118,7 @@ public class VelocityCommandManager implements CommandManager {
}
/**
* Fires a {@link CommandExecuteEvent}.
* Fires a {@link CommandExecuteEventImpl}.
*
* @param source the source to execute the command for
* @param cmdLine the command to execute
@ -127,7 +128,7 @@ public class VelocityCommandManager implements CommandManager {
final String cmdLine) {
Preconditions.checkNotNull(source, "source");
Preconditions.checkNotNull(cmdLine, "cmdLine");
return eventManager.fire(new CommandExecuteEvent(source, cmdLine));
return eventManager.fire(new CommandExecuteEventImpl(source, cmdLine));
}
private boolean executeImmediately0(final CommandSource source, final String cmdLine) {

Datei anzeigen

@ -24,7 +24,7 @@ import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.RootCommandNode;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEventImpl;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
@ -214,7 +214,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
}
server.getEventManager().fire(
new PlayerAvailableCommandsEvent(serverConn.getPlayer(), rootNode))
new PlayerAvailableCommandsEventImpl(serverConn.getPlayer(), rootNode))
.thenAcceptAsync(event -> playerConnection.write(commands), playerConnection.eventLoop())
.exceptionally((ex) -> {
logger.error("Exception while handling available commands for {}", playerConnection, ex);

Datei anzeigen

@ -20,8 +20,8 @@ package com.velocitypowered.proxy.connection.backend;
import static com.velocitypowered.proxy.connection.backend.BackendConnectionPhases.IN_TRANSITION;
import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase.HELLO;
import com.velocitypowered.api.event.player.ServerConnectedEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.event.player.ServerConnectedEventImpl;
import com.velocitypowered.api.event.player.ServerPostConnectEventImpl;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.ConnectionTypes;
import com.velocitypowered.proxy.connection.MinecraftConnection;
@ -101,7 +101,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
// The goods are in hand! We got JoinGame. Let's transition completely to the new state.
smc.setAutoReading(false);
server.getEventManager()
.fire(new ServerConnectedEvent(player, serverConn.getServer(),
.fire(new ServerConnectedEventImpl(player, serverConn.getServer(),
existingConnection != null ? existingConnection.getServer() : null))
.thenRunAsync(() -> {
// Make sure we can still transition (player might have disconnected here).
@ -132,7 +132,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
serverConn.getPlayer().setConnectedServer(serverConn);
// We're done! :)
server.getEventManager().fireAndForget(new ServerPostConnectEvent(player,
server.getEventManager().fireAndForget(new ServerPostConnectEventImpl(player,
existingConnection == null ? null : existingConnection.getServer()));
resultFuture.complete(ConnectionRequestResults.successful(serverConn.getServer()));
}, smc.eventLoop())

Datei anzeigen

@ -25,10 +25,11 @@ import static com.velocitypowered.proxy.network.PluginMessageUtil.constructChann
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.event.command.CommandExecuteEvent.CommandResult;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.player.PlayerChannelRegisterEvent;
import com.velocitypowered.api.event.player.PlayerChannelRegisterEventImpl;
import com.velocitypowered.api.event.player.PlayerChatEvent;
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
import com.velocitypowered.api.event.player.TabCompleteEvent;
import com.velocitypowered.api.event.player.PlayerChatEventImpl;
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEventImpl;
import com.velocitypowered.api.event.player.TabCompleteEventImpl;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
@ -173,10 +174,10 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
return null;
});
} else {
PlayerChatEvent event = new PlayerChatEvent(player, msg);
PlayerChatEvent event = new PlayerChatEventImpl(player, msg);
server.getEventManager().fire(event)
.thenAcceptAsync(pme -> {
PlayerChatEvent.ChatResult chatResult = pme.getResult();
PlayerChatEventImpl.ChatResult chatResult = pme.getResult();
if (chatResult.isAllowed()) {
Optional<String> eventMsg = pme.getResult().getMessage();
if (eventMsg.isPresent()) {
@ -224,7 +225,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
channelIdentifiers.add(new LegacyChannelIdentifier(channel));
}
}
server.getEventManager().fireAndForget(new PlayerChannelRegisterEvent(player,
server.getEventManager().fireAndForget(new PlayerChannelRegisterEventImpl(player,
ImmutableList.copyOf(channelIdentifiers)));
backendConn.write(packet.retain());
} else if (PluginMessageUtil.isUnregister(packet)) {
@ -286,7 +287,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
@Override
public boolean handle(ServerboundResourcePackResponsePacket packet) {
server.getEventManager().fireAndForget(new PlayerResourcePackStatusEvent(player,
server.getEventManager().fireAndForget(new PlayerResourcePackStatusEventImpl(player,
packet.getStatus()));
return false;
}
@ -576,7 +577,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
for (Offer offer : response.getOffers()) {
offers.add(offer.getText());
}
server.getEventManager().fire(new TabCompleteEvent(player, request.getCommand(), offers))
server.getEventManager().fire(new TabCompleteEventImpl(player, request.getCommand(), offers))
.thenAcceptAsync(e -> {
response.getOffers().clear();
for (String s : e.getSuggestions()) {

Datei anzeigen

@ -25,14 +25,17 @@ import com.google.common.base.Preconditions;
import com.google.gson.JsonObject;
import com.velocitypowered.api.event.player.DisconnectEvent;
import com.velocitypowered.api.event.player.DisconnectEvent.LoginStatus;
import com.velocitypowered.api.event.player.DisconnectEventImpl;
import com.velocitypowered.api.event.player.KickedFromServerEvent;
import com.velocitypowered.api.event.player.KickedFromServerEvent.DisconnectPlayer;
import com.velocitypowered.api.event.player.KickedFromServerEvent.Notify;
import com.velocitypowered.api.event.player.KickedFromServerEvent.RedirectPlayer;
import com.velocitypowered.api.event.player.KickedFromServerEvent.ServerKickResult;
import com.velocitypowered.api.event.player.PlayerModInfoEvent;
import com.velocitypowered.api.event.player.PlayerSettingsChangedEvent;
import com.velocitypowered.api.event.player.KickedFromServerEventImpl;
import com.velocitypowered.api.event.player.PlayerModInfoEventImpl;
import com.velocitypowered.api.event.player.PlayerSettingsChangedEventImpl;
import com.velocitypowered.api.event.player.ServerPreConnectEvent;
import com.velocitypowered.api.event.player.ServerPreConnectEventImpl;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.permission.PermissionProvider;
@ -59,7 +62,6 @@ import com.velocitypowered.proxy.network.StateRegistry;
import com.velocitypowered.proxy.network.packet.AbstractPluginMessagePacket;
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundChatPacket;
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundHeaderAndFooterPacket;
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundKeepAlivePacket;
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPluginMessagePacket;
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundResourcePackRequestPacket;
@ -212,7 +214,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
void setPlayerSettings(ServerboundClientSettingsPacket settings) {
ClientSettingsWrapper cs = new ClientSettingsWrapper(settings);
this.settings = cs;
server.getEventManager().fireAndForget(new PlayerSettingsChangedEvent(this, cs));
server.getEventManager().fireAndForget(new PlayerSettingsChangedEventImpl(this, cs));
}
@Override
@ -222,7 +224,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
public void setModInfo(ModInfo modInfo) {
this.modInfo = modInfo;
server.getEventManager().fireAndForget(new PlayerModInfoEvent(this, modInfo));
server.getEventManager().fireAndForget(new PlayerModInfoEventImpl(this, modInfo));
}
@Override
@ -505,7 +507,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
}
result = Notify.create(friendlyReason);
}
KickedFromServerEvent originalEvent = new KickedFromServerEvent(this, rs, kickReason,
KickedFromServerEvent originalEvent = new KickedFromServerEventImpl(this, rs, kickReason,
!kickedFromCurrent, result);
handleKickEvent(originalEvent, friendlyReason, kickedFromCurrent);
}
@ -669,7 +671,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
Optional<Player> connectedPlayer = server.getPlayer(this.getUniqueId());
server.unregisterConnection(this);
DisconnectEvent.LoginStatus status;
DisconnectEventImpl.LoginStatus status;
if (connectedPlayer.isPresent()) {
if (!connectedPlayer.get().getCurrentServer().isPresent()) {
status = LoginStatus.PRE_SERVER_JOIN;
@ -682,7 +684,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
LoginStatus.CANCELLED_BY_USER;
}
DisconnectEvent event = new DisconnectEvent(this, status);
DisconnectEvent event = new DisconnectEventImpl(this, status);
server.getEventManager().fire(event).whenComplete((val, ex) -> {
if (ex == null) {
this.teardownFuture.complete(null);
@ -852,7 +854,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
return completedFuture(plainResult(initialCheck.get(), toConnect));
}
ServerPreConnectEvent event = new ServerPreConnectEvent(ConnectedPlayer.this,
ServerPreConnectEvent event = new ServerPreConnectEventImpl(ConnectedPlayer.this,
toConnect);
return server.getEventManager().fire(event)
.thenComposeAsync(newEvent -> {

Datei anzeigen

@ -19,7 +19,7 @@ package com.velocitypowered.proxy.connection.client;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.connection.ConnectionHandshakeEvent;
import com.velocitypowered.api.event.connection.ConnectionHandshakeEventImpl;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.connection.InboundConnection;
import com.velocitypowered.proxy.VelocityServer;
@ -136,7 +136,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
return;
}
server.getEventManager().fireAndForget(new ConnectionHandshakeEvent(ic));
server.getEventManager().fireAndForget(new ConnectionHandshakeEventImpl(ic));
connection.setSessionHandler(new LoginSessionHandler(server, connection, ic));
}

Datei anzeigen

@ -25,15 +25,17 @@ import static com.velocitypowered.proxy.util.EncryptionUtils.decryptRsa;
import static com.velocitypowered.proxy.util.EncryptionUtils.generateServerId;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.permission.PermissionsSetupEvent;
import com.velocitypowered.api.event.player.DisconnectEvent;
import com.velocitypowered.api.event.permission.PermissionsSetupEventImpl;
import com.velocitypowered.api.event.player.DisconnectEvent.LoginStatus;
import com.velocitypowered.api.event.player.DisconnectEventImpl;
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
import com.velocitypowered.api.event.player.LoginEvent;
import com.velocitypowered.api.event.player.LoginEventImpl;
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent;
import com.velocitypowered.api.event.player.PostLoginEvent;
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEventImpl;
import com.velocitypowered.api.event.player.PostLoginEventImpl;
import com.velocitypowered.api.event.player.PreLoginEvent;
import com.velocitypowered.api.event.player.PreLoginEvent.PreLoginComponentResult;
import com.velocitypowered.api.event.player.PreLoginEventImpl;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.util.GameProfile;
@ -176,7 +178,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
if (login == null) {
throw new IllegalStateException("No ServerLogin packet received yet.");
}
PreLoginEvent event = new PreLoginEvent(inbound, login.getUsername());
PreLoginEvent event = new PreLoginEventImpl(inbound, login.getUsername());
server.getEventManager().fire(event)
.thenRunAsync(() -> {
if (mcConnection.isClosed()) {
@ -245,7 +247,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
logger.info("{} has connected", player);
return server.getEventManager()
.fire(new PermissionsSetupEvent(player, ConnectedPlayer.DEFAULT_PERMISSIONS))
.fire(new PermissionsSetupEventImpl(player, ConnectedPlayer.DEFAULT_PERMISSIONS))
.thenAcceptAsync(event -> {
if (!mcConnection.isClosed()) {
// wait for permissions to load, then set the players permission function
@ -285,11 +287,11 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
mcConnection.setAssociation(player);
mcConnection.setState(StateRegistry.PLAY);
server.getEventManager().fire(new LoginEvent(player))
server.getEventManager().fire(new LoginEventImpl(player))
.thenAcceptAsync(event -> {
if (mcConnection.isClosed()) {
// The player was disconnected
server.getEventManager().fireAndForget(new DisconnectEvent(player,
server.getEventManager().fireAndForget(new DisconnectEventImpl(player,
LoginStatus.CANCELLED_BY_USER_BEFORE_COMPLETE));
return;
}
@ -305,7 +307,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
}
mcConnection.setSessionHandler(new InitialConnectSessionHandler(player));
server.getEventManager().fire(new PostLoginEvent(player))
server.getEventManager().fire(new PostLoginEventImpl(player))
.thenCompose((ignored) -> connectToInitialServer(player))
.exceptionally((ex) -> {
logger.error("Exception while connecting {} to initial server", player, ex);
@ -321,7 +323,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
private CompletableFuture<Void> connectToInitialServer(ConnectedPlayer player) {
Optional<RegisteredServer> initialFromConfig = player.getNextServerToTry();
PlayerChooseInitialServerEvent event = new PlayerChooseInitialServerEvent(player,
PlayerChooseInitialServerEvent event = new PlayerChooseInitialServerEventImpl(player,
initialFromConfig.orElse(null));
return server.getEventManager().fire(event)

Datei anzeigen

@ -19,7 +19,7 @@ package com.velocitypowered.proxy.connection.client;
import com.google.common.collect.ImmutableList;
import com.spotify.futures.CompletableFutures;
import com.velocitypowered.api.event.connection.ProxyPingEvent;
import com.velocitypowered.api.event.connection.ProxyPingEventImpl;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.connection.InboundConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
@ -182,7 +182,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
}
this.pingReceived = true;
getInitialPing()
.thenCompose(ping -> server.getEventManager().fire(new ProxyPingEvent(inbound, ping)))
.thenCompose(ping -> server.getEventManager().fire(new ProxyPingEventImpl(inbound, ping)))
.thenAcceptAsync(event -> connection.closeWith(
LegacyDisconnectPacket.fromServerPing(event.getPing(), packet.getVersion())),
connection.eventLoop())
@ -207,7 +207,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
this.pingReceived = true;
getInitialPing()
.thenCompose(ping -> server.getEventManager().fire(new ProxyPingEvent(inbound, ping)))
.thenCompose(ping -> server.getEventManager().fire(new ProxyPingEventImpl(inbound, ping)))
.thenAcceptAsync(
(event) -> {
StringBuilder json = new StringBuilder();

Datei anzeigen

@ -21,6 +21,7 @@ import static com.velocitypowered.api.permission.PermissionFunction.ALWAYS_TRUE;
import com.velocitypowered.api.command.ConsoleCommandSource;
import com.velocitypowered.api.event.permission.PermissionsSetupEvent;
import com.velocitypowered.api.event.permission.PermissionsSetupEventImpl;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.permission.Tristate;
import com.velocitypowered.proxy.VelocityServer;
@ -72,7 +73,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
* Sets up permissions for the console.
*/
public void setupPermissions() {
PermissionsSetupEvent event = new PermissionsSetupEvent(this, s -> ALWAYS_TRUE);
PermissionsSetupEvent event = new PermissionsSetupEventImpl(this, s -> ALWAYS_TRUE);
// we can safely block here, this is before any listeners fire
this.permissionFunction = this.server.getEventManager().fire(event).join().createFunction(this);
if (this.permissionFunction == null) {

Datei anzeigen

@ -21,8 +21,8 @@ import static org.asynchttpclient.Dsl.asyncHttpClient;
import static org.asynchttpclient.Dsl.config;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.lifecycle.network.ListenerBoundEvent;
import com.velocitypowered.api.event.lifecycle.network.ListenerClosedEvent;
import com.velocitypowered.api.event.lifecycle.network.ListenerBoundEventImpl;
import com.velocitypowered.api.event.lifecycle.network.ListenerClosedEventImpl;
import com.velocitypowered.api.network.ListenerType;
import com.velocitypowered.natives.util.Natives;
import com.velocitypowered.proxy.VelocityServer;
@ -136,7 +136,7 @@ public final class ConnectionManager {
// Fire the proxy bound event after the socket is bound
server.getEventManager().fireAndForget(
new ListenerBoundEvent(address, ListenerType.MINECRAFT));
new ListenerBoundEventImpl(address, ListenerType.MINECRAFT));
} else {
LOGGER.error("Can't bind to {}", address, future.cause());
}
@ -165,7 +165,7 @@ public final class ConnectionManager {
// Fire the proxy bound event after the socket is bound
server.getEventManager().fireAndForget(
new ListenerBoundEvent(address, ListenerType.QUERY));
new ListenerBoundEventImpl(address, ListenerType.QUERY));
} else {
LOGGER.error("Can't bind to {}", bootstrap.config().localAddress(), future.cause());
}
@ -203,7 +203,7 @@ public final class ConnectionManager {
// Fire proxy close event to notify plugins of socket close. We block since plugins
// should have a chance to be notified before the server stops accepting connections.
server.getEventManager().fire(new ListenerClosedEvent(oldBind, endpoint.getType())).join();
server.getEventManager().fire(new ListenerClosedEventImpl(oldBind, endpoint.getType())).join();
Channel serverChannel = endpoint.getChannel();
@ -222,7 +222,7 @@ public final class ConnectionManager {
// Fire proxy close event to notify plugins of socket close. We block since plugins
// should have a chance to be notified before the server stops accepting connections.
server.getEventManager().fire(new ListenerClosedEvent(address, endpoint.getType())).join();
server.getEventManager().fire(new ListenerClosedEventImpl(address, endpoint.getType())).join();
try {
LOGGER.info("Closing endpoint {}", address);

Datei anzeigen

@ -23,7 +23,7 @@ import static com.velocitypowered.api.event.connection.ProxyQueryEvent.QueryType
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableSet;
import com.velocitypowered.api.event.connection.ProxyQueryEvent;
import com.velocitypowered.api.event.connection.ProxyQueryEventImpl;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.PluginDescription;
@ -151,7 +151,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
// Call event and write response
server.getEventManager()
.fire(new ProxyQueryEvent(isBasic ? BASIC : FULL, senderAddress, response))
.fire(new ProxyQueryEventImpl(isBasic ? BASIC : FULL, senderAddress, response))
.whenCompleteAsync((event, exc) -> {
// Packet header
ByteBuf queryResponse = ctx.alloc().buffer();