mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 14:37:43 +01:00
[Breaking] Many renamings in the API
The get prefix has been dropped from getters where it is unambiguous what is being referred to. Other getters have also received renames to clarify their purpose. The main exception is the ProxyConfig API, but it's one of my personal sore spots in the API, so it'll be replaced instead.
This commit is contained in:
@@ -21,7 +21,7 @@ public interface CommandMeta {
|
||||
*
|
||||
* @return the command aliases
|
||||
*/
|
||||
Collection<String> getAliases();
|
||||
Collection<String> aliases();
|
||||
|
||||
/**
|
||||
* Returns a collection containing command nodes that provide additional
|
||||
@@ -30,7 +30,7 @@ public interface CommandMeta {
|
||||
*
|
||||
* @return the hinting command nodes
|
||||
*/
|
||||
Collection<CommandNode<CommandSource>> getHints();
|
||||
Collection<CommandNode<CommandSource>> hints();
|
||||
|
||||
/**
|
||||
* Provides a fluent interface to create {@link CommandMeta}s.
|
||||
|
||||
@@ -18,12 +18,5 @@ public interface RawCommand extends InvocableCommand<RawCommand.Invocation> {
|
||||
* Contains the invocation data for a raw command.
|
||||
*/
|
||||
interface Invocation extends CommandInvocation<String> {
|
||||
|
||||
/**
|
||||
* Returns the used alias to execute the command.
|
||||
*
|
||||
* @return the used command alias
|
||||
*/
|
||||
String alias();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,5 @@ public interface SimpleCommand extends InvocableCommand<SimpleCommand.Invocation
|
||||
* Contains the invocation data for a simple command.
|
||||
*/
|
||||
interface Invocation extends CommandInvocation<String @NonNull []> {
|
||||
|
||||
/**
|
||||
* Returns the used alias to execute the command.
|
||||
*
|
||||
* @return the used command alias
|
||||
*/
|
||||
String alias();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
||||
*
|
||||
* @return the result of this event
|
||||
*/
|
||||
R getResult();
|
||||
R result();
|
||||
|
||||
/**
|
||||
* Sets the result of this event. The result must be non-null.
|
||||
@@ -99,7 +99,7 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Optional<Component> getReason() {
|
||||
public Optional<Component> reason() {
|
||||
return Optional.ofNullable(reason);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,12 @@ public @interface Subscribe {
|
||||
short order() default PostOrder.NORMAL;
|
||||
|
||||
/**
|
||||
* Whether the handler is required to be called asynchronously.
|
||||
* Whether the handler must be called asynchronously.
|
||||
*
|
||||
* <p>If this method returns {@code true}, the method is guaranteed to be executed
|
||||
* asynchronously from the current thread. Otherwise, the handler may be executed on the
|
||||
* current thread or asynchronously.</p>
|
||||
* asynchronously. Otherwise, the handler may be executed on the current thread or
|
||||
* asynchronously. <strong>This still means you must consider thread-safety in your
|
||||
* event listeners</strong> as the "current thread" can and will be different each time.</p>
|
||||
*
|
||||
* <p>If any method handler targeting an event type is marked with {@code true}, then every
|
||||
* handler targeting that event type will be executed asynchronously.</p>
|
||||
|
||||
@@ -20,13 +20,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
*/
|
||||
public interface CommandExecuteEvent extends ResultedEvent<CommandResult> {
|
||||
|
||||
CommandSource getCommandSource();
|
||||
CommandSource source();
|
||||
|
||||
/**
|
||||
* Gets the original command being executed without the first slash.
|
||||
* @return the original command being executed
|
||||
*/
|
||||
String getCommand();
|
||||
String rawCommand();
|
||||
|
||||
final class CommandResult implements ResultedEvent.Result {
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface CommandExecuteEvent extends ResultedEvent<CommandResult> {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public Optional<String> getCommand() {
|
||||
public Optional<String> modifiedCommand() {
|
||||
return Optional.ofNullable(command);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public final class CommandExecuteEventImpl implements CommandExecuteEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSource getCommandSource() {
|
||||
public CommandSource source() {
|
||||
return commandSource;
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ public final class CommandExecuteEventImpl implements CommandExecuteEvent {
|
||||
* @return the original command being executed
|
||||
*/
|
||||
@Override
|
||||
public String getCommand() {
|
||||
public String rawCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult getResult() {
|
||||
public CommandResult result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.velocitypowered.api.proxy.connection.Player;
|
||||
*/
|
||||
public interface PlayerAvailableCommandsEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
RootCommandNode<?> getRootNode();
|
||||
RootCommandNode<?> rootNode();
|
||||
}
|
||||
|
||||
@@ -35,12 +35,12 @@ public class PlayerAvailableCommandsEventImpl implements PlayerAvailableCommands
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RootCommandNode<?> getRootNode() {
|
||||
public RootCommandNode<?> rootNode() {
|
||||
return rootNode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,12 @@
|
||||
|
||||
package com.velocitypowered.api.event.connection;
|
||||
|
||||
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
||||
|
||||
/**
|
||||
* This event is fired when a handshake is established between a client and the proxy.
|
||||
*/
|
||||
public interface ConnectionHandshakeEvent {
|
||||
|
||||
InboundConnection connection();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ public final class ConnectionHandshakeEventImpl implements ConnectionHandshakeEv
|
||||
this.connection = Preconditions.checkNotNull(connection, "connection");
|
||||
}
|
||||
|
||||
public InboundConnection getConnection() {
|
||||
@Override
|
||||
public InboundConnection connection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
|
||||
package com.velocitypowered.api.event.connection;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.velocitypowered.api.event.ResultedEvent;
|
||||
import com.velocitypowered.api.proxy.connection.Player;
|
||||
import com.velocitypowered.api.proxy.connection.ServerConnection;
|
||||
@@ -17,86 +15,29 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This event is fired when a plugin message is sent to the proxy, either from a client ({@link
|
||||
* Player}) or a server ({@link ServerConnection}).
|
||||
*/
|
||||
public final class PluginMessageEvent implements ResultedEvent<PluginMessageEvent.ForwardResult> {
|
||||
public interface PluginMessageEvent extends ResultedEvent<PluginMessageEvent.ForwardResult> {
|
||||
|
||||
private final ChannelMessageSource source;
|
||||
private final ChannelMessageSink target;
|
||||
private final ChannelIdentifier identifier;
|
||||
private final byte[] data;
|
||||
private ForwardResult result;
|
||||
ChannelMessageSource getSource();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param source the source of the plugin message
|
||||
* @param target the destination of the plugin message
|
||||
* @param identifier the channel for this plugin message
|
||||
* @param data the payload of the plugin message
|
||||
*/
|
||||
public PluginMessageEvent(ChannelMessageSource source, ChannelMessageSink target,
|
||||
ChannelIdentifier identifier, byte[] data) {
|
||||
this.source = Preconditions.checkNotNull(source, "source");
|
||||
this.target = Preconditions.checkNotNull(target, "target");
|
||||
this.identifier = Preconditions.checkNotNull(identifier, "identifier");
|
||||
this.data = Preconditions.checkNotNull(data, "data");
|
||||
this.result = ForwardResult.forward();
|
||||
}
|
||||
ChannelMessageSink getTarget();
|
||||
|
||||
@Override
|
||||
public ForwardResult getResult() {
|
||||
return result;
|
||||
}
|
||||
ChannelIdentifier getIdentifier();
|
||||
|
||||
@Override
|
||||
public void setResult(ForwardResult result) {
|
||||
this.result = Preconditions.checkNotNull(result, "result");
|
||||
}
|
||||
byte[] getData();
|
||||
|
||||
public ChannelMessageSource getSource() {
|
||||
return source;
|
||||
}
|
||||
ByteArrayInputStream dataAsInputStream();
|
||||
|
||||
public ChannelMessageSink getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public ChannelIdentifier getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return Arrays.copyOf(data, data.length);
|
||||
}
|
||||
|
||||
public ByteArrayInputStream dataAsInputStream() {
|
||||
return new ByteArrayInputStream(data);
|
||||
}
|
||||
|
||||
public ByteArrayDataInput dataAsDataStream() {
|
||||
return ByteStreams.newDataInput(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PluginMessageEvent{"
|
||||
+ "source=" + source
|
||||
+ ", target=" + target
|
||||
+ ", identifier=" + identifier
|
||||
+ ", data=" + Arrays.toString(data)
|
||||
+ ", result=" + result
|
||||
+ '}';
|
||||
}
|
||||
ByteArrayDataInput dataAsDataStream();
|
||||
|
||||
/**
|
||||
* A result determining whether or not to forward this message on.
|
||||
*/
|
||||
public static final class ForwardResult implements ResultedEvent.Result {
|
||||
public static final class ForwardResult implements Result {
|
||||
|
||||
private static final ForwardResult ALLOWED = new ForwardResult(true);
|
||||
private static final ForwardResult DENIED = new ForwardResult(false);
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.velocitypowered.api.proxy.connection.Player;
|
||||
import com.velocitypowered.api.proxy.connection.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This event is fired when a plugin message is sent to the proxy, either from a client ({@link
|
||||
* Player}) or a server ({@link ServerConnection}).
|
||||
*/
|
||||
public final class PluginMessageEventImpl implements PluginMessageEvent {
|
||||
|
||||
private final ChannelMessageSource source;
|
||||
private final ChannelMessageSink target;
|
||||
private final ChannelIdentifier identifier;
|
||||
private final byte[] data;
|
||||
private ForwardResult result;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param source the source of the plugin message
|
||||
* @param target the destination of the plugin message
|
||||
* @param identifier the channel for this plugin message
|
||||
* @param data the payload of the plugin message
|
||||
*/
|
||||
public PluginMessageEventImpl(ChannelMessageSource source, ChannelMessageSink target,
|
||||
ChannelIdentifier identifier, byte[] data) {
|
||||
this.source = Preconditions.checkNotNull(source, "source");
|
||||
this.target = Preconditions.checkNotNull(target, "target");
|
||||
this.identifier = Preconditions.checkNotNull(identifier, "identifier");
|
||||
this.data = Preconditions.checkNotNull(data, "data");
|
||||
this.result = ForwardResult.forward();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForwardResult result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResult(ForwardResult result) {
|
||||
this.result = Preconditions.checkNotNull(result, "result");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMessageSource getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMessageSink getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelIdentifier getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getData() {
|
||||
return Arrays.copyOf(data, data.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteArrayInputStream dataAsInputStream() {
|
||||
return new ByteArrayInputStream(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteArrayDataInput dataAsDataStream() {
|
||||
return ByteStreams.newDataInput(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PluginMessageEvent{"
|
||||
+ "source=" + source
|
||||
+ ", target=" + target
|
||||
+ ", identifier=" + identifier
|
||||
+ ", data=" + Arrays.toString(data)
|
||||
+ ", result=" + result
|
||||
+ '}';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,9 +15,9 @@ import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
*/
|
||||
public interface ProxyPingEvent {
|
||||
|
||||
InboundConnection getConnection();
|
||||
InboundConnection connection();
|
||||
|
||||
ServerPing getPing();
|
||||
ServerPing ping();
|
||||
|
||||
void setPing(ServerPing ping);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ public final class ProxyPingEventImpl implements ProxyPingEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InboundConnection getConnection() {
|
||||
public InboundConnection connection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerPing getPing() {
|
||||
public ServerPing ping() {
|
||||
return ping;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,21 +20,21 @@ public interface ProxyQueryEvent {
|
||||
*
|
||||
* @return query type
|
||||
*/
|
||||
QueryType getQueryType();
|
||||
QueryType type();
|
||||
|
||||
/**
|
||||
* Get the address of the client that sent this query.
|
||||
*
|
||||
* @return querier address
|
||||
*/
|
||||
InetAddress getQuerierAddress();
|
||||
InetAddress queryingAddress();
|
||||
|
||||
/**
|
||||
* Returns the current query response.
|
||||
*
|
||||
* @return the current query response
|
||||
*/
|
||||
QueryResponse getResponse();
|
||||
QueryResponse response();
|
||||
|
||||
/**
|
||||
* Sets a new query response.
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class ProxyQueryEventImpl implements ProxyQueryEvent {
|
||||
* @return query type
|
||||
*/
|
||||
@Override
|
||||
public QueryType getQueryType() {
|
||||
public QueryType type() {
|
||||
return queryType;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class ProxyQueryEventImpl implements ProxyQueryEvent {
|
||||
* @return querier address
|
||||
*/
|
||||
@Override
|
||||
public InetAddress getQuerierAddress() {
|
||||
public InetAddress queryingAddress() {
|
||||
return querierAddress;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class ProxyQueryEventImpl implements ProxyQueryEvent {
|
||||
* @return the current query response
|
||||
*/
|
||||
@Override
|
||||
public QueryResponse getResponse() {
|
||||
public QueryResponse response() {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.net.SocketAddress;
|
||||
*/
|
||||
public interface ListenerBoundEvent {
|
||||
|
||||
SocketAddress getAddress();
|
||||
SocketAddress address();
|
||||
|
||||
ListenerType getListenerType();
|
||||
ListenerType type();
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ public final class ListenerBoundEventImpl implements ListenerBoundEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getAddress() {
|
||||
public SocketAddress address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenerType getListenerType() {
|
||||
public ListenerType type() {
|
||||
return listenerType;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.net.SocketAddress;
|
||||
*/
|
||||
public interface ListenerClosedEvent {
|
||||
|
||||
SocketAddress getAddress();
|
||||
SocketAddress address();
|
||||
|
||||
ListenerType getListenerType();
|
||||
ListenerType type();
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ public final class ListenerClosedEventImpl implements ListenerClosedEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getAddress() {
|
||||
public SocketAddress address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenerType getListenerType() {
|
||||
public ListenerType type() {
|
||||
return listenerType;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
*/
|
||||
public interface PermissionsSetupEvent {
|
||||
|
||||
PermissionSubject getSubject();
|
||||
PermissionSubject subject();
|
||||
|
||||
/**
|
||||
* Uses the provider function to obtain a {@link PermissionFunction} for the subject.
|
||||
@@ -29,7 +29,7 @@ public interface PermissionsSetupEvent {
|
||||
*/
|
||||
PermissionFunction createFunction(PermissionSubject subject);
|
||||
|
||||
PermissionProvider getProvider();
|
||||
PermissionProvider provider();
|
||||
|
||||
/**
|
||||
* Sets the {@link PermissionFunction} that should be used for the subject.
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class PermissionsSetupEventImpl implements PermissionsSetupEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionSubject getSubject() {
|
||||
public PermissionSubject subject() {
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public final class PermissionsSetupEventImpl implements PermissionsSetupEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionProvider getProvider() {
|
||||
public PermissionProvider provider() {
|
||||
return this.provider;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,15 @@ package com.velocitypowered.api.event.player;
|
||||
|
||||
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 interface DisconnectEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
LoginStatus getLoginStatus();
|
||||
LoginStatus loginStatus();
|
||||
|
||||
public enum LoginStatus {
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ public final class DisconnectEventImpl implements DisconnectEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginStatus getLoginStatus() {
|
||||
public LoginStatus loginStatus() {
|
||||
return loginStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
*/
|
||||
public interface GameProfileRequestEvent {
|
||||
|
||||
InboundConnection getConnection();
|
||||
InboundConnection connection();
|
||||
|
||||
String getUsername();
|
||||
String username();
|
||||
|
||||
GameProfile getOriginalProfile();
|
||||
GameProfile initialProfile();
|
||||
|
||||
boolean isOnlineMode();
|
||||
|
||||
@@ -32,7 +32,7 @@ public interface GameProfileRequestEvent {
|
||||
*
|
||||
* @return the user's {@link GameProfile}
|
||||
*/
|
||||
GameProfile getGameProfile();
|
||||
GameProfile gameProfile();
|
||||
|
||||
/**
|
||||
* Sets the game profile to use for this connection.
|
||||
|
||||
@@ -39,17 +39,17 @@ public final class GameProfileRequestEventImpl implements GameProfileRequestEven
|
||||
}
|
||||
|
||||
@Override
|
||||
public InboundConnection getConnection() {
|
||||
public InboundConnection connection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
public String username() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOriginalProfile() {
|
||||
public GameProfile initialProfile() {
|
||||
return originalProfile;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class GameProfileRequestEventImpl implements GameProfileRequestEven
|
||||
* @return the user's {@link GameProfile}
|
||||
*/
|
||||
@Override
|
||||
public GameProfile getGameProfile() {
|
||||
public GameProfile gameProfile() {
|
||||
return gameProfile == null ? originalProfile : gameProfile;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public interface KickedFromServerEvent extends
|
||||
ResultedEvent<KickedFromServerEvent.ServerKickResult> {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
RegisteredServer getServer();
|
||||
RegisteredServer server();
|
||||
|
||||
/**
|
||||
* Gets the reason the server kicked the player from the server.
|
||||
*
|
||||
* @return the server kicked the player from the server
|
||||
*/
|
||||
Optional<Component> getServerKickReason();
|
||||
Optional<Component> serverKickReason();
|
||||
|
||||
/**
|
||||
* Returns whether or not the player got kicked while connecting to another server.
|
||||
@@ -54,10 +54,10 @@ public interface KickedFromServerEvent extends
|
||||
*/
|
||||
final class DisconnectPlayer implements ServerKickResult {
|
||||
|
||||
private final Component component;
|
||||
private final Component message;
|
||||
|
||||
private DisconnectPlayer(Component component) {
|
||||
this.component = Preconditions.checkNotNull(component, "component");
|
||||
private DisconnectPlayer(Component message) {
|
||||
this.message = Preconditions.checkNotNull(message, "message");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,8 +65,8 @@ public interface KickedFromServerEvent extends
|
||||
return true;
|
||||
}
|
||||
|
||||
public Component getReason() {
|
||||
return component;
|
||||
public Component message() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public interface KickedFromServerEvent extends
|
||||
return server;
|
||||
}
|
||||
|
||||
public Component getMessage() {
|
||||
public Component message() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public interface KickedFromServerEvent extends
|
||||
return false;
|
||||
}
|
||||
|
||||
public Component getMessage() {
|
||||
public Component message() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class KickedFromServerEventImpl implements KickedFromServerEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerKickResult getResult() {
|
||||
public ServerKickResult result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -58,12 +58,12 @@ public final class KickedFromServerEventImpl implements KickedFromServerEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegisteredServer getServer() {
|
||||
public RegisteredServer server() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public final class KickedFromServerEventImpl implements KickedFromServerEvent {
|
||||
* @return the server kicked the player from the server
|
||||
*/
|
||||
@Override
|
||||
public Optional<Component> getServerKickReason() {
|
||||
public Optional<Component> serverKickReason() {
|
||||
return Optional.ofNullable(originalReason);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,6 @@ import com.velocitypowered.api.proxy.connection.Player;
|
||||
*/
|
||||
public interface LoginEvent extends ResultedEvent<ResultedEvent.ComponentResult> {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
@Override
|
||||
ComponentResult getResult();
|
||||
|
||||
@Override
|
||||
void setResult(ComponentResult result);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ public final class LoginEventImpl implements LoginEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentResult getResult() {
|
||||
public ComponentResult result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface PlayerChannelRegisterEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
List<ChannelIdentifier> getChannels();
|
||||
List<ChannelIdentifier> channels();
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ public final class PlayerChannelRegisterEventImpl implements PlayerChannelRegist
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChannelIdentifier> getChannels() {
|
||||
public List<ChannelIdentifier> channels() {
|
||||
return channels;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface PlayerChatEvent extends ResultedEvent<PlayerChatEvent.ChatResult> {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
String getMessage();
|
||||
|
||||
@Override
|
||||
ChatResult getResult();
|
||||
|
||||
@Override
|
||||
void setResult(ChatResult result);
|
||||
String sentMessage();
|
||||
|
||||
/**
|
||||
* Represents the result of the {@link PlayerChatEvent}.
|
||||
@@ -42,7 +36,7 @@ public interface PlayerChatEvent extends ResultedEvent<PlayerChatEvent.ChatResul
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Optional<String> getMessage() {
|
||||
public Optional<String> modifiedMessage() {
|
||||
return Optional.ofNullable(message);
|
||||
}
|
||||
|
||||
@@ -80,7 +74,7 @@ public interface PlayerChatEvent extends ResultedEvent<PlayerChatEvent.ChatResul
|
||||
* @param message the message to use instead
|
||||
* @return a result with a new message
|
||||
*/
|
||||
public static ChatResult message(@NonNull String message) {
|
||||
public static ChatResult replaceMessage(@NonNull String message) {
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
return new ChatResult(true, message);
|
||||
}
|
||||
|
||||
@@ -31,17 +31,17 @@ public final class PlayerChatEventImpl implements PlayerChatEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String sentMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatResult getResult() {
|
||||
public ChatResult result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.util.Optional;
|
||||
*/
|
||||
public interface PlayerChooseInitialServerEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
Optional<RegisteredServer> getInitialServer();
|
||||
Optional<RegisteredServer> initialServer();
|
||||
|
||||
/**
|
||||
* Sets the new initial server.
|
||||
|
||||
@@ -33,12 +33,12 @@ public class PlayerChooseInitialServerEventImpl implements PlayerChooseInitialSe
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RegisteredServer> getInitialServer() {
|
||||
public Optional<RegisteredServer> initialServer() {
|
||||
return Optional.ofNullable(initialServer);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
package com.velocitypowered.api.event.player;
|
||||
|
||||
import com.velocitypowered.api.proxy.connection.Player;
|
||||
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
||||
import com.velocitypowered.api.proxy.player.ClientSettings;
|
||||
|
||||
public interface PlayerSettingsChangedEvent {
|
||||
public interface PlayerClientSettingsChangedEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
PlayerSettings getPlayerSettings();
|
||||
ClientSettings settings();
|
||||
}
|
||||
@@ -10,33 +10,34 @@ 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;
|
||||
import com.velocitypowered.api.proxy.player.ClientSettings;
|
||||
|
||||
public final class PlayerSettingsChangedEventImpl implements PlayerSettingsChangedEvent {
|
||||
public final class PlayerClientSettingsChangedEventImpl implements
|
||||
PlayerClientSettingsChangedEvent {
|
||||
|
||||
private final Player player;
|
||||
private final PlayerSettings playerSettings;
|
||||
private final ClientSettings clientSettings;
|
||||
|
||||
public PlayerSettingsChangedEventImpl(Player player, PlayerSettings playerSettings) {
|
||||
public PlayerClientSettingsChangedEventImpl(Player player, ClientSettings clientSettings) {
|
||||
this.player = Preconditions.checkNotNull(player, "player");
|
||||
this.playerSettings = Preconditions.checkNotNull(playerSettings, "playerSettings");
|
||||
this.clientSettings = Preconditions.checkNotNull(clientSettings, "playerSettings");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerSettings getPlayerSettings() {
|
||||
return playerSettings;
|
||||
public ClientSettings settings() {
|
||||
return clientSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("player", player)
|
||||
.add("playerSettings", playerSettings)
|
||||
.add("playerSettings", clientSettings)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import com.velocitypowered.api.util.ModInfo;
|
||||
*/
|
||||
public interface PlayerModInfoEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
ModInfo getModInfo();
|
||||
ModInfo modInfo();
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ public final class PlayerModInfoEventImpl implements PlayerModInfoEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModInfo getModInfo() {
|
||||
public ModInfo modInfo() {
|
||||
return modInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ public interface PlayerResourcePackStatusEvent {
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
/**
|
||||
* Returns the new status for the resource pack.
|
||||
*
|
||||
* @return the new status
|
||||
*/
|
||||
Status getStatus();
|
||||
Status status();
|
||||
|
||||
/**
|
||||
* Represents the possible statuses for the resource pack.
|
||||
|
||||
@@ -30,7 +30,7 @@ public class PlayerResourcePackStatusEventImpl implements PlayerResourcePackStat
|
||||
* @return the player
|
||||
*/
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PlayerResourcePackStatusEventImpl implements PlayerResourcePackStat
|
||||
* @return the new status
|
||||
*/
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
public Status status() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ import com.velocitypowered.api.proxy.connection.Player;
|
||||
*/
|
||||
public interface PostLoginEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public final class PostLoginEventImpl implements PostLoginEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
*/
|
||||
public interface PreLoginEvent extends ResultedEvent<PreLoginEvent.PreLoginComponentResult> {
|
||||
|
||||
InboundConnection getConnection();
|
||||
InboundConnection connection();
|
||||
|
||||
String getUsername();
|
||||
|
||||
@Override
|
||||
PreLoginComponentResult getResult();
|
||||
|
||||
@Override
|
||||
void setResult(@NonNull PreLoginComponentResult result);
|
||||
String username();
|
||||
|
||||
/**
|
||||
* Represents an "allowed/allowed with forced online\offline mode/denied" result with a reason
|
||||
@@ -59,7 +53,7 @@ public interface PreLoginEvent extends ResultedEvent<PreLoginEvent.PreLoginCompo
|
||||
return result != Result.DISALLOWED;
|
||||
}
|
||||
|
||||
public Optional<Component> getReason() {
|
||||
public Optional<Component> denialReason() {
|
||||
return Optional.ofNullable(reason);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,17 +34,17 @@ public final class PreLoginEventImpl implements PreLoginEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InboundConnection getConnection() {
|
||||
public InboundConnection connection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
public String username() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreLoginComponentResult getResult() {
|
||||
public PreLoginComponentResult result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.util.Optional;
|
||||
*/
|
||||
public interface ServerConnectedEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
RegisteredServer getServer();
|
||||
RegisteredServer target();
|
||||
|
||||
Optional<RegisteredServer> getPreviousServer();
|
||||
Optional<RegisteredServer> previousServer();
|
||||
}
|
||||
|
||||
@@ -37,17 +37,17 @@ public final class ServerConnectedEventImpl implements ServerConnectedEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegisteredServer getServer() {
|
||||
public RegisteredServer target() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RegisteredServer> getPreviousServer() {
|
||||
public Optional<RegisteredServer> previousServer() {
|
||||
return Optional.ofNullable(previousServer);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ 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()}.
|
||||
* available in {@link Player#connectedServer()}.
|
||||
*/
|
||||
public interface ServerPostConnectEvent {
|
||||
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
@Nullable RegisteredServer getPreviousServer();
|
||||
@Nullable RegisteredServer previousServer();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Fired after the player has connected to a server. The server the player is now connected to is
|
||||
* available in {@link Player#getCurrentServer()}.
|
||||
* available in {@link Player#connectedServer()}.
|
||||
*/
|
||||
public class ServerPostConnectEventImpl implements ServerPostConnectEvent {
|
||||
|
||||
@@ -28,12 +28,12 @@ public class ServerPostConnectEventImpl implements ServerPostConnectEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable RegisteredServer getPreviousServer() {
|
||||
public @Nullable RegisteredServer previousServer() {
|
||||
return previousServer;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,22 +26,16 @@ public interface ServerPreConnectEvent extends ResultedEvent<ServerPreConnectEve
|
||||
*
|
||||
* @return the player connecting to the server
|
||||
*/
|
||||
Player getPlayer();
|
||||
|
||||
@Override
|
||||
ServerResult getResult();
|
||||
|
||||
@Override
|
||||
void setResult(ServerResult result);
|
||||
Player player();
|
||||
|
||||
/**
|
||||
* 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()}.
|
||||
* currently on when this event is fired, use {@link Player#connectedServer()}.
|
||||
*
|
||||
* @return the server that the player originally tried to connect to
|
||||
*/
|
||||
RegisteredServer getOriginalServer();
|
||||
RegisteredServer originalTarget();
|
||||
|
||||
/**
|
||||
* Represents the result of the {@link ServerPreConnectEvent}.
|
||||
@@ -50,25 +44,25 @@ public interface ServerPreConnectEvent extends ResultedEvent<ServerPreConnectEve
|
||||
|
||||
private static final ServerResult DENIED = new ServerResult(null);
|
||||
|
||||
private final @Nullable RegisteredServer server;
|
||||
private final @Nullable RegisteredServer target;
|
||||
|
||||
private ServerResult(@Nullable RegisteredServer server) {
|
||||
this.server = server;
|
||||
private ServerResult(@Nullable RegisteredServer target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowed() {
|
||||
return server != null;
|
||||
return target != null;
|
||||
}
|
||||
|
||||
public Optional<RegisteredServer> getServer() {
|
||||
return Optional.ofNullable(server);
|
||||
public Optional<RegisteredServer> target() {
|
||||
return Optional.ofNullable(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (server != null) {
|
||||
return "allowed: connect to " + server.getServerInfo().getName();
|
||||
if (target != null) {
|
||||
return "allowed: connect to " + target.serverInfo().name();
|
||||
}
|
||||
return "denied";
|
||||
}
|
||||
@@ -87,12 +81,12 @@ public interface ServerPreConnectEvent extends ResultedEvent<ServerPreConnectEve
|
||||
/**
|
||||
* Allows the player to connect to the specified server.
|
||||
*
|
||||
* @param server the new server to connect to
|
||||
* @param target the new server to connect to
|
||||
* @return a result to allow the player to connect to the specified server
|
||||
*/
|
||||
public static ServerResult allowed(RegisteredServer server) {
|
||||
Preconditions.checkNotNull(server, "server");
|
||||
return new ServerResult(server);
|
||||
public static ServerResult allowed(RegisteredServer target) {
|
||||
Preconditions.checkNotNull(target, "server");
|
||||
return new ServerResult(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ public final class ServerPreConnectEventImpl implements ServerPreConnectEvent {
|
||||
* @return the player connecting to the server
|
||||
*/
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResult getResult() {
|
||||
public ServerResult result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ public final class ServerPreConnectEventImpl implements ServerPreConnectEvent {
|
||||
/**
|
||||
* 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()}.
|
||||
* player is currently on when this event is fired, use {@link Player#connectedServer()}.
|
||||
* @return the server that the player originally tried to connect to
|
||||
*/
|
||||
@Override
|
||||
public RegisteredServer getOriginalServer() {
|
||||
public RegisteredServer originalTarget() {
|
||||
return originalServer;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,19 +21,19 @@ public interface TabCompleteEvent {
|
||||
*
|
||||
* @return the requesting player
|
||||
*/
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
|
||||
/**
|
||||
* Returns the message being partially completed.
|
||||
*
|
||||
* @return the partial message
|
||||
*/
|
||||
String getPartialMessage();
|
||||
String partialMessage();
|
||||
|
||||
/**
|
||||
* Returns all the suggestions provided to the user, as a mutable list.
|
||||
*
|
||||
* @return the suggestions
|
||||
*/
|
||||
List<String> getSuggestions();
|
||||
List<String> suggestions();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TabCompleteEventImpl implements TabCompleteEvent {
|
||||
* @return the requesting player
|
||||
*/
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
public Player player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class TabCompleteEventImpl implements TabCompleteEvent {
|
||||
* @return the partial message
|
||||
*/
|
||||
@Override
|
||||
public String getPartialMessage() {
|
||||
public String partialMessage() {
|
||||
return partialMessage;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class TabCompleteEventImpl implements TabCompleteEvent {
|
||||
* @return the suggestions
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSuggestions() {
|
||||
public List<String> suggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ public enum ProtocolVersion implements Ordered<ProtocolVersion> {
|
||||
* The user-friendly representation of the lowest and highest supported versions.
|
||||
*/
|
||||
public static final String SUPPORTED_VERSION_STRING = String
|
||||
.format("%s-%s", MINIMUM_VERSION.getVersionIntroducedIn(),
|
||||
MAXIMUM_VERSION.getMostRecentSupportedVersion());
|
||||
.format("%s-%s", MINIMUM_VERSION.versionIntroducedIn(),
|
||||
MAXIMUM_VERSION.mostRecentSupportedVersion());
|
||||
|
||||
/**
|
||||
* A map linking the protocol version number to its {@link ProtocolVersion} representation.
|
||||
@@ -135,29 +135,17 @@ public enum ProtocolVersion implements Ordered<ProtocolVersion> {
|
||||
*
|
||||
* @return the protocol version
|
||||
*/
|
||||
public int getProtocol() {
|
||||
public int protocol() {
|
||||
return protocol == -1 ? snapshotProtocol : protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user-friendly name for this protocol.
|
||||
*
|
||||
* @return the protocol name
|
||||
* @deprecated A protocol may be shared by multiple versions. Use @link{#getVersionIntroducedIn()}
|
||||
* or @link{#getVersionsSupportedBy()} to get more accurate version names.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getName() {
|
||||
return getVersionIntroducedIn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user-friendly name of the version
|
||||
* this protocol was introduced in.
|
||||
*
|
||||
* @return the version name
|
||||
*/
|
||||
public String getVersionIntroducedIn() {
|
||||
public String versionIntroducedIn() {
|
||||
return names[0];
|
||||
}
|
||||
|
||||
@@ -167,7 +155,7 @@ public enum ProtocolVersion implements Ordered<ProtocolVersion> {
|
||||
*
|
||||
* @return the version name
|
||||
*/
|
||||
public String getMostRecentSupportedVersion() {
|
||||
public String mostRecentSupportedVersion() {
|
||||
return names[names.length - 1];
|
||||
}
|
||||
|
||||
@@ -176,7 +164,7 @@ public enum ProtocolVersion implements Ordered<ProtocolVersion> {
|
||||
*
|
||||
* @return the version names
|
||||
*/
|
||||
public List<String> getVersionsSupportedBy() {
|
||||
public List<String> supportedVersions() {
|
||||
return ImmutableList.copyOf(names);
|
||||
}
|
||||
|
||||
@@ -186,7 +174,7 @@ public enum ProtocolVersion implements Ordered<ProtocolVersion> {
|
||||
* @param protocol the protocol as an int
|
||||
* @return the protocol version
|
||||
*/
|
||||
public static ProtocolVersion getProtocolVersion(int protocol) {
|
||||
public static ProtocolVersion byMinecraftProtocolVersion(int protocol) {
|
||||
return ID_TO_PROTOCOL_CONSTANT.getOrDefault(protocol, UNKNOWN);
|
||||
}
|
||||
|
||||
@@ -232,6 +220,6 @@ public enum ProtocolVersion implements Ordered<ProtocolVersion> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getVersionIntroducedIn();
|
||||
return versionIntroducedIn();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ public interface PermissionFunction {
|
||||
PermissionFunction ALWAYS_UNDEFINED = p -> Tristate.UNDEFINED;
|
||||
|
||||
/**
|
||||
* Gets the subjects setting for a particular permission.
|
||||
* Evaluates whether or not the player has a permission.
|
||||
*
|
||||
* @param permission the permission
|
||||
* @return the value the permission is set to
|
||||
*/
|
||||
Tristate getPermissionValue(String permission);
|
||||
Tristate evaluatePermission(String permission);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface PermissionSubject {
|
||||
* @return whether or not the subject has the permission
|
||||
*/
|
||||
default boolean hasPermission(String permission) {
|
||||
return getPermissionValue(permission).asBoolean();
|
||||
return evaluatePermission(permission).asBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,5 +28,5 @@ public interface PermissionSubject {
|
||||
* @param permission the permission
|
||||
* @return the value the permission is set to
|
||||
*/
|
||||
Tristate getPermissionValue(String permission);
|
||||
Tristate evaluatePermission(String permission);
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ public interface PluginContainer {
|
||||
*
|
||||
* @return the plugin's description
|
||||
*/
|
||||
PluginDescription getDescription();
|
||||
PluginDescription description();
|
||||
|
||||
/**
|
||||
* Returns the created plugin if it is available.
|
||||
*
|
||||
* @return the instance if available
|
||||
*/
|
||||
default Optional<?> getInstance() {
|
||||
default Optional<?> instance() {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface PluginDescription {
|
||||
* @return the plugin ID
|
||||
* @see Plugin#id()
|
||||
*/
|
||||
String getId();
|
||||
String id();
|
||||
|
||||
/**
|
||||
* Gets the name of the {@link Plugin} within this container.
|
||||
@@ -42,7 +42,7 @@ public interface PluginDescription {
|
||||
* @return an {@link Optional} with the plugin name, may be empty
|
||||
* @see Plugin#name()
|
||||
*/
|
||||
default Optional<String> getName() {
|
||||
default Optional<String> name() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public interface PluginDescription {
|
||||
* @return an {@link Optional} with the plugin version, may be empty
|
||||
* @see Plugin#version()
|
||||
*/
|
||||
default Optional<String> getVersion() {
|
||||
default Optional<String> version() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public interface PluginDescription {
|
||||
* @return an {@link Optional} with the plugin description, may be empty
|
||||
* @see Plugin#description()
|
||||
*/
|
||||
default Optional<String> getDescription() {
|
||||
default Optional<String> description() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface PluginDescription {
|
||||
* @return an {@link Optional} with the plugin url, may be empty
|
||||
* @see Plugin#url()
|
||||
*/
|
||||
default Optional<String> getUrl() {
|
||||
default Optional<String> url() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public interface PluginDescription {
|
||||
* @return the plugin authors, may be empty
|
||||
* @see Plugin#authors()
|
||||
*/
|
||||
default List<String> getAuthors() {
|
||||
default List<String> authors() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public interface PluginDescription {
|
||||
* @return the plugin dependencies, can be empty
|
||||
* @see Plugin#dependencies()
|
||||
*/
|
||||
default Collection<PluginDependency> getDependencies() {
|
||||
default Collection<PluginDependency> dependencies() {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
@@ -101,11 +101,11 @@ public interface PluginDescription {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source the plugin was loaded from.
|
||||
* Returns the file path the plugin was loaded from.
|
||||
*
|
||||
* @return the source the plugin was loaded from or {@link Optional#empty()} if unknown
|
||||
* @return the path the plugin was loaded from or {@link Optional#empty()} if unknown
|
||||
*/
|
||||
default Optional<Path> getSource() {
|
||||
default Optional<Path> file() {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
/**
|
||||
* Provides an interface to a Minecraft server proxy.
|
||||
@@ -35,7 +36,7 @@ public interface ProxyServer extends Audience {
|
||||
*
|
||||
* @param reason message to kick online players with
|
||||
*/
|
||||
void shutdown(net.kyori.adventure.text.Component reason);
|
||||
void shutdown(Component reason);
|
||||
|
||||
/**
|
||||
* Shuts down the proxy, kicking players with the default reason.
|
||||
@@ -65,14 +66,14 @@ public interface ProxyServer extends Audience {
|
||||
*
|
||||
* @return the players online on this proxy
|
||||
*/
|
||||
Collection<Player> getAllPlayers();
|
||||
Collection<Player> connectedPlayers();
|
||||
|
||||
/**
|
||||
* Returns the number of players currently connected to this proxy.
|
||||
*
|
||||
* @return the players on this proxy
|
||||
*/
|
||||
int getPlayerCount();
|
||||
int countConnectedPlayers();
|
||||
|
||||
/**
|
||||
* Retrieves a registered {@link RegisteredServer} instance by its name. The search is
|
||||
@@ -81,14 +82,14 @@ public interface ProxyServer extends Audience {
|
||||
* @param name the name of the server
|
||||
* @return the registered server, which may be empty
|
||||
*/
|
||||
Optional<RegisteredServer> getServer(String name);
|
||||
Optional<RegisteredServer> server(String name);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link RegisteredServer}s registered with this proxy.
|
||||
*
|
||||
* @return the servers registered with this proxy
|
||||
*/
|
||||
Collection<RegisteredServer> getAllServers();
|
||||
Collection<RegisteredServer> registeredServers();
|
||||
|
||||
/**
|
||||
* Matches all {@link Player}s whose names start with the provided partial name.
|
||||
@@ -129,62 +130,54 @@ public interface ProxyServer extends Audience {
|
||||
*
|
||||
* @return the console command invoker
|
||||
*/
|
||||
ConsoleCommandSource getConsoleCommandSource();
|
||||
ConsoleCommandSource consoleCommandSource();
|
||||
|
||||
/**
|
||||
* Gets the {@link PluginManager} instance.
|
||||
*
|
||||
* @return the plugin manager instance
|
||||
*/
|
||||
PluginManager getPluginManager();
|
||||
PluginManager pluginManager();
|
||||
|
||||
/**
|
||||
* Gets the {@link EventManager} instance.
|
||||
*
|
||||
* @return the event manager instance
|
||||
*/
|
||||
EventManager getEventManager();
|
||||
EventManager eventManager();
|
||||
|
||||
/**
|
||||
* Gets the {@link CommandManager} instance.
|
||||
*
|
||||
* @return the command manager
|
||||
*/
|
||||
CommandManager getCommandManager();
|
||||
CommandManager commandManager();
|
||||
|
||||
/**
|
||||
* Gets the {@link Scheduler} instance.
|
||||
*
|
||||
* @return the scheduler instance
|
||||
*/
|
||||
Scheduler getScheduler();
|
||||
Scheduler scheduler();
|
||||
|
||||
/**
|
||||
* Gets the {@link ChannelRegistrar} instance.
|
||||
*
|
||||
* @return the channel registrar
|
||||
*/
|
||||
ChannelRegistrar getChannelRegistrar();
|
||||
|
||||
/**
|
||||
* Gets the address that this proxy is bound to. This does not necessarily indicate the external
|
||||
* IP address of the proxy.
|
||||
*
|
||||
* @return the address the proxy is bound to
|
||||
*/
|
||||
SocketAddress getBoundAddress();
|
||||
ChannelRegistrar channelRegistrar();
|
||||
|
||||
/**
|
||||
* Gets the {@link ProxyConfig} instance.
|
||||
*
|
||||
* @return the proxy config
|
||||
*/
|
||||
ProxyConfig getConfiguration();
|
||||
ProxyConfig configuration();
|
||||
|
||||
/**
|
||||
* Returns the version of the proxy.
|
||||
*
|
||||
* @return the proxy version
|
||||
*/
|
||||
ProxyVersion getVersion();
|
||||
ProxyVersion version();
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public interface ProxyConfig {
|
||||
/**
|
||||
* Get a Map of all servers registered in <code>velocity.toml</code>. This method does
|
||||
* <strong>not</strong> return all the servers currently in memory, although in most cases it
|
||||
* does. For a view of all registered servers, see {@link ProxyServer#getAllServers()}.
|
||||
* does. For a view of all registered servers, see {@link ProxyServer#registeredServers()}.
|
||||
*
|
||||
* @return registered servers map
|
||||
*/
|
||||
|
||||
@@ -22,14 +22,14 @@ public interface InboundConnection {
|
||||
*
|
||||
* @return the player's remote address
|
||||
*/
|
||||
SocketAddress getRemoteAddress();
|
||||
SocketAddress remoteAddress();
|
||||
|
||||
/**
|
||||
* Returns the hostname that the user entered into the client, if applicable.
|
||||
*
|
||||
* @return the hostname from the client
|
||||
*/
|
||||
Optional<InetSocketAddress> getVirtualHost();
|
||||
Optional<InetSocketAddress> connectedHost();
|
||||
|
||||
/**
|
||||
* Determine whether or not the player remains online.
|
||||
@@ -43,5 +43,5 @@ public interface InboundConnection {
|
||||
*
|
||||
* @return the protocol version the connection uses
|
||||
*/
|
||||
ProtocolVersion getProtocolVersion();
|
||||
ProtocolVersion protocolVersion();
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import com.velocitypowered.api.command.CommandSource;
|
||||
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.ClientSettings;
|
||||
import com.velocitypowered.api.proxy.player.ConnectionRequestBuilder;
|
||||
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
||||
import com.velocitypowered.api.proxy.player.TabList;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
@@ -34,49 +34,49 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
String getUsername();
|
||||
String username();
|
||||
|
||||
/**
|
||||
* Returns the player's UUID.
|
||||
*
|
||||
* @return the UUID
|
||||
*/
|
||||
UUID getUniqueId();
|
||||
UUID id();
|
||||
|
||||
/**
|
||||
* Returns the server that the player is currently connected to.
|
||||
*
|
||||
* @return an {@link Optional} the server that the player is connected to, which may be empty
|
||||
*/
|
||||
Optional<ServerConnection> getCurrentServer();
|
||||
Optional<ServerConnection> connectedServer();
|
||||
|
||||
/**
|
||||
* Returns the player's client settings.
|
||||
*
|
||||
* @return the settings
|
||||
*/
|
||||
PlayerSettings getPlayerSettings();
|
||||
ClientSettings clientSettings();
|
||||
|
||||
/**
|
||||
* Returns the player's mod info if they have a modded client.
|
||||
*
|
||||
* @return an {@link Optional} the mod info. which may be empty
|
||||
*/
|
||||
Optional<ModInfo> getModInfo();
|
||||
Optional<ModInfo> modInfo();
|
||||
|
||||
/**
|
||||
* Returns the current player's ping.
|
||||
*
|
||||
* @return the player's ping or -1 if ping information is currently unknown
|
||||
*/
|
||||
long getPing();
|
||||
long ping();
|
||||
|
||||
/**
|
||||
* Returns the player's connection status.
|
||||
*
|
||||
* @return true if the player is authenticated with Mojang servers
|
||||
*/
|
||||
boolean isOnlineMode();
|
||||
boolean onlineMode();
|
||||
|
||||
/**
|
||||
* Creates a new connection request so that the player can connect to another server.
|
||||
@@ -96,14 +96,14 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
/**
|
||||
* Returns the player's game profile.
|
||||
*/
|
||||
GameProfile getGameProfile();
|
||||
GameProfile gameProfile();
|
||||
|
||||
/**
|
||||
* Returns the player's tab list.
|
||||
*
|
||||
* @return this player's tab list
|
||||
*/
|
||||
TabList getTabList();
|
||||
TabList tabList();
|
||||
|
||||
/**
|
||||
* Disconnects the player with the specified reason. Once this method is called, further calls to
|
||||
|
||||
@@ -22,19 +22,19 @@ public interface ServerConnection extends ChannelMessageSource, ChannelMessageSi
|
||||
*
|
||||
* @return the server this connection is connected to
|
||||
*/
|
||||
RegisteredServer getServer();
|
||||
RegisteredServer target();
|
||||
|
||||
/**
|
||||
* Returns the server info for this connection.
|
||||
*
|
||||
* @return the server info for this connection
|
||||
*/
|
||||
ServerInfo getServerInfo();
|
||||
ServerInfo serverInfo();
|
||||
|
||||
/**
|
||||
* Returns the player that this connection is associated with.
|
||||
*
|
||||
* @return the player for this connection
|
||||
*/
|
||||
Player getPlayer();
|
||||
Player player();
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ public interface ChannelIdentifier {
|
||||
*
|
||||
* @return the textual representation of the identifier
|
||||
*/
|
||||
String getId();
|
||||
String id();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.velocitypowered.api.proxy.messages;
|
||||
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEventImpl;
|
||||
|
||||
/**
|
||||
* Represents an interface to register and unregister {@link ChannelIdentifier}s for the proxy to
|
||||
* listen on.
|
||||
@@ -15,7 +17,7 @@ public interface ChannelRegistrar {
|
||||
|
||||
/**
|
||||
* Registers the specified message identifiers to listen on so you can intercept plugin messages
|
||||
* on the channel using {@link com.velocitypowered.api.event.connection.PluginMessageEvent}.
|
||||
* on the channel using {@link PluginMessageEventImpl}.
|
||||
*
|
||||
* @param identifiers the channel identifiers to register
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class LegacyChannelIdentifier implements ChannelIdentifier {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
public String id() {
|
||||
return this.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public final class MinecraftChannelIdentifier implements ChannelIdentifier {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
public String id() {
|
||||
return namespace + ":" + name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Locale;
|
||||
/**
|
||||
* Represents the client settings for the player.
|
||||
*/
|
||||
public interface PlayerSettings {
|
||||
public interface ClientSettings {
|
||||
|
||||
/**
|
||||
* Returns the locale of the Minecraft client.
|
||||
@@ -24,7 +24,7 @@ public interface ConnectionRequestBuilder {
|
||||
*
|
||||
* @return the server this request will connect to
|
||||
*/
|
||||
RegisteredServer getServer();
|
||||
RegisteredServer target();
|
||||
|
||||
/**
|
||||
* Initiates the connection to the remote server and emits a result on the {@link
|
||||
@@ -61,7 +61,7 @@ public interface ConnectionRequestBuilder {
|
||||
* @return whether or not the request succeeded
|
||||
*/
|
||||
default boolean isSuccessful() {
|
||||
return getStatus() == Status.SUCCESS;
|
||||
return status() == Status.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,21 +69,21 @@ public interface ConnectionRequestBuilder {
|
||||
*
|
||||
* @return the status for this result
|
||||
*/
|
||||
Status getStatus();
|
||||
Status status();
|
||||
|
||||
/**
|
||||
* Returns an (optional) textual reason for the failure to connect to the server.
|
||||
*
|
||||
* @return the reason why the user could not connect to the server
|
||||
*/
|
||||
Optional<Component> getReason();
|
||||
Optional<Component> failureReason();
|
||||
|
||||
/**
|
||||
* Returns the server we actually tried to connect to.
|
||||
*
|
||||
* @return the server we actually tried to connect to
|
||||
*/
|
||||
RegisteredServer getAttemptedConnection();
|
||||
RegisteredServer finalTarget();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,7 +63,7 @@ public interface TabList {
|
||||
*
|
||||
* @return immutable {@link Collection} of tab list entries
|
||||
*/
|
||||
Collection<TabListEntry> getEntries();
|
||||
Collection<TabListEntry> entries();
|
||||
|
||||
/**
|
||||
* Builds a tab list entry.
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface TabListEntry {
|
||||
*
|
||||
* @return parent {@link TabList}
|
||||
*/
|
||||
TabList getTabList();
|
||||
TabList parent();
|
||||
|
||||
/**
|
||||
* Returns the {@link GameProfile} of the entry, which uniquely identifies the entry with the
|
||||
@@ -31,7 +31,7 @@ public interface TabListEntry {
|
||||
*
|
||||
* @return {@link GameProfile} of the entry
|
||||
*/
|
||||
GameProfile getProfile();
|
||||
GameProfile gameProfile();
|
||||
|
||||
/**
|
||||
* Returns {@link Optional} text {@link Component}, which if present is the text
|
||||
@@ -41,7 +41,7 @@ public interface TabListEntry {
|
||||
* @return {@link Optional} text {@link Component} of name displayed in the tab
|
||||
* list
|
||||
*/
|
||||
Optional<Component> getDisplayName();
|
||||
Optional<Component> displayName();
|
||||
|
||||
/**
|
||||
* Sets the text {@link Component} to be displayed for {@code this} {@link TabListEntry}. If
|
||||
@@ -68,16 +68,16 @@ public interface TabListEntry {
|
||||
*
|
||||
* @return latency set for {@code this} entry
|
||||
*/
|
||||
int getLatency();
|
||||
int ping();
|
||||
|
||||
/**
|
||||
* Sets the latency for {@code this} entry to the specified value.
|
||||
*
|
||||
* @param latency to changed to
|
||||
* @return {@code this}, for chaining
|
||||
* @see #getLatency()
|
||||
* @see #ping()
|
||||
*/
|
||||
TabListEntry setLatency(int latency);
|
||||
TabListEntry setPing(int latency);
|
||||
|
||||
/**
|
||||
* Gets the game mode {@code this} entry has been set to.
|
||||
@@ -92,14 +92,14 @@ public interface TabListEntry {
|
||||
*
|
||||
* @return the game mode
|
||||
*/
|
||||
int getGameMode();
|
||||
int gameMode();
|
||||
|
||||
/**
|
||||
* Sets the game mode for {@code this} entry to the specified value.
|
||||
*
|
||||
* @param gameMode to change to
|
||||
* @return {@code this}, for chaining
|
||||
* @see #getGameMode()
|
||||
* @see #gameMode()
|
||||
*/
|
||||
TabListEntry setGameMode(int gameMode);
|
||||
|
||||
@@ -145,7 +145,7 @@ public interface TabListEntry {
|
||||
*
|
||||
* @param profile to set
|
||||
* @return {@code this}, for chaining
|
||||
* @see TabListEntry#getProfile()
|
||||
* @see TabListEntry#gameProfile()
|
||||
*/
|
||||
public Builder profile(GameProfile profile) {
|
||||
this.profile = profile;
|
||||
@@ -157,7 +157,7 @@ public interface TabListEntry {
|
||||
*
|
||||
* @param displayName to set
|
||||
* @return {@code this}, for chaining
|
||||
* @see TabListEntry#getDisplayName()
|
||||
* @see TabListEntry#displayName()
|
||||
*/
|
||||
public Builder displayName(@Nullable Component displayName) {
|
||||
this.displayName = displayName;
|
||||
@@ -169,7 +169,7 @@ public interface TabListEntry {
|
||||
*
|
||||
* @param latency to set
|
||||
* @return {@code this}, for chaining
|
||||
* @see TabListEntry#getLatency()
|
||||
* @see TabListEntry#ping()
|
||||
*/
|
||||
public Builder latency(int latency) {
|
||||
this.latency = latency;
|
||||
@@ -181,7 +181,7 @@ public interface TabListEntry {
|
||||
*
|
||||
* @param gameMode to set
|
||||
* @return {@code this}, for chaining
|
||||
* @see TabListEntry#getGameMode()
|
||||
* @see TabListEntry#gameMode()
|
||||
*/
|
||||
public Builder gameMode(int gameMode) {
|
||||
this.gameMode = gameMode;
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class QueryResponse {
|
||||
private final String hostname;
|
||||
private final String gameVersion;
|
||||
private final String map;
|
||||
private final int currentPlayers;
|
||||
private final int onlinePlayers;
|
||||
private final int maxPlayers;
|
||||
private final String proxyHost;
|
||||
private final int proxyPort;
|
||||
@@ -39,13 +39,13 @@ public final class QueryResponse {
|
||||
private final ImmutableCollection<PluginInformation> plugins;
|
||||
|
||||
@VisibleForTesting
|
||||
QueryResponse(String hostname, String gameVersion, String map, int currentPlayers,
|
||||
QueryResponse(String hostname, String gameVersion, String map, int onlinePlayers,
|
||||
int maxPlayers, String proxyHost, int proxyPort, ImmutableCollection<String> players,
|
||||
String proxyVersion, ImmutableCollection<PluginInformation> plugins) {
|
||||
this.hostname = hostname;
|
||||
this.gameVersion = gameVersion;
|
||||
this.map = map;
|
||||
this.currentPlayers = currentPlayers;
|
||||
this.onlinePlayers = onlinePlayers;
|
||||
this.maxPlayers = maxPlayers;
|
||||
this.proxyHost = proxyHost;
|
||||
this.proxyPort = proxyPort;
|
||||
@@ -60,7 +60,7 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return hostname
|
||||
*/
|
||||
public String getHostname() {
|
||||
public String hostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return game version
|
||||
*/
|
||||
public String getGameVersion() {
|
||||
public String gameVersion() {
|
||||
return gameVersion;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return map name
|
||||
*/
|
||||
public String getMap() {
|
||||
public String mapName() {
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return online player count
|
||||
*/
|
||||
public int getCurrentPlayers() {
|
||||
return currentPlayers;
|
||||
public int onlinePlayers() {
|
||||
return onlinePlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return max player count
|
||||
*/
|
||||
public int getMaxPlayers() {
|
||||
public int maxPlayers() {
|
||||
return maxPlayers;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return proxy hostname
|
||||
*/
|
||||
public String getProxyHost() {
|
||||
public String proxyHost() {
|
||||
return proxyHost;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return proxy port
|
||||
*/
|
||||
public int getProxyPort() {
|
||||
public int proxyPort() {
|
||||
return proxyPort;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return collection of players
|
||||
*/
|
||||
public Collection<String> getPlayers() {
|
||||
public Collection<String> players() {
|
||||
return players;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return server software
|
||||
*/
|
||||
public String getProxyVersion() {
|
||||
public String proxyVersion() {
|
||||
return proxyVersion;
|
||||
}
|
||||
|
||||
@@ -143,11 +143,10 @@ public final class QueryResponse {
|
||||
*
|
||||
* @return collection of plugins
|
||||
*/
|
||||
public Collection<PluginInformation> getPlugins() {
|
||||
public Collection<PluginInformation> plugins() {
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@link Builder} instance from data represented by this response, so that you
|
||||
* may create a new {@link QueryResponse} with new data. It is guaranteed that
|
||||
@@ -158,16 +157,16 @@ public final class QueryResponse {
|
||||
*/
|
||||
public Builder toBuilder() {
|
||||
return QueryResponse.builder()
|
||||
.hostname(getHostname())
|
||||
.gameVersion(getGameVersion())
|
||||
.map(getMap())
|
||||
.currentPlayers(getCurrentPlayers())
|
||||
.maxPlayers(getMaxPlayers())
|
||||
.proxyHost(getProxyHost())
|
||||
.proxyPort(getProxyPort())
|
||||
.players(getPlayers())
|
||||
.proxyVersion(getProxyVersion())
|
||||
.plugins(getPlugins());
|
||||
.hostname(hostname())
|
||||
.gameVersion(gameVersion())
|
||||
.map(mapName())
|
||||
.onlinePlayers(onlinePlayers())
|
||||
.maxPlayers(maxPlayers())
|
||||
.proxyHost(proxyHost())
|
||||
.proxyPort(proxyPort())
|
||||
.players(players())
|
||||
.proxyVersion(proxyVersion())
|
||||
.plugins(plugins());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +187,7 @@ public final class QueryResponse {
|
||||
return false;
|
||||
}
|
||||
QueryResponse response = (QueryResponse) o;
|
||||
return currentPlayers == response.currentPlayers
|
||||
return onlinePlayers == response.onlinePlayers
|
||||
&& maxPlayers == response.maxPlayers
|
||||
&& proxyPort == response.proxyPort
|
||||
&& hostname.equals(response.hostname)
|
||||
@@ -202,9 +201,8 @@ public final class QueryResponse {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects
|
||||
.hash(hostname, gameVersion, map, currentPlayers, maxPlayers, proxyHost, proxyPort, players,
|
||||
proxyVersion, plugins);
|
||||
return Objects.hash(hostname, gameVersion, map, onlinePlayers, maxPlayers, proxyHost,
|
||||
proxyPort, players, proxyVersion, plugins);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +211,7 @@ public final class QueryResponse {
|
||||
+ "hostname='" + hostname + '\''
|
||||
+ ", gameVersion='" + gameVersion + '\''
|
||||
+ ", map='" + map + '\''
|
||||
+ ", currentPlayers=" + currentPlayers
|
||||
+ ", onlinePlayers=" + onlinePlayers
|
||||
+ ", maxPlayers=" + maxPlayers
|
||||
+ ", proxyHost='" + proxyHost + '\''
|
||||
+ ", proxyPort=" + proxyPort
|
||||
@@ -233,7 +231,7 @@ public final class QueryResponse {
|
||||
private @MonotonicNonNull String proxyHost;
|
||||
private @MonotonicNonNull String proxyVersion;
|
||||
|
||||
private int currentPlayers;
|
||||
private int onlinePlayers;
|
||||
private int maxPlayers;
|
||||
private int proxyPort;
|
||||
|
||||
@@ -275,12 +273,12 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the players that are currently claimed to be online.
|
||||
* @param currentPlayers a non-negative number representing all players online
|
||||
* @param players a non-negative number representing all players online
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder currentPlayers(int currentPlayers) {
|
||||
Preconditions.checkArgument(currentPlayers >= 0, "currentPlayers cannot be negative");
|
||||
this.currentPlayers = currentPlayers;
|
||||
public Builder onlinePlayers(int players) {
|
||||
Preconditions.checkArgument(players >= 0, "currentPlayers cannot be negative");
|
||||
this.onlinePlayers = players;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -338,7 +336,7 @@ public final class QueryResponse {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all players from the builder. This does not affect {@link #getCurrentPlayers()}.
|
||||
* Removes all players from the builder. This does not affect {@link #onlinePlayers()}.
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder clearPlayers() {
|
||||
@@ -397,7 +395,7 @@ public final class QueryResponse {
|
||||
Preconditions.checkNotNull(hostname, "hostname"),
|
||||
Preconditions.checkNotNull(gameVersion, "gameVersion"),
|
||||
Preconditions.checkNotNull(map, "map"),
|
||||
currentPlayers,
|
||||
onlinePlayers,
|
||||
maxPlayers,
|
||||
Preconditions.checkNotNull(proxyHost, "proxyHost"),
|
||||
proxyPort,
|
||||
|
||||
@@ -25,14 +25,14 @@ public interface RegisteredServer extends ChannelMessageSink, Audience {
|
||||
*
|
||||
* @return the server info
|
||||
*/
|
||||
ServerInfo getServerInfo();
|
||||
ServerInfo serverInfo();
|
||||
|
||||
/**
|
||||
* Returns a list of all the players currently connected to this server on this proxy.
|
||||
*
|
||||
* @return the players on this proxy
|
||||
*/
|
||||
Collection<Player> getPlayersConnected();
|
||||
Collection<Player> connectedPlayers();
|
||||
|
||||
/**
|
||||
* Attempts to ping the remote server and return the server list ping result.
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
package com.velocitypowered.api.proxy.server;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -33,11 +32,11 @@ public final class ServerInfo implements Comparable<ServerInfo> {
|
||||
this.address = Preconditions.checkNotNull(address, "address");
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
public final String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public final SocketAddress getAddress() {
|
||||
public final SocketAddress address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@@ -69,6 +68,6 @@ public final class ServerInfo implements Comparable<ServerInfo> {
|
||||
|
||||
@Override
|
||||
public int compareTo(ServerInfo o) {
|
||||
return this.name.compareTo(o.getName());
|
||||
return this.name.compareTo(o.name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,23 +56,23 @@ public final class ServerPing {
|
||||
this.modinfo = modinfo;
|
||||
}
|
||||
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public Optional<Players> getPlayers() {
|
||||
public Optional<Players> players() {
|
||||
return Optional.ofNullable(players);
|
||||
}
|
||||
|
||||
public Component getDescription() {
|
||||
public Component description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Optional<Favicon> getFavicon() {
|
||||
public Optional<Favicon> favicon() {
|
||||
return Optional.ofNullable(favicon);
|
||||
}
|
||||
|
||||
public Optional<ModInfo> getModinfo() {
|
||||
public Optional<ModInfo> modInfo() {
|
||||
return Optional.ofNullable(modinfo);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public final class ServerPing {
|
||||
if (players != null) {
|
||||
builder.onlinePlayers = players.online;
|
||||
builder.maximumPlayers = players.max;
|
||||
builder.samplePlayers.addAll(players.getSample());
|
||||
builder.samplePlayers.addAll(players.sample());
|
||||
} else {
|
||||
builder.nullOutPlayers = true;
|
||||
}
|
||||
@@ -319,11 +319,11 @@ public final class ServerPing {
|
||||
this.name = Preconditions.checkNotNull(name, "name");
|
||||
}
|
||||
|
||||
public int getProtocol() {
|
||||
public int protocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -371,15 +371,15 @@ public final class ServerPing {
|
||||
this.sample = ImmutableList.copyOf(sample);
|
||||
}
|
||||
|
||||
public int getOnline() {
|
||||
public int online() {
|
||||
return online;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
public int maximum() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public List<SamplePlayer> getSample() {
|
||||
public List<SamplePlayer> sample() {
|
||||
return sample == null ? ImmutableList.of() : sample;
|
||||
}
|
||||
|
||||
@@ -421,11 +421,11 @@ public final class ServerPing {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
public UUID id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user