3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

Even more renames, start hiding some API internals

Dieser Commit ist enthalten in:
Andrew Steinborn 2023-10-29 15:23:01 -04:00
Ursprung 95cd4c407d
Commit 6f88c02c72
163 geänderte Dateien mit 682 neuen und 848 gelöschten Zeilen

Datei anzeigen

@ -3,20 +3,20 @@
name: Java CI with Gradle
on: [push, pull_request]
on: [ push, pull_request ]
jobs:
build-17:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build

Datei anzeigen

@ -18,7 +18,7 @@ Velocity is licensed under the GPLv3 license.
* First-class support for Paper, Sponge, Fabric and Forge. (Other implementations
may work, but we make every endeavor to support these server implementations
specifically.)
## Building
Velocity is built with [Gradle](https://gradle.org). We recommend using the

Datei anzeigen

@ -52,12 +52,12 @@ tasks {
o.source = "8"
o.links(
"https://www.slf4j.org/apidocs/",
"https://guava.dev/releases/${libs.guava.get().version}/api/docs/",
"https://google.github.io/guice/api-docs/${libs.guice.get().version}/javadoc/",
"https://docs.oracle.com/en/java/javase/11/docs/api/",
"https://jd.advntr.dev/api/${libs.adventure.bom.get().version}/",
"https://javadoc.io/doc/com.github.ben-manes.caffeine/caffeine"
"https://www.slf4j.org/apidocs/",
"https://guava.dev/releases/${libs.guava.get().version}/api/docs/",
"https://google.github.io/guice/api-docs/${libs.guice.get().version}/javadoc/",
"https://docs.oracle.com/en/java/javase/11/docs/api/",
"https://jd.advntr.dev/api/${libs.adventure.bom.get().version}/",
"https://javadoc.io/doc/com.github.ben-manes.caffeine/caffeine"
)
// Disable the crazy super-strict doclint tool in Java 8

Datei anzeigen

@ -12,22 +12,20 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.tree.LiteralCommandNode;
/**
* A command that uses Brigadier for parsing the command and
* providing suggestions to the client.
* A command that uses Brigadier for parsing the command and providing suggestions to the client.
*/
public final class BrigadierCommand implements Command {
/**
* The return code used by a {@link com.mojang.brigadier.Command} to indicate
* the command execution should be forwarded to the backend server.
* The return code used by a {@link com.mojang.brigadier.Command} to indicate the command
* execution should be forwarded to the backend server.
*/
public static final int FORWARD = 0xF6287429;
private final LiteralCommandNode<CommandSource> node;
/**
* Constructs a {@link BrigadierCommand} from the node returned by
* the given builder.
* Constructs a {@link BrigadierCommand} from the node returned by the given builder.
*
* @param builder the {@link LiteralCommandNode} builder
*/

Datei anzeigen

@ -7,11 +7,11 @@
package com.velocitypowered.api.command;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
/**
* Represents a command that can be executed by a {@link CommandSource}
* such as a {@link Player} or the console.
* Represents a command that can be executed by a {@link CommandSource} such as a {@link Player} or
* the console.
*
* <p><strong>You must not subclass <code>Command</code></strong>. Use one of the following
* <i>registrable</i> subinterfaces:</p>
@ -30,4 +30,5 @@ import com.velocitypowered.api.proxy.Player;
* </ul>
*/
public interface Command {
}

Datei anzeigen

@ -18,8 +18,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public interface CommandManager {
/**
* Returns a builder to create a {@link CommandMeta} with
* the given alias.
* Returns a builder to create a {@link CommandMeta} with the given alias.
*
* @param alias the first command alias
* @return a {@link CommandMeta} builder
@ -27,8 +26,7 @@ public interface CommandManager {
CommandMeta.Builder buildMeta(String alias);
/**
* Returns a builder to create a {@link CommandMeta} for
* the given Brigadier command.
* Returns a builder to create a {@link CommandMeta} for the given Brigadier command.
*
* @param command the command
* @return a {@link CommandMeta} builder
@ -38,11 +36,12 @@ public interface CommandManager {
/**
* Registers the specified command with the specified aliases.
*
* @param alias the first command alias
* @param command the command to register
* @param alias the first command alias
* @param command the command to register
* @param otherAliases additional aliases
* @throws IllegalArgumentException if one of the given aliases is already registered, or
* the given command does not implement a registrable {@link Command} subinterface
* @throws IllegalArgumentException if one of the given aliases is already registered, or the
* given command does not implement a registrable {@link Command}
* subinterface
* @see Command for a list of registrable subinterfaces
*/
default void register(String alias, Command command, String... otherAliases) {
@ -60,10 +59,11 @@ public interface CommandManager {
/**
* Registers the specified command with the given metadata.
*
* @param meta the command metadata
* @param meta the command metadata
* @param command the command to register
* @throws IllegalArgumentException if one of the given aliases is already registered, or
* the given command does not implement a registrable {@link Command} subinterface
* @throws IllegalArgumentException if one of the given aliases is already registered, or the
* given command does not implement a registrable {@link Command}
* subinterface
* @see Command for a list of registrable subinterfaces
*/
void register(CommandMeta meta, Command command);
@ -93,27 +93,26 @@ public interface CommandManager {
/**
* Attempts to asynchronously execute a command from the given {@code cmdLine}.
*
* @param source the source to execute the command for
* @param source the source to execute the command for
* @param cmdLine the command to run
* @return a future that may be completed with the result of the command execution.
* Can be completed exceptionally if an exception is thrown during execution.
* @return a future that may be completed with the result of the command execution. Can be
* completed exceptionally if an exception is thrown during execution.
*/
CompletableFuture<Boolean> executeAsync(CommandSource source, String cmdLine);
/**
* Attempts to asynchronously execute a command from the given {@code cmdLine}
* without firing a {@link CommandExecuteEvent}.
* Attempts to asynchronously execute a command from the given {@code cmdLine} without firing a
* {@link CommandExecuteEvent}.
*
* @param source the source to execute the command for
* @param source the source to execute the command for
* @param cmdLine the command to run
* @return a future that may be completed with the result of the command execution.
* Can be completed exceptionally if an exception is thrown during execution.
* @return a future that may be completed with the result of the command execution. Can be
* completed exceptionally if an exception is thrown during execution.
*/
CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine);
/**
* Returns an immutable collection of the case-insensitive aliases registered
* on this manager.
* Returns an immutable collection of the case-insensitive aliases registered on this manager.
*
* @return the registered aliases
*/

Datei anzeigen

@ -17,25 +17,25 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public interface CommandMeta {
/**
* Returns a non-empty collection containing the case-insensitive aliases
* used to execute the command.
* Returns a non-empty collection containing the case-insensitive aliases used to execute the
* command.
*
* @return the command aliases
*/
Collection<String> aliases();
/**
* Returns an immutable collection containing command nodes that provide
* additional argument metadata and tab-complete suggestions.
* Note some {@link Command} implementations may not support hinting.
* Returns an immutable collection containing command nodes that provide additional argument
* metadata and tab-complete suggestions. Note some {@link Command} implementations may not
* support hinting.
*
* @return the hinting command nodes
*/
Collection<CommandNode<CommandSource>> hints();
/**
* Returns the plugin who registered the command.
* Note some {@link Command} registrations may not provide this information.
* Returns the plugin who registered the command. Note some {@link Command} registrations may not
* provide this information.
*
* @return the registering plugin
*/
@ -55,13 +55,13 @@ public interface CommandMeta {
Builder aliases(String... aliases);
/**
* Specifies a command node providing additional argument metadata and
* tab-complete suggestions.
* Specifies a command node providing additional argument metadata and tab-complete
* suggestions.
*
* @param node the command node
* @return this builder, for chaining
* @throws IllegalArgumentException if the node is executable, i.e. has a non-null
* {@link com.mojang.brigadier.Command}, or has a redirect.
* {@link com.mojang.brigadier.Command}, or has a redirect.
*/
Builder hint(CommandNode<CommandSource> node);

Datei anzeigen

@ -15,9 +15,8 @@ import java.util.concurrent.CompletableFuture;
* A command that can be executed with arbitrary arguments.
*
* <p>Modifying the command tree (e.g. registering a command via
* {@link CommandManager#register(CommandMeta, Command)}) during
* permission checking and suggestions provision results in
* undefined behavior, which may include deadlocks.
* {@link CommandManager#register(CommandMeta, Command)}) during permission checking and suggestions
* provision results in undefined behavior, which may include deadlocks.
*
* @param <I> the type of the command invocation object
*/

Datei anzeigen

@ -8,9 +8,9 @@
package com.velocitypowered.api.command;
/**
* A specialized sub-interface of {@code Command} which indicates the proxy should pass
* the command and its arguments directly without further processing.
* This is useful for bolting on external command frameworks to Velocity.
* A specialized sub-interface of {@code Command} which indicates the proxy should pass the command
* and its arguments directly without further processing. This is useful for bolting on external
* command frameworks to Velocity.
*/
public interface RawCommand extends InvocableCommand<RawCommand.Invocation> {

Datei anzeigen

@ -10,8 +10,7 @@ package com.velocitypowered.api.command;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* A simple command, modelled after the convention popularized by
* Bukkit and BungeeCord.
* A simple command, modelled after the convention popularized by Bukkit and BungeeCord.
*
* <p>Prefer using {@link BrigadierCommand}, which is also
* backwards-compatible with older clients.

Datei anzeigen

@ -15,8 +15,8 @@ import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.jetbrains.annotations.NotNull;
/**
* Represents an implementation of brigadier's {@link Message}, providing support for {@link
* Component} messages.
* Represents an implementation of brigadier's {@link Message}, providing support for
* {@link Component} messages.
*/
public final class VelocityBrigadierMessage implements Message, ComponentLike {

Datei anzeigen

@ -8,8 +8,8 @@
package com.velocitypowered.api.event;
/**
* Represents a continuation of a paused event handler. Any of the resume methods
* may only be called once otherwise an {@link IllegalStateException} is expected.
* Represents a continuation of a paused event handler. Any of the resume methods may only be called
* once otherwise an {@link IllegalStateException} is expected.
*/
public interface Continuation {

Datei anzeigen

@ -15,36 +15,36 @@ import java.util.concurrent.CompletableFuture;
public interface EventManager {
/**
* Requests that the specified {@code listener} listen for events and associate it with the {@code
* plugin}.
* Requests that the specified {@code listener} listen for events and associate it with the
* {@code plugin}.
*
* @param plugin the plugin to associate with the listener
* @param plugin the plugin to associate with the listener
* @param listener the listener to register
*/
void register(Object plugin, Object listener);
/**
* Requests that the specified {@code handler} listen for events and associate it with the {@code
* plugin}.
* Requests that the specified {@code handler} listen for events and associate it with the
* {@code plugin}.
*
* @param plugin the plugin to associate with the handler
* @param plugin the plugin to associate with the handler
* @param eventClass the class for the event handler to register
* @param handler the handler to register
* @param <E> the event type to handle
* @param handler the handler to register
* @param <E> the event type to handle
*/
default <E> void register(Object plugin, Class<E> eventClass, EventHandler<E> handler) {
register(plugin, eventClass, PostOrder.NORMAL, handler);
}
/**
* Requests that the specified {@code handler} listen for events and associate it with the {@code
* plugin}.
* Requests that the specified {@code handler} listen for events and associate it with the
* {@code plugin}.
*
* @param plugin the plugin to associate with the handler
* @param plugin the plugin to associate with the handler
* @param eventClass the class for the event handler to register
* @param postOrder the order in which events should be posted to the handler
* @param handler the handler to register
* @param <E> the event type to handle
* @param postOrder the order in which events should be posted to the handler
* @param handler the handler to register
* @param <E> the event type to handle
*/
<E> void register(Object plugin, Class<E> eventClass, short postOrder,
EventHandler<E> handler);
@ -78,7 +78,7 @@ public interface EventManager {
/**
* Unregisters a specific listener for a specific plugin.
*
* @param plugin the plugin associated with the listener
* @param plugin the plugin associated with the listener
* @param listener the listener to deregister
*/
void unregisterListener(Object plugin, Object listener);
@ -86,9 +86,9 @@ public interface EventManager {
/**
* Unregisters a specific event handler for a specific plugin.
*
* @param plugin the plugin to associate with the handler
* @param plugin the plugin to associate with the handler
* @param handler the handler to register
* @param <E> the event type to handle
* @param <E> the event type to handle
*/
<E> void unregister(Object plugin, EventHandler<E> handler);
}

Datei anzeigen

@ -37,8 +37,8 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
interface Result {
/**
* Returns whether the event is allowed to proceed. Plugins may choose to skip denied
* events, and the proxy will respect the result of this method.
* Returns whether the event is allowed to proceed. Plugins may choose to skip denied events,
* and the proxy will respect the result of this method.
*
* @return whether the event is allowed to proceed
*/

Datei anzeigen

@ -34,9 +34,9 @@ public @interface Subscribe {
* not to enable it now. This option is being provided as a migration aid.</strong></p>
*
* <p>If this method returns {@code true}, the method is guaranteed to be executed
* 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>
* 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>

Datei anzeigen

@ -14,8 +14,8 @@ import java.lang.annotation.Target;
/**
* Marks an event as an event the proxy will wait on to completely fire (including any
* {@link com.velocitypowered.api.event.EventTask}s) before continuing handling it. Annotated
* classes are suitable candidates for using EventTasks for handling complex asynchronous
* operations in a non-blocking matter.
* classes are suitable candidates for using EventTasks for handling complex asynchronous operations
* in a non-blocking matter.
*/
@Target(ElementType.TYPE)
@Documented

Datei anzeigen

@ -31,7 +31,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
* Constructs a CommandExecuteEvent.
*
* @param commandSource the source executing the command
* @param command the command being executed without first slash
* @param command the command being executed without first slash
*/
public CommandExecuteEvent(CommandSource commandSource, String command) {
this.commandSource = Preconditions.checkNotNull(commandSource, "commandSource");
@ -127,8 +127,8 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
}
/**
* Forwards the command to server instead of executing it on the proxy. This is the
* default behavior when a command is not registered on Velocity.
* Forwards the command to server instead of executing it on the proxy. This is the default
* behavior when a command is not registered on Velocity.
*
* @return the forward result
*/

Datei anzeigen

@ -13,13 +13,12 @@ import com.google.common.annotations.Beta;
import com.mojang.brigadier.tree.RootCommandNode;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.event.player.PlayerReferentEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
/**
* Allows plugins to modify the packet indicating commands available on the server to a
* Minecraft 1.13+ client. The given {@link RootCommandNode} is mutable. Velocity will wait
* for this event to finish firing before sending the list of available commands to the
* client.
* Allows plugins to modify the packet indicating commands available on the server to a Minecraft
* 1.13+ client. The given {@link RootCommandNode} is mutable. Velocity will wait for this event to
* finish firing before sending the list of available commands to the client.
*/
@AwaitingEvent
@Beta
@ -31,7 +30,7 @@ public class PlayerAvailableCommandsEvent implements PlayerReferentEvent {
/**
* Constructs an available commands event.
*
* @param player the targeted player
* @param player the targeted player
* @param rootNode the Brigadier root node
*/
public PlayerAvailableCommandsEvent(Player player,

Datei anzeigen

@ -8,12 +8,12 @@
package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.InboundConnection;
import com.velocitypowered.api.network.connection.InboundConnection;
/**
* This event is fired when a handshake is established between a client and the proxy.
* Velocity will fire this event asynchronously and will not wait for it to complete before
* handling the connection.
* This event is fired when a handshake is established between a client and the proxy. Velocity will
* fire this event asynchronously and will not wait for it to complete before handling the
* connection.
*/
public final class ConnectionHandshakeEvent {

Datei anzeigen

@ -9,19 +9,18 @@ package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
/**
* This event is fired when a player disconnects from the proxy. This operation can take place
* when the player disconnects due to normal network activity or when the proxy shuts down.
* Operations on the provided player, aside from basic data retrieval operations, may behave in
* undefined ways.
* This event is fired when a player disconnects from the proxy. This operation can take place when
* the player disconnects due to normal network activity or when the proxy shuts down. Operations on
* the provided player, aside from basic data retrieval operations, may behave in undefined ways.
*
* <p>
* Velocity typically fires this event asynchronously and does not wait for a response. However,
* it will wait for all {@link DisconnectEvent}s for every player on the proxy to fire
* successfully before the proxy shuts down. This event is the sole exception to the
* {@link AwaitingEvent} contract.
* Velocity typically fires this event asynchronously and does not wait for a response. However, it
* will wait for all {@link DisconnectEvent}s for every player on the proxy to fire successfully
* before the proxy shuts down. This event is the sole exception to the {@link AwaitingEvent}
* contract.
* </p>
*/
@AwaitingEvent

Datei anzeigen

@ -11,7 +11,7 @@ import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.event.player.PlayerReferentEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
/**
* This event is fired once the player has been authenticated, but before they connect to a server.

Datei anzeigen

@ -12,18 +12,19 @@ import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.network.connection.ServerConnection;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
import com.velocitypowered.api.proxy.player.Player;
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}). Velocity will wait on this event to finish
* firing before discarding the sent plugin message (if handled) or forwarding it to the server.
* This event is fired when a plugin message is sent to the proxy, either from a client
* ({@link Player}) or a server ({@link ServerConnection}). Velocity will wait on this event to
* finish firing before discarding the sent plugin message (if handled) or forwarding it to the
* server.
*/
@AwaitingEvent
public final class PluginMessageEvent implements ResultedEvent<PluginMessageEvent.ForwardResult> {
@ -37,10 +38,10 @@ public final class PluginMessageEvent implements ResultedEvent<PluginMessageEven
/**
* Creates a new instance.
*
* @param source the source of the plugin message
* @param target the destination of the plugin message
* @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
* @param data the payload of the plugin message
*/
public PluginMessageEvent(ChannelMessageSource source, ChannelMessageSink target,
ChannelIdentifier identifier, byte[] data) {

Datei anzeigen

@ -10,7 +10,7 @@ package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.event.player.PlayerReferentEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
/**
* This event is fired once the player has been fully initialized and is about to connect to their

Datei anzeigen

@ -10,7 +10,8 @@ package com.velocitypowered.api.event.connection;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.InboundConnection;
import com.velocitypowered.api.network.connection.InboundConnection;
import com.velocitypowered.api.network.connection.LoginPhaseConnection;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -23,9 +24,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* the login process.
*
* <p>
* As of Velocity 3.1.0, you may cast the {@link InboundConnection} to a
* {@link com.velocitypowered.api.proxy.LoginPhaseConnection} to allow a
* proxy plugin to send login plugin messages to the client.
* As of Velocity 3.1.0, you may cast the {@link InboundConnection} to a
* {@link LoginPhaseConnection} to allow a proxy plugin to send login plugin messages to the
* client.
* </p>
*/
@AwaitingEvent
@ -39,7 +40,7 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
* Creates a new instance.
*
* @param connection the connection logging into the proxy
* @param username the player's username
* @param username the player's username
*/
public PreLoginEvent(InboundConnection connection, String username) {
this.connection = Preconditions.checkNotNull(connection, "connection");

Datei anzeigen

@ -11,20 +11,21 @@ import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.permission.PermissionProvider;
import com.velocitypowered.api.permission.PermissionSubject;
import com.velocitypowered.api.proxy.player.Player;
import net.kyori.adventure.permission.PermissionChecker;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Called when a {@link PermissionSubject}'s permissions are being setup. This event is typically
* called for the {@link com.velocitypowered.api.proxy.ConsoleCommandSource} and any
* {@link com.velocitypowered.api.proxy.Player}s who join the proxy.
* called for the {@link com.velocitypowered.api.proxy.ConsoleCommandSource} and any {@link Player}s
* who join the proxy.
*
* <p>This event is only called once per subject, on initialisation.</p>
*
* <p>
* Velocity will wait for this event to finish firing before proceeding further with server
* startup (for the console command source) and logins (for players) but it is strongly
* recommended to minimize the amount of work that must be done in this event.
* Velocity will wait for this event to finish firing before proceeding further with server startup
* (for the console command source) and logins (for players) but it is strongly recommended to
* minimize the amount of work that must be done in this event.
* </p>
*/
@AwaitingEvent

Datei anzeigen

@ -9,7 +9,7 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.InboundConnection;
import com.velocitypowered.api.network.connection.InboundConnection;
import com.velocitypowered.api.util.GameProfile;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -19,9 +19,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* a user, i.e. skin replacement.
*
* <p>
* Velocity will wait for this event to finish firing before proceeding with the rest of the login
* process, but you should try to limit the work done in any event that fires during the login
* process.
* Velocity will wait for this event to finish firing before proceeding with the rest of the login
* process, but you should try to limit the work done in any event that fires during the login
* process.
* </p>
*/
@AwaitingEvent
@ -36,9 +36,9 @@ public final class GameProfileRequestEvent {
/**
* Creates a new instance.
*
* @param connection the connection connecting to the proxy
* @param connection the connection connecting to the proxy
* @param originalProfile the original {@link GameProfile} for the user
* @param onlineMode whether or not the user connected in online or offline mode
* @param onlineMode whether or not the user connected in online or offline mode
*/
public GameProfileRequestEvent(InboundConnection connection, GameProfile originalProfile,
boolean onlineMode) {

Datei anzeigen

@ -10,7 +10,7 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -19,9 +19,9 @@ 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). Velocity will wait on this
* event to finish firing before taking the specified action.
* 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). Velocity will wait on this event to
* finish firing before taking the specified action.
*/
@AwaitingEvent
public final class KickedFromServerEvent implements
@ -36,14 +36,14 @@ public final class KickedFromServerEvent implements
/**
* 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 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
* @param result the initial result
*/
public KickedFromServerEvent(Player player, RegisteredServer server,
@Nullable Component originalReason, boolean duringServerConnect,
@Nullable Component originalReason, boolean duringServerConnect,
ServerKickResult result) {
this.player = Preconditions.checkNotNull(player, "player");
this.server = Preconditions.checkNotNull(server, "server");
@ -88,7 +88,7 @@ public final class KickedFromServerEvent implements
*
* @return whether or not the player got kicked
* @deprecated {@link #kickedDuringServerConnect()} has a better name and reflects the actual
* result
* result
*/
@Deprecated
public boolean kickedDuringLogin() {
@ -161,11 +161,11 @@ public final class KickedFromServerEvent implements
}
/**
* Creates a new redirect result to forward the player to the specified {@code server}.
* The specified {@code message} will be sent to the player after the redirection.
* Use {@code Component.empty()} to skip sending any messages to the player.
* Creates a new redirect result to forward the player to the specified {@code server}. The
* specified {@code message} will be sent to the player after the redirection. Use
* {@code Component.empty()} to skip sending any messages to the player.
*
* @param server the server to send the player to
* @param server the server to send the player to
* @param message the message will be sent to the player after redirecting
* @return the redirect result
*/
@ -175,8 +175,8 @@ public final class KickedFromServerEvent implements
}
/**
* Creates a new redirect result to forward the player to the specified {@code server}.
* The kick reason will be displayed to the player
* Creates a new redirect result to forward the player to the specified {@code server}. The kick
* reason will be displayed to the player
*
* @param server the server to send the player to
* @return the redirect result

Datei anzeigen

@ -8,13 +8,13 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.player.Player;
import java.util.List;
/**
* This event is fired when a client ({@link Player}) sends a plugin message through the
* register channel. Velocity will not wait on this event to finish firing.
* This event is fired when a client ({@link Player}) sends a plugin message through the register
* channel. Velocity will not wait on this event to finish firing.
*/
public final class PlayerChannelRegisterEvent implements PlayerReferentEvent {
@ -37,8 +37,8 @@ public final class PlayerChannelRegisterEvent implements PlayerReferentEvent {
@Override
public String toString() {
return "PlayerChannelRegisterEvent{"
+ "player=" + player
+ ", channels=" + channels
+ '}';
+ "player=" + player
+ ", channels=" + channels
+ '}';
}
}

Datei anzeigen

@ -10,14 +10,14 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
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. Velocity will wait on this event
* to finish firing before forwarding it to the server, if the result allows it.
* This event is fired when a player types in a chat message. Velocity will wait on this event to
* finish firing before forwarding it to the server, if the result allows it.
*/
@AwaitingEvent
public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.ChatResult>,
@ -30,7 +30,7 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
/**
* Constructs a PlayerChatEvent.
*
* @param player the player sending the message
* @param player the player sending the message
* @param message the message being sent
*/
public PlayerChatEvent(Player player, String message) {

Datei anzeigen

@ -9,14 +9,14 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.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 the login process, and we need to choose the first server
* to connect to. Velocity will wait on this event to finish firing before initiating the connection
* Fired when a player has finished the login process, and we need to choose the first server to
* connect to. Velocity will wait on this event to finish firing before initiating the connection
* but you should try to limit the work done in this event. Failures will be handled by
* {@link KickedFromServerEvent} as normal.
*/
@ -29,7 +29,7 @@ public class PlayerChooseInitialServerEvent implements PlayerReferentEvent {
/**
* Constructs a PlayerChooseInitialServerEvent.
*
* @param player the player that was connected
* @param player the player that was connected
* @param initialServer the initial server selected, may be {@code null}
*/
public PlayerChooseInitialServerEvent(Player player, @Nullable RegisteredServer initialServer) {

Datei anzeigen

@ -8,13 +8,14 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
/**
* Fired when a {@link Player} sends the <code>minecraft:brand</code> plugin message. Velocity will
* not wait on the result of this event.
*/
public final class PlayerClientBrandEvent implements PlayerReferentEvent {
private final Player player;
private final String brand;
@ -22,7 +23,7 @@ public final class PlayerClientBrandEvent implements PlayerReferentEvent {
* Creates a new instance.
*
* @param player the {@link Player} of the sent client brand
* @param brand the sent client brand
* @param brand the sent client brand
*/
public PlayerClientBrandEvent(Player player, String brand) {
this.player = Preconditions.checkNotNull(player);
@ -41,9 +42,8 @@ public final class PlayerClientBrandEvent implements PlayerReferentEvent {
@Override
public String toString() {
return "PlayerClientBrandEvent{"
+ "player=" + player
+ ", brand='" + brand + '\''
+ '}';
+ "player=" + player
+ ", brand='" + brand + '\''
+ '}';
}
}

Datei anzeigen

@ -9,7 +9,7 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.util.ModInfo;
/**

Datei anzeigen

@ -7,7 +7,7 @@
package com.velocitypowered.api.event.player;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
/**
* Defines any event that refers to a player.

Datei anzeigen

@ -10,7 +10,7 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -67,8 +67,8 @@ public class PlayerResourcePackStatusEvent implements PlayerReferentEvent {
}
/**
* Gets whether or not to override the kick resulting from
* {@link ResourcePackInfo#required()} being true.
* Gets whether or not to override the kick resulting from {@link ResourcePackInfo#required()}
* being true.
*
* @return whether or not to overwrite the result
*/
@ -77,11 +77,10 @@ public class PlayerResourcePackStatusEvent implements PlayerReferentEvent {
}
/**
* Set to true to prevent {@link ResourcePackInfo#required()}
* from kicking the player.
* Overwriting this kick is only possible on versions older than 1.17,
* as the client or server will enforce this regardless. Cancelling the resulting
* kick-events will not prevent the player from disconnecting from the proxy.
* Set to true to prevent {@link ResourcePackInfo#required()} from kicking the player. Overwriting
* this kick is only possible on versions older than 1.17, as the client or server will enforce
* this regardless. Cancelling the resulting kick-events will not prevent the player from
* disconnecting from the proxy.
*
* @param overwriteKick whether or not to cancel the kick
* @throws IllegalArgumentException if the player version is 1.17 or newer
@ -89,7 +88,7 @@ public class PlayerResourcePackStatusEvent implements PlayerReferentEvent {
public void setOverwriteKick(boolean overwriteKick) {
Preconditions.checkArgument(player.protocolVersion()
.compareTo(ProtocolVersion.MINECRAFT_1_17) < 0,
"overwriteKick is not supported on 1.17 or newer");
"overwriteKick is not supported on 1.17 or newer");
this.overwriteKick = overwriteKick;
}

Datei anzeigen

@ -9,13 +9,13 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.player.PlayerSettings;
/**
* This event is fired when the client sends new client settings for the player. This event can
* and typically will be fired multiple times per connection. Velocity will not wait on this event
* to finish firing.
* This event is fired when the client sends new client settings for the player. This event can and
* typically will be fired multiple times per connection. Velocity will not wait on this event to
* finish firing.
*/
public final class PlayerSettingsChangedEvent implements PlayerReferentEvent {

Datei anzeigen

@ -9,7 +9,7 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -18,9 +18,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* connection to the previous server has been de-established.
*
* <p>
* <strong>Note</strong>: For historical reasons, Velocity does wait on this event to finish
* firing before continuing the server connection process. This behavior is
* <strong>deprecated</strong> and likely to be removed in Polymer.
* <strong>Note</strong>: For historical reasons, Velocity does wait on this event to finish
* firing before continuing the server connection process. This behavior is
* <strong>deprecated</strong> and likely to be removed in Polymer.
* </p>
*/
@AwaitingEvent
@ -33,8 +33,8 @@ public final class ServerConnectedEvent implements PlayerReferentEvent {
/**
* Constructs a ServerConnectedEvent.
*
* @param player the player that was connected
* @param server the server the player was connected to
* @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,

Datei anzeigen

@ -15,7 +15,7 @@ import com.google.common.io.ByteStreams;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.event.player.ServerLoginPluginMessageEvent.ResponseResult;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.network.connection.ServerConnection;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
@ -23,12 +23,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Fired when a server sends a login plugin message to the proxy. Plugins have the opportunity to
* respond to the messages as needed. Velocity will wait on this event to finish. The server will
* be responsible for continuing the login process once the server is satisfied with any login
* plugin responses sent by proxy plugins (or messages indicating a lack of response).
* respond to the messages as needed. Velocity will wait on this event to finish. The server will be
* responsible for continuing the login process once the server is satisfied with any login plugin
* responses sent by proxy plugins (or messages indicating a lack of response).
*/
@AwaitingEvent
public class ServerLoginPluginMessageEvent implements ResultedEvent<ResponseResult> {
private final ServerConnection connection;
private final ChannelIdentifier identifier;
private final byte[] contents;
@ -40,7 +41,7 @@ public class ServerLoginPluginMessageEvent implements ResultedEvent<ResponseResu
*
* @param connection the connection on which the plugin message was sent
* @param identifier the channel identifier for the message sent
* @param contents the contents of the message
* @param contents the contents of the message
* @param sequenceId the ID of the message
*/
public ServerLoginPluginMessageEvent(
@ -122,7 +123,7 @@ public class ServerLoginPluginMessageEvent implements ResultedEvent<ResponseResu
private static final ResponseResult UNKNOWN = new ResponseResult(null);
private final byte@Nullable [] response;
private final byte @Nullable [] response;
private ResponseResult(byte @Nullable [] response) {
this.response = response;

Datei anzeigen

@ -8,7 +8,7 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -18,6 +18,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* firing.
*/
public class ServerPostConnectEvent implements PlayerReferentEvent {
private final Player player;
private final RegisteredServer previousServer;
@ -38,7 +39,8 @@ public class ServerPostConnectEvent implements PlayerReferentEvent {
/**
* Returns the previous server the player was connected to. This is {@code null} if they were not
* connected to another server beforehand (for instance, if the player has just joined the proxy).
* connected to another server beforehand (for instance, if the player has just joined the
* proxy).
*
* @return the previous server the player was connected to
*/

Datei anzeigen

@ -10,10 +10,10 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.network.connection.ServerConnection;
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
import com.velocitypowered.api.proxy.ConnectionRequestBuilder.Status;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -34,7 +34,7 @@ public final class ServerPreConnectEvent implements
/**
* Creates the ServerPreConnectEvent.
*
* @param player the player who is connecting to a server
* @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) {
@ -45,7 +45,7 @@ public final class ServerPreConnectEvent implements
/**
* Creates the ServerPreConnectEvent.
*
* @param player the player who is connecting to a server
* @param player the player who is connecting to a server
* @param originalServer the server the player was trying to connect to
* @param previousServer the server the player is connected to
*/
@ -78,9 +78,9 @@ public final class ServerPreConnectEvent implements
}
/**
* 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 #getPreviousServer()}.
* 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 #getPreviousServer()}.
*
* @return the server that the player originally tried to connect to
*/

Datei anzeigen

@ -9,18 +9,18 @@ package com.velocitypowered.api.event.player;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.network.connection.ServerConnection;
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
/**
* This event is fired when the downstream server tries to send a player a ResourcePack packet.
* The proxy will wait on this event to finish before forwarding the resource pack to the user.
* If this event is denied, it will retroactively send a DENIED status to the downstream
* server in response.
* This event is fired when the downstream server tries to send a player a ResourcePack packet. The
* proxy will wait on this event to finish before forwarding the resource pack to the user. If this
* event is denied, it will retroactively send a DENIED status to the downstream server in response.
* If the downstream server has it set to "forced" it will forcefully disconnect the user.
*/
@AwaitingEvent
public class ServerResourcePackSendEvent implements ResultedEvent<ResultedEvent.GenericResult> {
private GenericResult result;
private final ResourcePackInfo receivedResourcePack;
private ResourcePackInfo providedResourcePack;
@ -30,7 +30,7 @@ public class ServerResourcePackSendEvent implements ResultedEvent<ResultedEvent.
* Constructs a new ServerResourcePackSendEvent.
*
* @param receivedResourcePack The resource pack the server sent.
* @param serverConnection The connection this occurred on.
* @param serverConnection The connection this occurred on.
*/
public ServerResourcePackSendEvent(
ResourcePackInfo receivedResourcePack,

Datei anzeigen

@ -10,19 +10,20 @@ package com.velocitypowered.api.event.player;
import static com.google.common.base.Preconditions.checkNotNull;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.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.
* Velocity will wait for this event to finish firing before sending the tab complete results to
* the client. Be sure to be as fast as possible, since the client will freeze while it waits for
* the tab complete results.
* Velocity will wait for this event to finish firing before sending the tab complete results to the
* client. Be sure to be as fast as possible, since the client will freeze while it waits for the
* tab complete results.
*/
@AwaitingEvent
public class TabCompleteEvent implements PlayerReferentEvent {
private final Player player;
private final String partialMessage;
private final List<String> suggestions;
@ -30,9 +31,9 @@ public class TabCompleteEvent implements PlayerReferentEvent {
/**
* Constructs a new TabCompleteEvent instance.
*
* @param player the player
* @param player the player
* @param partialMessage the partial message
* @param suggestions the initial list of suggestions
* @param suggestions the initial list of suggestions
*/
public TabCompleteEvent(Player player, String partialMessage, List<String> suggestions) {
this.player = checkNotNull(player, "player");

Datei anzeigen

@ -9,15 +9,15 @@ package com.velocitypowered.api.event.proxy;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.proxy.InboundConnection;
import com.velocitypowered.api.network.connection.InboundConnection;
import com.velocitypowered.api.proxy.server.ServerPing;
/**
* This event is fired when a request for server information is sent by a remote client, or when the
* server sends the MOTD and favicon to the client after a successful login. Velocity will
* wait on this event to finish firing before delivering the results to the remote client, but
* you are urged to handle this event as quickly as possible when handling this event due to the
* amount of ping packets a client can send.
* server sends the MOTD and favicon to the client after a successful login. Velocity will wait on
* this event to finish firing before delivering the results to the remote client, but you are urged
* to handle this event as quickly as possible when handling this event due to the amount of ping
* packets a client can send.
*/
@AwaitingEvent
public final class ProxyPingEvent {

Datei anzeigen

@ -26,9 +26,9 @@ public final class ProxyQueryEvent {
/**
* Creates a new event.
*
* @param queryType the type of query
* @param queryType the type of query
* @param querierAddress the remote address for the query
* @param response the current query response
* @param response the current query response
*/
public ProxyQueryEvent(QueryType queryType, InetAddress querierAddress, QueryResponse response) {
this.queryType = Preconditions.checkNotNull(queryType, "queryType");

Datei anzeigen

@ -153,7 +153,7 @@ public enum ProtocolVersion {
*
* @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.
* or @link{#getVersionsSupportedBy()} to get more accurate version names.
*/
@Deprecated
public String getName() {
@ -161,8 +161,7 @@ public enum ProtocolVersion {
}
/**
* Returns the user-friendly name of the version
* this protocol was introduced in.
* Returns the user-friendly name of the version this protocol was introduced in.
*
* @return the version name
*/
@ -171,8 +170,7 @@ public enum ProtocolVersion {
}
/**
* Returns the user-friendly name of the last
* version this protocol is valid for.
* Returns the user-friendly name of the last version this protocol is valid for.
*
* @return the version name
*/

Datei anzeigen

@ -5,7 +5,7 @@
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.proxy;
package com.velocitypowered.api.network.connection;
import com.velocitypowered.api.network.ProtocolVersion;
import java.net.InetSocketAddress;

Datei anzeigen

@ -5,26 +5,26 @@
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.proxy;
package com.velocitypowered.api.network.connection;
import com.velocitypowered.api.proxy.crypto.KeyIdentifiable;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Represents a connextion that is in the login phase. This is most useful in conjunction
* for login plugin messages.
* Represents a connextion that is in the login phase. This is most useful in conjunction for login
* plugin messages.
*/
public interface LoginPhaseConnection extends InboundConnection, KeyIdentifiable {
/**
* Sends a login plugin message to the client, and provides a consumer to react to the
* response to the client. The login process will not continue until there are no more
* login plugin messages that require responses.
* Sends a login plugin message to the client, and provides a consumer to react to the response to
* the client. The login process will not continue until there are no more login plugin messages
* that require responses.
*
* @param identifier the channel identifier to use
* @param contents the message to send
* @param consumer the consumer that will respond to the message
* @param contents the message to send
* @param consumer the consumer that will respond to the message
*/
void sendLoginPluginMessage(ChannelIdentifier identifier, byte[] contents,
MessageConsumer consumer);

Datei anzeigen

@ -5,10 +5,11 @@
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.proxy;
package com.velocitypowered.api.network.connection;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
import java.util.Optional;

Datei anzeigen

@ -21,8 +21,8 @@ public @interface Plugin {
/**
* The ID of the plugin. This ID should be unique as to not conflict with other plugins. The
* plugin ID may contain alphanumeric characters, dashes, and underscores, and be a maximum
* of 64 characters long.
* plugin ID may contain alphanumeric characters, dashes, and underscores, and be a maximum of 64
* characters long.
*
* @return the ID for this plugin
*/

Datei anzeigen

@ -32,8 +32,7 @@ public interface PluginContainer {
}
/**
* Returns an executor service for this plugin. The executor will use a cached
* thread pool.
* Returns an executor service for this plugin. The executor will use a cached thread pool.
*
* @return an {@link ExecutorService} associated with this plugin
*/

Datei anzeigen

@ -13,8 +13,8 @@ import java.util.Optional;
/**
* Manages plugins loaded on the proxy. This manager can retrieve {@link PluginContainer}s from
* plugin instances and inject arbitrary JAR files into the plugin classpath with {@link
* #addToClasspath(Object, Path)}.
* plugin instances and inject arbitrary JAR files into the plugin classpath with
* {@link #addToClasspath(Object, Path)}.
*/
public interface PluginManager {
@ -53,7 +53,7 @@ public interface PluginManager {
* Adds the specified {@code path} to the plugin classpath.
*
* @param plugin the plugin
* @param path the path to the JAR you want to inject into the classpath
* @param path the path to the JAR you want to inject into the classpath
* @throws UnsupportedOperationException if the operation is not applicable to this plugin
*/
void addToClasspath(Object plugin, Path path);

Datei anzeigen

@ -28,8 +28,8 @@ public final class PluginDependency {
/**
* Creates a new instance.
*
* @param id the plugin ID
* @param version an optional version
* @param id the plugin ID
* @param version an optional version
* @param optional whether or not this dependency is optional
*/
public PluginDependency(String id, @Nullable String version, boolean optional) {

Datei anzeigen

@ -7,6 +7,7 @@
package com.velocitypowered.api.proxy;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
@ -26,8 +27,8 @@ public interface ConnectionRequestBuilder {
RegisteredServer server();
/**
* Initiates the connection to the remote server and emits a result on the {@link
* CompletableFuture} after the user has logged on. No messages will be communicated to the
* Initiates the connection to the remote server and emits a result on the
* {@link CompletableFuture} after the user has logged on. No messages will be communicated to the
* client: the user is responsible for all error handling.
*
* @return a {@link CompletableFuture} representing the status of this connection
@ -35,9 +36,9 @@ public interface ConnectionRequestBuilder {
CompletableFuture<Result> connect();
/**
* Initiates the connection to the remote server and emits a result on the {@link
* CompletableFuture} after the user has logged on. Velocity's own built-in handling will be used
* to provide errors to the client.
* Initiates the connection to the remote server and emits a result on the
* {@link CompletableFuture} after the user has logged on. Velocity's own built-in handling will
* be used to provide errors to the client.
*
* @return a {@link CompletableFuture} representing the status of this connection
*/

Datei anzeigen

@ -13,4 +13,5 @@ import com.velocitypowered.api.command.CommandSource;
* Indicates that the executor of the command is the console.
*/
public interface ConsoleCommandSource extends CommandSource {
}

Datei anzeigen

@ -13,6 +13,7 @@ import com.velocitypowered.api.event.EventManager;
import com.velocitypowered.api.plugin.PluginManager;
import com.velocitypowered.api.proxy.config.ProxyConfig;
import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
@ -42,8 +43,8 @@ public interface ProxyServer extends Audience {
void shutdown();
/**
* Closes all listening endpoints for this server.
* This includes the main minecraft listener and query channel.
* Closes all listening endpoints for this server. This includes the main minecraft listener and
* query channel.
*/
void closeListeners();
@ -203,20 +204,19 @@ public interface ProxyServer extends Audience {
/**
* Creates a builder to build a {@link ResourcePackInfo} instance for use with
* {@link com.velocitypowered.api.proxy.Player#sendResourcePackOffer(ResourcePackInfo)}.
* {@link Player#sendResourcePackOffer(ResourcePackInfo)}.
*
* <p>Note: The resource-pack location should always:
* - Use HTTPS with a valid certificate.
* - Be in a crawler-accessible location. Having it behind Cloudflare or other DoS/Bot/crawler
* protection may cause issues in downloading.
* - Be on a web-server with enough bandwidth and reliable connection
* so the download does not time out or fail.</p>
* - Use HTTPS with a valid certificate. - Be in a crawler-accessible location. Having it behind
* Cloudflare or other DoS/Bot/crawler protection may cause issues in downloading. - Be on a
* web-server with enough bandwidth and reliable connection so the download does not time out or
* fail.</p>
*
* <p>Do also make sure that the resource pack is in the correct format for the version
* of the client. It is also highly recommended to always provide the resource-pack SHA-1 hash
* of the resource pack with {@link ResourcePackInfo.Builder#hash(byte[])}
* whenever possible to save bandwidth. If a hash is present the client will first check
* if it already has a resource pack by that hash cached.</p>
* of the client. It is also highly recommended to always provide the resource-pack SHA-1 hash of
* the resource pack with {@link ResourcePackInfo.Builder#hash(byte[])} whenever possible to save
* bandwidth. If a hash is present the client will first check if it already has a resource pack
* by that hash cached.</p>
*
* @param url The url where the resource pack can be found
* @return a ResourcePackInfo builder

Datei anzeigen

@ -70,9 +70,9 @@ public interface ProxyConfig {
boolean isOnlineMode();
/**
* If client's ISP/AS sent from this proxy is different from the one from Mojang's
* authentication server, the player is kicked. This disallows some VPN and proxy
* connections but is a weak form of protection.
* If client's ISP/AS sent from this proxy is different from the one from Mojang's authentication
* server, the player is kicked. This disallows some VPN and proxy connections but is a weak form
* of protection.
*
* @return whether to prevent client proxy connections by checking the IP with Mojang servers
*/

Datei anzeigen

@ -20,8 +20,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public interface IdentifiedKey extends KeySigned {
/**
* Returns RSA public key.
* Note: this key is at least 2048 bits but may be larger.
* Returns RSA public key. Note: this key is at least 2048 bits but may be larger.
*
* @return the RSA public key in question
*/
@ -32,15 +31,14 @@ public interface IdentifiedKey extends KeySigned {
* Validates a signature against this public key.
*
* @param signature the signature data
* @param toVerify the signed data
*
* @param toVerify the signed data
* @return validity of the signature
*/
boolean verifyDataSignature(byte[] signature, byte[]... toVerify);
/**
* Retrieves the signature holders UUID.
* Returns null before the {@link com.velocitypowered.api.event.connection.LoginEvent}.
* Retrieves the signature holders UUID. Returns null before the
* {@link com.velocitypowered.api.event.connection.LoginEvent}.
*
* @return the holder UUID or null if not present
*/
@ -68,11 +66,11 @@ public interface IdentifiedKey extends KeySigned {
this.backwardsCompatibleTo = backwardsCompatibleTo;
this.applicableTo = applicableTo;
}
public Set<Revision> backwardsCompatibleTo() {
return backwardsCompatibleTo;
}
public Set<ProtocolVersion> applicableTo() {
return applicableTo;
}

Datei anzeigen

@ -15,8 +15,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public interface KeyIdentifiable {
/**
* Returns the timed identified key of the object context. This is only available if the client
* is running Minecraft 1.19 or newer.
* Returns the timed identified key of the object context. This is only available if the client is
* running Minecraft 1.19 or newer.
*
* @return the key or null if not available
*/

Datei anzeigen

@ -25,10 +25,8 @@ public interface KeySigned {
PublicKey signer();
/**
* Returns the expiry time point of the key.
* Note: this limit is arbitrary. RSA keys don't expire,
* but the signature of this key as provided by the session
* server will expire.
* Returns the expiry time point of the key. Note: this limit is arbitrary. RSA keys don't expire,
* but the signature of this key as provided by the session server will expire.
*
* @return the expiry time point
*/
@ -53,9 +51,8 @@ public interface KeySigned {
byte[] signature();
/**
* Validates the signature, expiry temporal and key against the
* signer public key. Note: This will **not** check for
* expiry. You can check for expiry with {@link KeySigned#hasExpired()}.
* Validates the signature, expiry temporal and key against the signer public key. Note: This will
* **not** check for expiry. You can check for expiry with {@link KeySigned#hasExpired()}.
* <p>DOES NOT WORK YET FOR MESSAGES AND COMMANDS!</p>
* Addendum: Does not work for 1.19.1 until the user has authenticated.
*

Datei anzeigen

@ -7,6 +7,8 @@
package com.velocitypowered.api.proxy.messages;
import net.kyori.adventure.key.Key;
/**
* Represents a channel identifier for use with plugin messaging.
*/
@ -18,4 +20,27 @@ public interface ChannelIdentifier {
* @return the textual representation of the identifier
*/
String id();
/**
* Returns a channel identifier to identify a channel for Minecraft clients older than Minecraft
* 1.13.
*
* @param name the channel name to use
* @return the channel identifier with the given name
*/
static ChannelIdentifier legacy(String name) {
return new LegacyChannelIdentifier(name);
}
/**
* Returns a channel identifier to identify a channel for Minecraft clients newer or equal to
* Minecraft 1.13. This uses a Minecraft resource code of the form {@code namespace:name}.
*
* @param key the channel name to use
* @return the channel identifier with the given name
*/
static ChannelIdentifier ofKey(Key key) {
return new MinecraftChannelIdentifier(key);
}
}

Datei anzeigen

@ -16,7 +16,7 @@ public interface ChannelMessageSink {
* Sends a plugin message to this target.
*
* @param identifier the channel identifier to send the message on
* @param data the data to send
* @param data the data to send
* @return whether or not the message could be sent
*/
boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data);

Datei anzeigen

@ -17,7 +17,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* messages, please see {@link MinecraftChannelIdentifier}. This class is immutable and safe for
* multi-threaded use.
*/
public final class LegacyChannelIdentifier implements ChannelIdentifier {
final class LegacyChannelIdentifier implements ChannelIdentifier {
private final String name;
@ -26,7 +26,7 @@ public final class LegacyChannelIdentifier implements ChannelIdentifier {
*
* @param name the name for the channel
*/
public LegacyChannelIdentifier(String name) {
LegacyChannelIdentifier(String name) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "provided name is empty");
this.name = name;
}
@ -54,7 +54,7 @@ public final class LegacyChannelIdentifier implements ChannelIdentifier {
@Override
public int hashCode() {
return Objects.hash(name);
return name.hashCode();
}
@Override

Datei anzeigen

@ -7,11 +7,7 @@
package com.velocitypowered.api.proxy.messages;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.base.Strings;
import java.util.Objects;
import java.util.regex.Pattern;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -19,94 +15,17 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* Represents a Minecraft 1.13+ channel identifier. This class is immutable and safe for
* multi-threaded use.
*/
public final class MinecraftChannelIdentifier implements ChannelIdentifier {
final class MinecraftChannelIdentifier implements ChannelIdentifier {
private static final Pattern VALID_IDENTIFIER_REGEX = Pattern.compile("[a-z0-9/\\-_]*");
private final Key key;
private final String namespace;
private final String name;
private MinecraftChannelIdentifier(String namespace, String name) {
this.namespace = namespace;
this.name = name;
}
/**
* Creates an identifier in the default namespace ({@code minecraft}). Plugins are strongly
* encouraged to provide their own namespace.
*
* @param name the name in the default namespace to use
* @return a new channel identifier
*/
public static MinecraftChannelIdentifier forDefaultNamespace(String name) {
return new MinecraftChannelIdentifier("minecraft", name);
}
/**
* Creates an identifier in the specified namespace.
*
* @param namespace the namespace to use
* @param name the channel name inside the specified namespace
* @return a new channel identifier
*/
public static MinecraftChannelIdentifier create(String namespace, String name) {
checkArgument(!Strings.isNullOrEmpty(namespace), "namespace is null or empty");
checkArgument(name != null, "namespace is null or empty");
checkArgument(VALID_IDENTIFIER_REGEX.matcher(namespace).matches(),
"namespace is not valid, must match: %s got %s",
VALID_IDENTIFIER_REGEX.toString(),
namespace);
checkArgument(VALID_IDENTIFIER_REGEX.matcher(name).matches(),
"name is not valid, must match: %s got %s",
VALID_IDENTIFIER_REGEX.toString(),
name);
return new MinecraftChannelIdentifier(namespace, name);
}
/**
* Creates an channel identifier from the specified Minecraft identifier.
*
* @param identifier the Minecraft identifier
* @return a new channel identifier
*/
public static MinecraftChannelIdentifier from(String identifier) {
int colonPos = identifier.indexOf(':');
if (colonPos == -1) {
throw new IllegalArgumentException("Identifier does not contain a colon.");
}
if (colonPos + 1 == identifier.length()) {
throw new IllegalArgumentException("Identifier is empty.");
}
String namespace = identifier.substring(0, colonPos);
String name = identifier.substring(colonPos + 1);
return create(namespace, name);
}
/**
* Creates an channel identifier from the specified Minecraft identifier.
*
* @param key the Minecraft key to use
* @return a new channel identifier
*/
public static MinecraftChannelIdentifier from(Key key) {
return create(key.namespace(), key.value());
}
public String getNamespace() {
return namespace;
}
public String getName() {
return name;
}
public Key asKey() {
return Key.key(namespace, name);
MinecraftChannelIdentifier(Key key) {
this.key = key;
}
@Override
public String toString() {
return namespace + ":" + name + " (modern)";
return this.key.asString() + " (modern)";
}
@Override
@ -118,17 +37,16 @@ public final class MinecraftChannelIdentifier implements ChannelIdentifier {
return false;
}
MinecraftChannelIdentifier that = (MinecraftChannelIdentifier) o;
return Objects.equals(namespace, that.namespace)
&& Objects.equals(name, that.name);
return Objects.equals(key, that.key);
}
@Override
public int hashCode() {
return Objects.hash(namespace, name);
return key.hashCode();
}
@Override
public String id() {
return namespace + ":" + name;
return key.asString();
}
}

Datei anzeigen

@ -14,6 +14,7 @@ import java.util.UUID;
* Represents a chat session held by a player.
*/
public interface ChatSession extends KeyIdentifiable {
/**
* Returns the {@link UUID} of the session.
*

Datei anzeigen

@ -5,17 +5,18 @@
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.proxy;
package com.velocitypowered.api.proxy.player;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
import com.velocitypowered.api.network.connection.InboundConnection;
import com.velocitypowered.api.network.connection.ServerConnection;
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.crypto.KeyIdentifiable;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
import com.velocitypowered.api.proxy.player.PlayerSettings;
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
import com.velocitypowered.api.proxy.player.TabList;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.api.util.ModInfo;
@ -186,19 +187,17 @@ public interface Player extends
void spoofChatInput(String input);
/**
* Queues and sends a new Resource-pack offer to the player.
* To monitor the status of the sent resource pack, subscribe to
* {@link PlayerResourcePackStatusEvent}.
* To create a {@link ResourcePackInfo} use the
* {@link ProxyServer#createResourcePackBuilder(String)} builder.
* Queues and sends a new Resource-pack offer to the player. To monitor the status of the sent
* resource pack, subscribe to {@link PlayerResourcePackStatusEvent}. To create a
* {@link ResourcePackInfo} use the {@link ProxyServer#createResourcePackBuilder(String)}
* builder.
*
* @param packInfo the resource-pack in question
*/
void sendResourcePackOffer(ResourcePackInfo packInfo);
/**
* Gets the {@link ResourcePackInfo} of the currently applied
* resource-pack or null if none.
* Gets the {@link ResourcePackInfo} of the currently applied resource-pack or null if none.
*
* @return the applied resource pack or null if none.
*/
@ -206,9 +205,8 @@ public interface Player extends
ResourcePackInfo appliedResourcePack();
/**
* Gets the {@link ResourcePackInfo} of the resource pack
* the user is currently downloading or is currently
* prompted to install or null if none.
* Gets the {@link ResourcePackInfo} of the resource pack the user is currently downloading or is
* currently prompted to install or null if none.
*
* @return the pending resource pack or null if none
*/
@ -217,9 +215,9 @@ public interface Player extends
/**
* <strong>Note that this method does not send a plugin message to the server the player
* is connected to.</strong> You should only use this method if you are trying to communicate
* with a mod that is installed on the player's client. To send a plugin message to the server
* from the player, you should use the equivalent method on the instance returned by
* is connected to.</strong> You should only use this method if you are trying to communicate with
* a mod that is installed on the player's client. To send a plugin message to the server from the
* player, you should use the equivalent method on the instance returned by
* {@link #connectedServer()}.
*
* @inheritDoc
@ -234,9 +232,9 @@ public interface Player extends
@Override
default @NotNull HoverEvent<HoverEvent.ShowEntity> asHoverEvent(
@NotNull UnaryOperator<HoverEvent.ShowEntity> op) {
@NotNull UnaryOperator<HoverEvent.ShowEntity> op) {
return HoverEvent.showEntity(op.apply(HoverEvent.ShowEntity.showEntity(this, uuid(),
Component.text(username()))));
Component.text(username()))));
}

Datei anzeigen

@ -59,9 +59,8 @@ public interface PlayerSettings {
/**
* Returns whether the client explicitly allows listing on the
* {@link com.velocitypowered.api.proxy.player.TabList} or not in
* anonymous TabList mode.
* This feature was introduced in 1.18.
* {@link com.velocitypowered.api.proxy.player.TabList} or not in anonymous TabList mode. This
* feature was introduced in 1.18.
*
* @return whether or not the client explicitly allows listing. Always false on older clients.
*/

Datei anzeigen

@ -23,8 +23,8 @@ public interface ResourcePackInfo {
String url();
/**
* Gets the {@link Component} that is displayed on the resource-pack prompt.
* This is only displayed if the client version is 1.17 or newer.
* Gets the {@link Component} that is displayed on the resource-pack prompt. This is only
* displayed if the client version is 1.17 or newer.
*
* @return the prompt if present or null otherwise
*/
@ -32,16 +32,16 @@ public interface ResourcePackInfo {
Component prompt();
/**
* Gets whether or not the acceptance of the resource-pack is enforced.
* See {@link Builder#required(boolean)} for more information.
* Gets whether or not the acceptance of the resource-pack is enforced. See
* {@link Builder#required(boolean)} for more information.
*
* @return whether or not to force usage of this resource-pack
*/
boolean required();
/**
* Gets the SHA-1 hash of the resource-pack
* See {@link Builder#hash(byte[])} for more information.
* Gets the SHA-1 hash of the resource-pack See {@link Builder#hash(byte[])} for more
* information.
*
* @return the hash if present or null otherwise
*/
@ -56,8 +56,8 @@ public interface ResourcePackInfo {
Origin origin();
/**
* Gets the original {@link Origin} of the resource-pack.
* The original origin may differ if the resource pack was altered in the event
* Gets the original {@link Origin} of the resource-pack. The original origin may differ if the
* resource pack was altered in the event
* {@link com.velocitypowered.api.event.player.ServerResourcePackSendEvent}.
*
* @return the origin of the resource pack
@ -65,12 +65,11 @@ public interface ResourcePackInfo {
Origin originalOrigin();
/**
* Returns a copy of this {@link ResourcePackInfo} instance as a builder so that it can
* be modified.
* It is <b>not</b> guaranteed that
* Returns a copy of this {@link ResourcePackInfo} instance as a builder so that it can be
* modified. It is <b>not</b> guaranteed that
* {@code resourcePackInfo.asBuilder().build().equals(resourcePackInfo)} is true. That is due to
* the transient {@link ResourcePackInfo#origin()} and
* {@link ResourcePackInfo#originalOrigin()} fields.
* the transient {@link ResourcePackInfo#origin()} and {@link ResourcePackInfo#originalOrigin()}
* fields.
*
* @return a content-copy of this instance as a {@link ResourcePackInfo.Builder}
*/
@ -85,7 +84,6 @@ public interface ResourcePackInfo {
* {@link ResourcePackInfo#originalOrigin()} fields are transient.
*
* @param newUrl The new URL to use in the updated builder.
*
* @return a content-copy of this instance as a {@link ResourcePackInfo.Builder}
*/
ResourcePackInfo.Builder asBuilder(String newUrl);
@ -96,40 +94,34 @@ public interface ResourcePackInfo {
interface Builder {
/**
* Sets the resource-pack as required to play on the network.
* This feature was introduced in 1.17.
* Setting this to true has one of two effects:
* If the client is on 1.17 or newer:
* - The resource-pack prompt will display without a decline button
* - Accept or disconnect are the only available options but players may still press escape.
* - Forces the resource-pack offer prompt to display even if the player has
* previously declined or disabled resource packs
* - The player will be disconnected from the network if they close/skip the prompt.
* If the client is on a version older than 1.17:
* - If the player accepts the resource pack or has previously accepted a resource-pack
* then nothing else will happen.
* - If the player declines the resource pack or has previously declined a resource-pack
* the player will be disconnected from the network
* Sets the resource-pack as required to play on the network. This feature was introduced in
* 1.17. Setting this to true has one of two effects: If the client is on 1.17 or newer: - The
* resource-pack prompt will display without a decline button - Accept or disconnect are the
* only available options but players may still press escape. - Forces the resource-pack offer
* prompt to display even if the player has previously declined or disabled resource packs - The
* player will be disconnected from the network if they close/skip the prompt. If the client is
* on a version older than 1.17: - If the player accepts the resource pack or has previously
* accepted a resource-pack then nothing else will happen. - If the player declines the resource
* pack or has previously declined a resource-pack the player will be disconnected from the
* network
*
* @param shouldForce whether or not to force the client to accept the resource pack
*/
Builder required(boolean shouldForce);
/**
* Sets the SHA-1 hash of the provided resource pack.
* Note: It is recommended to always set this hash.
* If this hash is not set/ not present then the client will always download
* the resource pack even if it may still be cached. By having this hash present,
* the client will check first whether or not a resource pack by this hash is cached
* before downloading.
* Sets the SHA-1 hash of the provided resource pack. Note: It is recommended to always set this
* hash. If this hash is not set/ not present then the client will always download the resource
* pack even if it may still be cached. By having this hash present, the client will check first
* whether or not a resource pack by this hash is cached before downloading.
*
* @param hash the SHA-1 hash of the resource-pack
*/
Builder hash(@Nullable byte[] hash);
/**
* Sets a {@link Component} to display on the download prompt.
* This will only display if the client version is 1.17 or newer.
* Sets a {@link Component} to display on the download prompt. This will only display if the
* client version is 1.17 or newer.
*
* @param prompt the component to display
*/
@ -137,8 +129,8 @@ public interface ResourcePackInfo {
/**
* Builds the {@link ResourcePackInfo} from the provided info for use with
* {@link com.velocitypowered.api.proxy.Player#sendResourcePackOffer(ResourcePackInfo)}.
* Note: Some features may be version-dependent. Check before use.
* {@link Player#sendResourcePackOffer(ResourcePackInfo)}. Note: Some features may be
* version-dependent. Check before use.
*
* @return a ResourcePackInfo instance from the provided information
*/

Datei anzeigen

@ -7,7 +7,6 @@
package com.velocitypowered.api.proxy.player;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.crypto.IdentifiedKey;
import com.velocitypowered.api.util.GameProfile;
import java.util.Collection;
@ -71,7 +70,7 @@ public interface TabList {
*
* @param uuid of the entry
* @return {@link Optional} containing the removed {@link TabListEntry} if present, otherwise
* {@link Optional#empty()}
* {@link Optional#empty()}
*/
Optional<TabListEntry> removeEntry(UUID uuid);
@ -88,7 +87,7 @@ public interface TabList {
*
* @param uuid The player's {@link UUID} the {@link TabListEntry} is in reference to.
* @return {@code Optional.empty()} if the player is not present in the provided player's
* {@link TabList} otherwise a present {@link TabListEntry} in relation to the player.
* {@link TabList} otherwise a present {@link TabListEntry} in relation to the player.
*/
Optional<TabListEntry> getEntry(UUID uuid);
@ -116,7 +115,7 @@ public interface TabList {
*/
@Deprecated
default TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
int gameMode) {
int gameMode) {
return buildEntry(profile, displayName, latency, gameMode, null, true);
}
@ -133,7 +132,7 @@ public interface TabList {
*/
@Deprecated
default TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
int gameMode, @Nullable IdentifiedKey key) {
int gameMode, @Nullable IdentifiedKey key) {
return buildEntry(profile, displayName, latency, gameMode, null, true);
}
@ -151,7 +150,7 @@ public interface TabList {
*/
@Deprecated
default TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
int gameMode, @Nullable ChatSession chatSession) {
int gameMode, @Nullable ChatSession chatSession) {
return buildEntry(profile, displayName, latency, gameMode, chatSession, true);
}
@ -169,5 +168,5 @@ public interface TabList {
*/
@Deprecated
TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
int gameMode, @Nullable ChatSession chatSession, boolean listed);
int gameMode, @Nullable ChatSession chatSession, boolean listed);
}

Datei anzeigen

@ -18,6 +18,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* Represents a single entry in a {@link TabList}.
*/
public interface TabListEntry extends KeyIdentifiable {
/**
* Returns the {@link ChatSession} associated with this entry.
*
@ -56,7 +57,7 @@ public interface TabListEntry extends KeyIdentifiable {
* {@link GameProfile#name()} is shown.
*
* @return {@link Optional} text {@link net.kyori.adventure.text.Component} of name displayed in
* the tab list
* the tab list
*/
Optional<Component> getDisplayNameComponent();

Datei anzeigen

@ -17,13 +17,13 @@ import net.kyori.adventure.builder.AbstractBuilder;
import org.jetbrains.annotations.NotNull;
/**
* Contains the parameters used to ping a {@link RegisteredServer}.
* This class is immutable.
* Contains the parameters used to ping a {@link RegisteredServer}. This class is immutable.
*
* @since 3.2.0
* @see RegisteredServer#ping(PingOptions)
* @since 3.2.0
*/
public final class PingOptions {
/**
* Default PingOptions.
*/
@ -73,7 +73,7 @@ public final class PingOptions {
}
final PingOptions other = (PingOptions) o;
return Objects.equals(this.protocolVersion, other.protocolVersion)
&& Objects.equals(this.timeout, other.timeout);
&& Objects.equals(this.timeout, other.timeout);
}
@Override
@ -84,9 +84,9 @@ public final class PingOptions {
@Override
public String toString() {
return "PingOptions{"
+ "protocolVersion=" + protocolVersion
+ ", timeout=" + timeout
+ '}';
+ "protocolVersion=" + protocolVersion
+ ", timeout=" + timeout
+ '}';
}
/**
@ -95,6 +95,7 @@ public final class PingOptions {
* @since 3.2.0
*/
public static final class Builder implements AbstractBuilder<PingOptions> {
private ProtocolVersion protocolVersion = ProtocolVersion.UNKNOWN;
private long timeout = 0;
@ -116,11 +117,9 @@ public final class PingOptions {
/**
* Sets the maximum time to wait to get the required {@link ServerPing}.
*
* @param timeout the timeout duration
* A value of 0 means that the read-timeout value
* from the Velocity configuration will be used,
* while a negative value means that there will
* be no timeout.
* @param timeout the timeout duration A value of 0 means that the read-timeout value from the
* Velocity configuration will be used, while a negative value means that there
* will be no timeout.
* @return this builder
*/
public Builder timeout(final @NotNull Duration timeout) {
@ -132,11 +131,9 @@ public final class PingOptions {
/**
* Sets the maximum time to wait to get the required {@link ServerPing}.
*
* @param time the timeout duration
* A value of 0 means that the read-timeout value
* from the Velocity configuration will be used,
* while a negative value means that there will
* be no timeout.
* @param time the timeout duration A value of 0 means that the read-timeout value from the
* Velocity configuration will be used, while a negative value means that there
* will be no timeout.
* @param timeunit the unit of time to be used to provide the timeout duration
* @return this builder
*/

Datei anzeigen

@ -55,8 +55,8 @@ public final class QueryResponse {
}
/**
* Get hostname which will be used to reply to the query. By default it is {@link
* ProxyConfig#getMotd()} in plain text without colour codes.
* Get hostname which will be used to reply to the query. By default it is
* {@link ProxyConfig#getMotd()} in plain text without colour codes.
*
* @return hostname
*/
@ -75,8 +75,8 @@ public final class QueryResponse {
}
/**
* Get map name which will be used to reply to the query. By default {@link
* ProxyConfig#getQueryMap()} is sent.
* Get map name which will be used to reply to the query. By default
* {@link ProxyConfig#getQueryMap()} is sent.
*
* @return map name
*/
@ -149,10 +149,10 @@ public final class QueryResponse {
/**
* 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
* {@code queryResponse.toBuilder().build().equals(queryResponse)}: that is, if no other
* changes are made to the returned builder, the built instance will equal the original instance.
* 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
* {@code queryResponse.toBuilder().build().equals(queryResponse)}: that is, if no other changes
* are made to the returned builder, the built instance will equal the original instance.
*
* @return {@link QueryResponse} builder
*/
@ -227,6 +227,7 @@ public final class QueryResponse {
* A builder for {@link QueryResponse} objects.
*/
public static final class Builder {
private @MonotonicNonNull String hostname;
private @MonotonicNonNull String gameVersion;
private @MonotonicNonNull String map;

Datei anzeigen

@ -7,8 +7,8 @@
package com.velocitypowered.api.proxy.server;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import com.velocitypowered.api.proxy.player.Player;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import net.kyori.adventure.audience.Audience;
@ -42,8 +42,8 @@ public interface RegisteredServer extends ChannelMessageSink, Audience {
CompletableFuture<ServerPing> ping();
/**
* Attempts to ping the remote server and return the server list ping result
* according to the options provided.
* Attempts to ping the remote server and return the server list ping result according to the
* options provided.
*
* @param pingOptions the options provided for pinging the server
* @return the server ping result from the server

Datei anzeigen

@ -24,7 +24,7 @@ public final class ServerInfo implements Comparable<ServerInfo> {
/**
* Creates a new ServerInfo object.
*
* @param name the name for the server
* @param name the name for the server
* @param address the address of the server to connect to
*/
public ServerInfo(String name, SocketAddress address) {

Datei anzeigen

@ -40,11 +40,11 @@ public final class ServerPing {
/**
* Constructs a ServerPing instance.
*
* @param version the version of the server
* @param players the players on the server
* @param version the version of the server
* @param players the players on the server
* @param description the MOTD for the server
* @param favicon the server's favicon
* @param modinfo the mods this server runs
* @param favicon the server's favicon
* @param modinfo the mods this server runs
*/
public ServerPing(Version version, @Nullable Players players,
Component description, @Nullable Favicon favicon,
@ -109,10 +109,9 @@ public final class ServerPing {
}
/**
* Returns a copy of this {@link ServerPing} instance as a builder so that it can be modified.
* It is guaranteed that {@code ping.asBuilder().build().equals(ping)} is true: that is, if no
* other changes are made to the returned builder, the built instance will equal the original
* instance.
* Returns a copy of this {@link ServerPing} instance as a builder so that it can be modified. It
* is guaranteed that {@code ping.asBuilder().build().equals(ping)} is true: that is, if no other
* changes are made to the returned builder, the built instance will equal the original instance.
*
* @return a copy of this instance as a {@link Builder}
*/
@ -307,10 +306,9 @@ public final class ServerPing {
}
/**
* Represents the version of the server sent to the client. A protocol version
* that does not match the client's protocol version will show up on the server
* list as an incompatible version, but the client will still permit the user
* to connect to the server anyway.
* Represents the version of the server sent to the client. A protocol version that does not match
* the client's protocol version will show up on the server list as an incompatible version, but
* the client will still permit the user to connect to the server anyway.
*/
public static final class Version {
@ -321,7 +319,7 @@ public final class ServerPing {
* Creates a new instance.
*
* @param protocol the protocol version as an integer
* @param name a friendly name for the protocol version
* @param name a friendly name for the protocol version
*/
public Version(int protocol, String name) {
this.protocol = protocol;
@ -363,8 +361,8 @@ public final class ServerPing {
}
/**
* Represents what the players the server purports to have online, its maximum capacity,
* and a sample of players on the server.
* Represents what the players the server purports to have online, its maximum capacity, and a
* sample of players on the server.
*/
public static final class Players {
@ -376,7 +374,7 @@ public final class ServerPing {
* Creates a new instance.
*
* @param online the number of online players
* @param max the maximum number of players
* @param max the maximum number of players
* @param sample a sample of players on the server
*/
public Players(int online, int max, List<SamplePlayer> sample) {

Datei anzeigen

@ -22,7 +22,7 @@ public interface Scheduler {
/**
* Initializes a new {@link TaskBuilder} for creating a task on the proxy.
*
* @param plugin the plugin to request the task for
* @param plugin the plugin to request the task for
* @param runnable the task to run when scheduled
* @return the task builder
*/
@ -31,7 +31,7 @@ public interface Scheduler {
/**
* Initializes a new {@link TaskBuilder} for creating a task on the proxy.
*
* @param plugin the plugin to request the task for
* @param plugin the plugin to request the task for
* @param consumer the task to be run when scheduled with the capacity to cancel itself
* @return the task builder
*/

Datei anzeigen

@ -44,7 +44,7 @@ class FastUuidSansHyphens {
private static final int MOJANG_BROKEN_UUID_LENGTH = 32;
private static final char[] HEX_DIGITS =
new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
private static final long[] HEX_VALUES = new long[128];
@ -82,15 +82,13 @@ class FastUuidSansHyphens {
}
/**
* Parses a UUID from the given character sequence. The character sequence must represent a
* Mojang UUID.
* Parses a UUID from the given character sequence. The character sequence must represent a Mojang
* UUID.
*
* @param uuidSequence the character sequence from which to parse a UUID
*
* @return the UUID represented by the given character sequence
*
* @throws IllegalArgumentException if the given character sequence does not conform to the string
* representation of a Mojang UUID.
* representation of a Mojang UUID.
*/
static UUID parseUuid(final CharSequence uuidSequence) {
if (uuidSequence.length() != MOJANG_BROKEN_UUID_LENGTH) {
@ -142,7 +140,6 @@ class FastUuidSansHyphens {
* Mojang-style UUID.
*
* @param uuid the UUID to represent as a string
*
* @return a string representation of the given UUID
*/
public static String toString(final UUID uuid) {
@ -151,22 +148,22 @@ class FastUuidSansHyphens {
final char[] uuidChars = new char[MOJANG_BROKEN_UUID_LENGTH];
uuidChars[0] = HEX_DIGITS[(int) ((mostSignificantBits & 0xf000000000000000L) >>> 60)];
uuidChars[1] = HEX_DIGITS[(int) ((mostSignificantBits & 0x0f00000000000000L) >>> 56)];
uuidChars[2] = HEX_DIGITS[(int) ((mostSignificantBits & 0x00f0000000000000L) >>> 52)];
uuidChars[3] = HEX_DIGITS[(int) ((mostSignificantBits & 0x000f000000000000L) >>> 48)];
uuidChars[4] = HEX_DIGITS[(int) ((mostSignificantBits & 0x0000f00000000000L) >>> 44)];
uuidChars[5] = HEX_DIGITS[(int) ((mostSignificantBits & 0x00000f0000000000L) >>> 40)];
uuidChars[6] = HEX_DIGITS[(int) ((mostSignificantBits & 0x000000f000000000L) >>> 36)];
uuidChars[7] = HEX_DIGITS[(int) ((mostSignificantBits & 0x0000000f00000000L) >>> 32)];
uuidChars[8] = HEX_DIGITS[(int) ((mostSignificantBits & 0x00000000f0000000L) >>> 28)];
uuidChars[9] = HEX_DIGITS[(int) ((mostSignificantBits & 0x000000000f000000L) >>> 24)];
uuidChars[0] = HEX_DIGITS[(int) ((mostSignificantBits & 0xf000000000000000L) >>> 60)];
uuidChars[1] = HEX_DIGITS[(int) ((mostSignificantBits & 0x0f00000000000000L) >>> 56)];
uuidChars[2] = HEX_DIGITS[(int) ((mostSignificantBits & 0x00f0000000000000L) >>> 52)];
uuidChars[3] = HEX_DIGITS[(int) ((mostSignificantBits & 0x000f000000000000L) >>> 48)];
uuidChars[4] = HEX_DIGITS[(int) ((mostSignificantBits & 0x0000f00000000000L) >>> 44)];
uuidChars[5] = HEX_DIGITS[(int) ((mostSignificantBits & 0x00000f0000000000L) >>> 40)];
uuidChars[6] = HEX_DIGITS[(int) ((mostSignificantBits & 0x000000f000000000L) >>> 36)];
uuidChars[7] = HEX_DIGITS[(int) ((mostSignificantBits & 0x0000000f00000000L) >>> 32)];
uuidChars[8] = HEX_DIGITS[(int) ((mostSignificantBits & 0x00000000f0000000L) >>> 28)];
uuidChars[9] = HEX_DIGITS[(int) ((mostSignificantBits & 0x000000000f000000L) >>> 24)];
uuidChars[10] = HEX_DIGITS[(int) ((mostSignificantBits & 0x0000000000f00000L) >>> 20)];
uuidChars[11] = HEX_DIGITS[(int) ((mostSignificantBits & 0x00000000000f0000L) >>> 16)];
uuidChars[12] = HEX_DIGITS[(int) ((mostSignificantBits & 0x000000000000f000L) >>> 12)];
uuidChars[13] = HEX_DIGITS[(int) ((mostSignificantBits & 0x0000000000000f00L) >>> 8)];
uuidChars[14] = HEX_DIGITS[(int) ((mostSignificantBits & 0x00000000000000f0L) >>> 4)];
uuidChars[15] = HEX_DIGITS[(int) (mostSignificantBits & 0x000000000000000fL)];
uuidChars[15] = HEX_DIGITS[(int) (mostSignificantBits & 0x000000000000000fL)];
uuidChars[16] = HEX_DIGITS[(int) ((leastSignificantBits & 0xf000000000000000L) >>> 60)];
uuidChars[17] = HEX_DIGITS[(int) ((leastSignificantBits & 0x0f00000000000000L) >>> 56)];
uuidChars[18] = HEX_DIGITS[(int) ((leastSignificantBits & 0x00f0000000000000L) >>> 52)];
@ -182,7 +179,7 @@ class FastUuidSansHyphens {
uuidChars[28] = HEX_DIGITS[(int) ((leastSignificantBits & 0x000000000000f000L) >>> 12)];
uuidChars[29] = HEX_DIGITS[(int) ((leastSignificantBits & 0x0000000000000f00L) >>> 8)];
uuidChars[30] = HEX_DIGITS[(int) ((leastSignificantBits & 0x00000000000000f0L) >>> 4)];
uuidChars[31] = HEX_DIGITS[(int) (leastSignificantBits & 0x000000000000000fL)];
uuidChars[31] = HEX_DIGITS[(int) (leastSignificantBits & 0x000000000000000fL)];
return new String(uuidChars);
}

Datei anzeigen

@ -25,8 +25,8 @@ public final class GameProfile {
/**
* Creates a new Mojang game profile.
*
* @param id the UUID for the profile
* @param name the profile's username
* @param id the UUID for the profile
* @param name the profile's username
* @param properties properties for the profile
*/
public GameProfile(UUID id, String name, List<Property> properties) {
@ -38,7 +38,7 @@ public final class GameProfile {
* Creates a new Mojang game profile.
*
* @param undashedId the undashed, Mojang-style UUID for the profile
* @param name the profile's username
* @param name the profile's username
* @param properties properties for the profile
*/
public GameProfile(String undashedId, String name, List<Property> properties) {
@ -190,8 +190,8 @@ public final class GameProfile {
/**
* Creates a profile property entry.
*
* @param name the name of the property
* @param value the value of the property
* @param name the name of the property
* @param value the value of the property
* @param signature the Mojang signature for the property
*/
public Property(String name, String value, String signature) {

Datei anzeigen

@ -26,7 +26,7 @@ public final class ModInfo {
/**
* Constructs a new ModInfo instance.
*
* @param type the Forge server list version to use
* @param type the Forge server list version to use
* @param modList the mods to present to the client
*/
public ModInfo(String type, List<Mod> modList) {

Datei anzeigen

@ -23,8 +23,8 @@ public final class ProxyVersion {
/**
* Creates a new {@link ProxyVersion} instance.
*
* @param name the name for the proxy implementation
* @param vendor the vendor for the proxy implementation
* @param name the name for the proxy implementation
* @param vendor the vendor for the proxy implementation
* @param version the version for the proxy implementation
*/
public ProxyVersion(String name, String vendor, String version) {

Datei anzeigen

@ -1,63 +0,0 @@
/*
* Copyright (C) 2019-2021 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.proxy.messages;
import static com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier.create;
import static com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier.from;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class MinecraftChannelIdentifierTest {
@Test
void createAllowsValidNamespaces() {
create("minecraft", "brand");
}
@Test
void createAllowsEmptyName() {
create("minecraft", "");
}
@Test
void createDisallowsNull() {
assertAll(
() -> assertThrows(IllegalArgumentException.class, () -> create(null, "")),
() -> assertThrows(IllegalArgumentException.class, () -> create("", "")),
() -> assertThrows(IllegalArgumentException.class, () -> create("minecraft", null))
);
}
@Test
void fromIdentifierIsCorrect() {
MinecraftChannelIdentifier expected = MinecraftChannelIdentifier.create("velocity", "test");
assertEquals(expected, MinecraftChannelIdentifier.from("velocity:test"));
}
@Test
void createAllowsSlashes() {
create("velocity", "test/test2");
}
@Test
void fromIdentifierThrowsOnBadValues() {
assertAll(
() -> assertThrows(IllegalArgumentException.class, () -> from("")),
() -> assertThrows(IllegalArgumentException.class, () -> from(":")),
() -> assertThrows(IllegalArgumentException.class, () -> from(":a")),
() -> assertThrows(IllegalArgumentException.class, () -> from("a:")),
() -> assertThrows(IllegalArgumentException.class, () -> from("hello:$$$$$$")),
() -> assertThrows(IllegalArgumentException.class, () -> from("hello::"))
);
}
}

Datei anzeigen

@ -1,5 +1,4 @@
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.withType
import java.io.ByteArrayOutputStream
val currentShortRevision = ByteArrayOutputStream().use {
@ -15,15 +14,15 @@ tasks.withType<Jar> {
manifest {
val buildNumber = System.getenv("BUILD_NUMBER")
val velocityHumanVersion: String =
if (project.version.toString().endsWith("-SNAPSHOT")) {
if (buildNumber == null) {
"${project.version} (git-$currentShortRevision)"
if (project.version.toString().endsWith("-SNAPSHOT")) {
if (buildNumber == null) {
"${project.version} (git-$currentShortRevision)"
} else {
"${project.version} (git-$currentShortRevision-b$buildNumber)"
}
} else {
"${project.version} (git-$currentShortRevision-b$buildNumber)"
"${project.version}"
}
} else {
"${project.version}"
}
attributes["Implementation-Version"] = velocityHumanVersion
}
}

Datei anzeigen

@ -10,6 +10,7 @@ extensions.configure<SpotlessExtension> {
} else {
licenseHeaderFile(rootProject.file("HEADER.txt"))
}
importOrder()
removeUnusedImports()
}
}

Datei anzeigen

@ -6,7 +6,7 @@
<suppressions>
<suppress checks="MissingJavadocType"
files="src/main/java/com/velocitypowered/proxy/network/protocol/packet/*" />
files="src/main/java/com/velocitypowered/proxy/network/protocol/packet/*"/>
<suppress checks="MissingJavadocMethod"
files="src/main/java/com/velocitypowered/proxy/network/protocol/packet/*" />
files="src/main/java/com/velocitypowered/proxy/network/protocol/packet/*"/>
</suppressions>

Datei anzeigen

@ -32,7 +32,7 @@
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<module name="SuppressionFilter">
<property name="file" value="${org.checkstyle.google.suppressionfilter.config}"
default="checkstyle-suppressions.xml" />
default="checkstyle-suppressions.xml"/>
<!--<property name="optional" value="true"/>-->
</module>
@ -45,7 +45,8 @@
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="100"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
<property name="ignorePattern"
value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="TreeWalker">
@ -104,7 +105,7 @@
<property name="query" value="//RCURLY[parent::SLIST[count(./*)=1]
or preceding-sibling::*[last()][self::LCURLY]]"/>
</module>
<module name="WhitespaceAfter" />
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyLambdas" value="true"/>
@ -356,14 +357,14 @@
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.google.suppressionxpathfilter.config}"
default="checkstyle-xpath-suppressions.xml" />
default="checkstyle-xpath-suppressions.xml"/>
<property name="optional" value="true"/>
</module>
<module name="SuppressWarningsHolder" />
<module name="SuppressWarningsHolder"/>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)" />
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)" />
<property name="checkFormat" value="$1" />
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressWithNearbyCommentFilter">
<property name="commentFormat" value="CHECKSTYLE.SUPPRESS\: ([\w\|]+)"/>

Datei anzeigen

@ -5,27 +5,38 @@ traditional Java fallbacks.
## Compression
* **Supported platforms**: Linux x86_64 and aarch64, with Java 11 `ByteBuffer` API support as a fallback.
* **Supported platforms**: Linux x86_64 and aarch64, with Java 11 `ByteBuffer` API support as a
fallback.
Compiled on CentOS 7.
* **Rationale**: Using a native zlib wrapper, we can avoid multiple trips into Java just to copy memory around.
* **Rationale**: Using a native zlib wrapper, we can avoid multiple trips into Java just to copy
memory around.
## Encryption
* **Supported platforms**: Linux x86_64 (OpenSSL 1.0.x and OpenSSL 1.1.x) and aarch64 (OpenSSL 1.1.x only)
* **Rationale**: Using a C library for encryption means we can limit memory copies. Prior to Java 7, this was the only
way to use AES-NI extensions on modern processors, but this is less important since JDK 8 has native support.
* OpenSSL is not included in Velocity. Every distribution provides it now. To deal with ABI incompatibilities,
the native library (which only calls into OpenSSL and contains no cryptographic code) are available for
CentOS 7 (OpenSSL 1.0.0-based), Debian 9 (OpenSSL 1.1.0-based) and Debian Bookworm (OpenSSL 3.0.0-based)
* **Supported platforms**: Linux x86_64 (OpenSSL 1.0.x and OpenSSL 1.1.x) and aarch64 (OpenSSL 1.1.x
only)
* **Rationale**: Using a C library for encryption means we can limit memory copies. Prior to Java 7,
this was the only
way to use AES-NI extensions on modern processors, but this is less important since JDK 8 has
native support.
* OpenSSL is not included in Velocity. Every distribution provides it now. To deal with ABI
incompatibilities,
the native library (which only calls into OpenSSL and contains no cryptographic code) are
available for
CentOS 7 (OpenSSL 1.0.0-based), Debian 9 (OpenSSL 1.1.0-based) and Debian Bookworm (OpenSSL
3.0.0-based)
to provide the widest, most reasonable compatibility with most modern distributions.
## OS support
The natives intend to have the widest possible range of compatibility with modern Linux distributions
The natives intend to have the widest possible range of compatibility with modern Linux
distributions
(defined as those being released in or after 2014).
In theory, these libraries can be compiled for any Unix-like system (in the past, we supported macOS),
In theory, these libraries can be compiled for any Unix-like system (in the past, we supported
macOS),
but interest in other systems is minimal at best, thus we focus on Linux x86_64 and aarch64 as they
are commonly used platforms.
Alpine Linux support is on a "best-effort" basis only. Using `apk add libc6-compat` may enable native support.
Alpine Linux support is on a "best-effort" basis only. Using `apk add libc6-compat` may enable
native support.

Datei anzeigen

@ -23,5 +23,6 @@ import com.velocitypowered.natives.util.BufferPreference;
* Generic interface for any Velocity native.
*/
public interface Native {
BufferPreference preferredBufferType();
}

Datei anzeigen

@ -21,6 +21,7 @@ import io.netty.buffer.ByteBuf;
import java.util.zip.DataFormatException;
class CompressorUtils {
/**
* The default preferred output buffer size for zlib.
*/

Datei anzeigen

@ -28,6 +28,6 @@ class NativeZlibInflate {
static native long free(long ctx);
static native boolean process(long ctx, long sourceAddress, int sourceLength,
static native boolean process(long ctx, long sourceAddress, int sourceLength,
long destinationAddress, int destinationLength) throws DataFormatException;
}

Datei anzeigen

@ -27,6 +27,7 @@ import java.util.zip.DataFormatException;
* implementation.
*/
public interface VelocityCompressor extends Disposable, Native {
void inflate(ByteBuf source, ByteBuf destination, int uncompressedSize)
throws DataFormatException;

Datei anzeigen

@ -68,7 +68,7 @@ public class JavaVelocityCipher implements VelocityCipher {
that the output buffer needs more bytes than the input buffer. When we are working with
AES-CFB8, the output size is equal to the input size. See the problem? */
throw new AssertionError("Cipher update did not operate in place and requested a larger "
+ "buffer than the source buffer");
+ "buffer than the source buffer");
}
}

Datei anzeigen

@ -25,6 +25,7 @@ import io.netty.buffer.ByteBufAllocator;
* Additional utilities for {@link ByteBuf}.
*/
public class MoreByteBufUtils {
private MoreByteBufUtils() {
throw new AssertionError();
}
@ -34,9 +35,9 @@ public class MoreByteBufUtils {
* is called, you should decrement the reference count on the {@code buf} with
* {@link ByteBuf#release()}.
*
* @param alloc the {@link ByteBufAllocator} to use
* @param alloc the {@link ByteBufAllocator} to use
* @param nativeStuff the native we are working with
* @param buf the buffer we are working with
* @param buf the buffer we are working with
* @return a buffer compatible with the native
*/
public static ByteBuf ensureCompatible(ByteBufAllocator alloc, Native nativeStuff, ByteBuf buf) {
@ -70,8 +71,8 @@ public class MoreByteBufUtils {
* Creates a {@link ByteBuf} that will have the best performance with the specified
* {@code nativeStuff}.
*
* @param alloc the {@link ByteBufAllocator} to use
* @param nativeStuff the native we are working with
* @param alloc the {@link ByteBufAllocator} to use
* @param nativeStuff the native we are working with
* @param initialCapacity the initial capacity to allocate
* @return a buffer compatible with the native
*/

Datei anzeigen

@ -25,6 +25,7 @@ import java.util.function.BooleanSupplier;
* Statically-computed constraints for native code.
*/
public class NativeConstraints {
private static final boolean NATIVES_ENABLED = !Boolean.getBoolean("velocity.natives-disabled");
private static final boolean IS_AMD64;
private static final boolean IS_AARCH64;

Datei anzeigen

@ -125,7 +125,7 @@ public class Natives {
new NativeCodeLoader.Variant<>(NativeConstraints.MACOS_AARCH64,
copyAndLoadNative("/macos_arm64/velocity-cipher.dylib"),
"native (macOS ARM64 / Apple Silicon)",
NativeVelocityCipher.FACTORY),
NativeVelocityCipher.FACTORY),
new NativeCodeLoader.Variant<>(NativeCodeLoader.ALWAYS, () -> {
}, "Java", JavaVelocityCipher.FACTORY)

Datei anzeigen

@ -24,8 +24,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* The main class. Responsible for parsing command line arguments and then launching the
* proxy.
* The main class. Responsible for parsing command line arguments and then launching the proxy.
*/
public class Velocity {

Datei anzeigen

@ -28,8 +28,8 @@ import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.PluginManager;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;

Datei anzeigen

@ -33,7 +33,7 @@ import com.spotify.futures.CompletableFutures;
import com.velocitypowered.api.command.Command;
import com.velocitypowered.api.command.CommandMeta;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.proxy.command.brigadier.VelocityArgumentCommandNode;
import java.util.ArrayList;
import java.util.Collection;
@ -157,8 +157,8 @@ final class SuggestionsProvider<S> {
}
final Collection<CommandNode<S>> aliases = contextSoFar.getRootNode().getChildren();
@SuppressWarnings("unchecked")
final CompletableFuture<Suggestions>[] futures = new CompletableFuture[aliases.size()];
@SuppressWarnings("unchecked") final CompletableFuture<Suggestions>[] futures =
new CompletableFuture[aliases.size()];
int i = 0;
for (final CommandNode<S> node : aliases) {
CompletableFuture<Suggestions> future = Suggestions.empty();

Datei anzeigen

@ -122,15 +122,15 @@ public class VelocityCommandManager implements CommandManager {
final List<CommandRegistrar<?>> commandRegistrars = this.implementedRegistrars(command);
if (commandRegistrars.isEmpty()) {
throw new IllegalArgumentException(
command + " does not implement a registrable Command subinterface");
command + " does not implement a registrable Command subinterface");
} else if (commandRegistrars.size() > 1) {
final String implementedInterfaces = commandRegistrars.stream()
.map(CommandRegistrar::registrableSuperInterface)
.map(Class::getSimpleName)
.collect(Collectors.joining(", "));
.map(CommandRegistrar::registrableSuperInterface)
.map(Class::getSimpleName)
.collect(Collectors.joining(", "));
throw new IllegalArgumentException(
command + " implements multiple registrable Command subinterfaces: "
+ implementedInterfaces);
command + " implements multiple registrable Command subinterfaces: "
+ implementedInterfaces);
} else {
this.internalRegister(commandRegistrars.get(0), command, meta);
}

Datei anzeigen

@ -28,8 +28,8 @@ import com.mojang.brigadier.tree.ArgumentCommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.List;
import java.util.Optional;

Datei anzeigen

@ -25,9 +25,9 @@ import com.mojang.brigadier.tree.ArgumentCommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.network.connection.ServerConnection;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Objects;
import java.util.Optional;
@ -39,6 +39,7 @@ import net.kyori.adventure.util.TriState;
* Implements the Velocity default {@code /send} command.
*/
public class SendCommand {
private final ProxyServer server;
private static final String SERVER_ARG = "server";
private static final String PLAYER_ARG = "player";
@ -52,44 +53,44 @@ public class SendCommand {
*/
public void register() {
LiteralCommandNode<CommandSource> totalNode = LiteralArgumentBuilder
.<CommandSource>literal("send")
.requires(source ->
source.getPermissionValue("velocity.command.send") == TriState.TRUE)
.executes(this::usage)
.build();
.<CommandSource>literal("send")
.requires(source ->
source.getPermissionValue("velocity.command.send") == TriState.TRUE)
.executes(this::usage)
.build();
ArgumentCommandNode<CommandSource, String> playerNode = RequiredArgumentBuilder
.<CommandSource, String>argument("player", StringArgumentType.word())
.suggests((context, builder) -> {
String argument = context.getArguments().containsKey(PLAYER_ARG)
? context.getArgument(PLAYER_ARG, String.class)
: "";
for (Player player : server.getAllPlayers()) {
String playerName = player.username();
if (playerName.regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest(playerName);
}
}
if ("all".regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest("all");
}
if ("current".regionMatches(true, 0, argument, 0, argument.length())
&& context.getSource() instanceof Player) {
builder.suggest("current");
}
return builder.buildFuture();
})
.executes(this::usage)
.build();
.<CommandSource, String>argument("player", StringArgumentType.word())
.suggests((context, builder) -> {
String argument = context.getArguments().containsKey(PLAYER_ARG)
? context.getArgument(PLAYER_ARG, String.class)
: "";
for (Player player : server.onlinePlayers()) {
String playerName = player.username();
if (playerName.regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest(playerName);
}
}
if ("all".regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest("all");
}
if ("current".regionMatches(true, 0, argument, 0, argument.length())
&& context.getSource() instanceof Player) {
builder.suggest("current");
}
return builder.buildFuture();
})
.executes(this::usage)
.build();
ArgumentCommandNode<CommandSource, String> serverNode = RequiredArgumentBuilder
.<CommandSource, String>argument("server", StringArgumentType.word())
.suggests((context, builder) -> {
for (RegisteredServer server : server.registeredServers()) {
builder.suggest(server.serverInfo().name());
}
return builder.buildFuture();
})
.executes(this::send)
.build();
.<CommandSource, String>argument("server", StringArgumentType.word())
.suggests((context, builder) -> {
for (RegisteredServer server : server.registeredServers()) {
builder.suggest(server.serverInfo().name());
}
return builder.buildFuture();
})
.executes(this::send)
.build();
totalNode.addChild(playerNode);
playerNode.addChild(serverNode);
server.commandManager().register(new BrigadierCommand(totalNode));
@ -97,7 +98,7 @@ public class SendCommand {
private int usage(CommandContext<CommandSource> context) {
context.getSource().sendMessage(
Component.translatable("velocity.command.send-usage", NamedTextColor.YELLOW)
Component.translatable("velocity.command.send-usage", NamedTextColor.YELLOW)
);
return 1;
}
@ -110,7 +111,7 @@ public class SendCommand {
if (maybeServer.isEmpty()) {
context.getSource().sendMessage(
CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName))
CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName))
);
return 0;
}
@ -119,7 +120,7 @@ public class SendCommand {
&& !Objects.equals(player, "all")
&& !Objects.equals(player, "current")) {
context.getSource().sendMessage(
CommandMessages.PLAYER_NOT_FOUND.args(Component.text(player))
CommandMessages.PLAYER_NOT_FOUND.args(Component.text(player))
);
return 0;
}

Datei anzeigen

@ -22,9 +22,9 @@ import static net.kyori.adventure.text.event.HoverEvent.showText;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.network.connection.ServerConnection;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.player.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
import java.util.List;

Datei anzeigen

@ -413,6 +413,7 @@ public class VelocityCommand implements SimpleCommand {
* Heap SubCommand.
*/
public static class Heap implements SubCommand {
private static final Logger logger = LogManager.getLogger(Heap.class);
private MethodHandle heapGenerator;
private Consumer<CommandSource> heapConsumer;

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen