diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index ab1dc2fcd4..aafe7ad3ad 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -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 diff --git a/README.md b/README.md index 5de7436fda..1d303d16d2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 32fdc70717..f3644c97ec 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -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 diff --git a/api/src/main/java/com/velocitypowered/api/command/BrigadierCommand.java b/api/src/main/java/com/velocitypowered/api/command/BrigadierCommand.java index 094e4ddf9c..a0dea5a0c4 100644 --- a/api/src/main/java/com/velocitypowered/api/command/BrigadierCommand.java +++ b/api/src/main/java/com/velocitypowered/api/command/BrigadierCommand.java @@ -12,22 +12,20 @@ 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 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/command/Command.java b/api/src/main/java/com/velocitypowered/api/command/Command.java index e2b7f92561..4aa2768296 100644 --- a/api/src/main/java/com/velocitypowered/api/command/Command.java +++ b/api/src/main/java/com/velocitypowered/api/command/Command.java @@ -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. * *

You must not subclass Command. Use one of the following * registrable subinterfaces:

@@ -30,4 +30,5 @@ * */ public interface Command { + } diff --git a/api/src/main/java/com/velocitypowered/api/command/CommandManager.java b/api/src/main/java/com/velocitypowered/api/command/CommandManager.java index f4ef053972..abc17e7a18 100644 --- a/api/src/main/java/com/velocitypowered/api/command/CommandManager.java +++ b/api/src/main/java/com/velocitypowered/api/command/CommandManager.java @@ -18,8 +18,7 @@ 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 @@ default void register(String alias, Command command, String... otherAliases) { /** * 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 @@ default void register(String alias, Command command, String... otherAliases) { /** * 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 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 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/command/CommandMeta.java b/api/src/main/java/com/velocitypowered/api/command/CommandMeta.java index 23605f3285..ea692bde13 100644 --- a/api/src/main/java/com/velocitypowered/api/command/CommandMeta.java +++ b/api/src/main/java/com/velocitypowered/api/command/CommandMeta.java @@ -17,25 +17,25 @@ 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 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> 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 @@ interface Builder { 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 node); diff --git a/api/src/main/java/com/velocitypowered/api/command/InvocableCommand.java b/api/src/main/java/com/velocitypowered/api/command/InvocableCommand.java index 37afa07108..107cd0040c 100644 --- a/api/src/main/java/com/velocitypowered/api/command/InvocableCommand.java +++ b/api/src/main/java/com/velocitypowered/api/command/InvocableCommand.java @@ -15,9 +15,8 @@ * A command that can be executed with arbitrary arguments. * *

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 the type of the command invocation object */ diff --git a/api/src/main/java/com/velocitypowered/api/command/RawCommand.java b/api/src/main/java/com/velocitypowered/api/command/RawCommand.java index 05da7c6e4e..21626895e4 100644 --- a/api/src/main/java/com/velocitypowered/api/command/RawCommand.java +++ b/api/src/main/java/com/velocitypowered/api/command/RawCommand.java @@ -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 { diff --git a/api/src/main/java/com/velocitypowered/api/command/SimpleCommand.java b/api/src/main/java/com/velocitypowered/api/command/SimpleCommand.java index 0fb3a7ff82..072cc391d1 100644 --- a/api/src/main/java/com/velocitypowered/api/command/SimpleCommand.java +++ b/api/src/main/java/com/velocitypowered/api/command/SimpleCommand.java @@ -10,8 +10,7 @@ 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. * *

Prefer using {@link BrigadierCommand}, which is also * backwards-compatible with older clients. diff --git a/api/src/main/java/com/velocitypowered/api/command/VelocityBrigadierMessage.java b/api/src/main/java/com/velocitypowered/api/command/VelocityBrigadierMessage.java index 0ae69591ef..68af560659 100644 --- a/api/src/main/java/com/velocitypowered/api/command/VelocityBrigadierMessage.java +++ b/api/src/main/java/com/velocitypowered/api/command/VelocityBrigadierMessage.java @@ -15,8 +15,8 @@ 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 { diff --git a/api/src/main/java/com/velocitypowered/api/event/Continuation.java b/api/src/main/java/com/velocitypowered/api/event/Continuation.java index 30672ef606..260617b69d 100644 --- a/api/src/main/java/com/velocitypowered/api/event/Continuation.java +++ b/api/src/main/java/com/velocitypowered/api/event/Continuation.java @@ -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 { diff --git a/api/src/main/java/com/velocitypowered/api/event/EventManager.java b/api/src/main/java/com/velocitypowered/api/event/EventManager.java index 2261e22208..562e320b1e 100644 --- a/api/src/main/java/com/velocitypowered/api/event/EventManager.java +++ b/api/src/main/java/com/velocitypowered/api/event/EventManager.java @@ -15,36 +15,36 @@ 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 the event type to handle + * @param handler the handler to register + * @param the event type to handle */ default void register(Object plugin, Class eventClass, EventHandler 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 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 the event type to handle */ void register(Object plugin, Class eventClass, short postOrder, EventHandler handler); @@ -78,7 +78,7 @@ default void fireAndForget(Object event) { /** * 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 @@ default void fireAndForget(Object event) { /** * 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 the event type to handle + * @param the event type to handle */ void unregister(Object plugin, EventHandler handler); } diff --git a/api/src/main/java/com/velocitypowered/api/event/ResultedEvent.java b/api/src/main/java/com/velocitypowered/api/event/ResultedEvent.java index 8e1bfee28c..a4004dec75 100644 --- a/api/src/main/java/com/velocitypowered/api/event/ResultedEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/ResultedEvent.java @@ -37,8 +37,8 @@ public interface ResultedEvent { 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/event/Subscribe.java b/api/src/main/java/com/velocitypowered/api/event/Subscribe.java index 7e81b2230e..3a2b7a9002 100644 --- a/api/src/main/java/com/velocitypowered/api/event/Subscribe.java +++ b/api/src/main/java/com/velocitypowered/api/event/Subscribe.java @@ -34,9 +34,9 @@ * not to enable it now. This option is being provided as a migration aid.

* *

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. This still means you must consider thread-safety in your - * event listeners as the "current thread" can and will be different each time.

+ * asynchronously. Otherwise, the handler may be executed on the current thread or asynchronously. + * This still means you must consider thread-safety in your event listeners as + * the "current thread" can and will be different each time.

* *

If any method handler targeting an event type is marked with {@code true}, then every * handler targeting that event type will be executed asynchronously.

diff --git a/api/src/main/java/com/velocitypowered/api/event/annotation/AwaitingEvent.java b/api/src/main/java/com/velocitypowered/api/event/annotation/AwaitingEvent.java index 3fd72cdc68..b4f5f26017 100644 --- a/api/src/main/java/com/velocitypowered/api/event/annotation/AwaitingEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/annotation/AwaitingEvent.java @@ -14,8 +14,8 @@ /** * 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 diff --git a/api/src/main/java/com/velocitypowered/api/event/command/CommandExecuteEvent.java b/api/src/main/java/com/velocitypowered/api/event/command/CommandExecuteEvent.java index c510bbda0c..8003186f70 100644 --- a/api/src/main/java/com/velocitypowered/api/event/command/CommandExecuteEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/command/CommandExecuteEvent.java @@ -31,7 +31,7 @@ public final class CommandExecuteEvent implements ResultedEvent { * 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 static CommandResult deny() { } /** - * 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/event/command/PlayerAvailableCommandsEvent.java b/api/src/main/java/com/velocitypowered/api/event/command/PlayerAvailableCommandsEvent.java index d046b77ca7..0434caca0b 100644 --- a/api/src/main/java/com/velocitypowered/api/event/command/PlayerAvailableCommandsEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/command/PlayerAvailableCommandsEvent.java @@ -13,13 +13,12 @@ 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, diff --git a/api/src/main/java/com/velocitypowered/api/event/connection/ConnectionHandshakeEvent.java b/api/src/main/java/com/velocitypowered/api/event/connection/ConnectionHandshakeEvent.java index 76df9f967a..09e7715690 100644 --- a/api/src/main/java/com/velocitypowered/api/event/connection/ConnectionHandshakeEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/connection/ConnectionHandshakeEvent.java @@ -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 { diff --git a/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java b/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java index e9ff8693c5..88ffa293ad 100644 --- a/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java @@ -9,19 +9,18 @@ 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. * *

- * 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. *

*/ @AwaitingEvent diff --git a/api/src/main/java/com/velocitypowered/api/event/connection/LoginEvent.java b/api/src/main/java/com/velocitypowered/api/event/connection/LoginEvent.java index 997b3e5538..48d85b3c77 100644 --- a/api/src/main/java/com/velocitypowered/api/event/connection/LoginEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/connection/LoginEvent.java @@ -11,7 +11,7 @@ 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. diff --git a/api/src/main/java/com/velocitypowered/api/event/connection/PluginMessageEvent.java b/api/src/main/java/com/velocitypowered/api/event/connection/PluginMessageEvent.java index 6d4901c926..a189c6b12d 100644 --- a/api/src/main/java/com/velocitypowered/api/event/connection/PluginMessageEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/connection/PluginMessageEvent.java @@ -12,18 +12,19 @@ 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 { @@ -37,10 +38,10 @@ public final class PluginMessageEvent implements ResultedEvent - * 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. *

*/ @AwaitingEvent @@ -39,7 +40,7 @@ public final class PreLoginEvent implements ResultedEventThis event is only called once per subject, on initialisation.

* *

- * 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. *

*/ @AwaitingEvent diff --git a/api/src/main/java/com/velocitypowered/api/event/player/GameProfileRequestEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/GameProfileRequestEvent.java index 78a3985488..b734ad8636 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/GameProfileRequestEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/GameProfileRequestEvent.java @@ -9,7 +9,7 @@ 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 @@ * a user, i.e. skin replacement. * *

- * 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. *

*/ @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) { diff --git a/api/src/main/java/com/velocitypowered/api/event/player/KickedFromServerEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/KickedFromServerEvent.java index 92f5880b30..eccf6975d3 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/KickedFromServerEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/KickedFromServerEvent.java @@ -10,7 +10,7 @@ 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 @@ /** * 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 boolean kickedDuringServerConnect() { * * @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 RegisteredServer getServer() { } /** - * 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 static RedirectPlayer redirect(RegisteredServer server, } /** - * 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 diff --git a/api/src/main/java/com/velocitypowered/api/event/player/PlayerChannelRegisterEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/PlayerChannelRegisterEvent.java index 5e0760adc7..c646db0ec6 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/PlayerChannelRegisterEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/PlayerChannelRegisterEvent.java @@ -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 List channels() { @Override public String toString() { return "PlayerChannelRegisterEvent{" - + "player=" + player - + ", channels=" + channels - + '}'; + + "player=" + player + + ", channels=" + channels + + '}'; } } diff --git a/api/src/main/java/com/velocitypowered/api/event/player/PlayerChatEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/PlayerChatEvent.java index 9aef05e4c7..3e02a8069a 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/PlayerChatEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/PlayerChatEvent.java @@ -10,14 +10,14 @@ 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, @@ -30,7 +30,7 @@ public final class PlayerChatEvent implements ResultedEventminecraft:brand 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 String getBrand() { @Override public String toString() { return "PlayerClientBrandEvent{" - + "player=" + player - + ", brand='" + brand + '\'' - + '}'; + + "player=" + player + + ", brand='" + brand + '\'' + + '}'; } } - diff --git a/api/src/main/java/com/velocitypowered/api/event/player/PlayerModInfoEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/PlayerModInfoEvent.java index df11fb16a5..ae91eacbc5 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/PlayerModInfoEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/PlayerModInfoEvent.java @@ -9,7 +9,7 @@ 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; /** diff --git a/api/src/main/java/com/velocitypowered/api/event/player/PlayerReferentEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/PlayerReferentEvent.java index 7fd65bb841..07ae3a34c7 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/PlayerReferentEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/PlayerReferentEvent.java @@ -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. diff --git a/api/src/main/java/com/velocitypowered/api/event/player/PlayerResourcePackStatusEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/PlayerResourcePackStatusEvent.java index 3e589fa1c4..0493c9d808 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/PlayerResourcePackStatusEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/PlayerResourcePackStatusEvent.java @@ -10,7 +10,7 @@ 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 ResourcePackInfo getPackInfo() { } /** - * 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 boolean isOverwriteKick() { } /** - * 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 boolean isOverwriteKick() { 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; } diff --git a/api/src/main/java/com/velocitypowered/api/event/player/PlayerSettingsChangedEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/PlayerSettingsChangedEvent.java index a27e0b6287..ad77ab4d00 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/PlayerSettingsChangedEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/PlayerSettingsChangedEvent.java @@ -9,13 +9,13 @@ 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 { diff --git a/api/src/main/java/com/velocitypowered/api/event/player/ServerConnectedEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/ServerConnectedEvent.java index 87af98dea0..27e6c5e61a 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/ServerConnectedEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/ServerConnectedEvent.java @@ -9,7 +9,7 @@ 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 @@ * connection to the previous server has been de-established. * *

- * Note: For historical reasons, Velocity does wait on this event to finish - * firing before continuing the server connection process. This behavior is - * deprecated and likely to be removed in Polymer. + * Note: For historical reasons, Velocity does wait on this event to finish + * firing before continuing the server connection process. This behavior is + * deprecated and likely to be removed in Polymer. *

*/ @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, diff --git a/api/src/main/java/com/velocitypowered/api/event/player/ServerLoginPluginMessageEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/ServerLoginPluginMessageEvent.java index d5866c7133..b9f3305ddf 100644 --- a/api/src/main/java/com/velocitypowered/api/event/player/ServerLoginPluginMessageEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/player/ServerLoginPluginMessageEvent.java @@ -15,7 +15,7 @@ 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 @@ /** * 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 { + private final ServerConnection connection; private final ChannelIdentifier identifier; private final byte[] contents; @@ -40,7 +41,7 @@ public class ServerLoginPluginMessageEvent implements ResultedEvent { + private GenericResult result; private final ResourcePackInfo receivedResourcePack; private ResourcePackInfo providedResourcePack; @@ -30,7 +30,7 @@ public class ServerResourcePackSendEvent implements ResultedEvent 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 suggestions) { this.player = checkNotNull(player, "player"); diff --git a/api/src/main/java/com/velocitypowered/api/event/proxy/ProxyPingEvent.java b/api/src/main/java/com/velocitypowered/api/event/proxy/ProxyPingEvent.java index 0301465fe4..a538290eaf 100644 --- a/api/src/main/java/com/velocitypowered/api/event/proxy/ProxyPingEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/proxy/ProxyPingEvent.java @@ -9,15 +9,15 @@ 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 { diff --git a/api/src/main/java/com/velocitypowered/api/event/query/ProxyQueryEvent.java b/api/src/main/java/com/velocitypowered/api/event/query/ProxyQueryEvent.java index fd6eafa7bf..f76d1b9979 100644 --- a/api/src/main/java/com/velocitypowered/api/event/query/ProxyQueryEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/query/ProxyQueryEvent.java @@ -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"); diff --git a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java index ef7024efeb..30d5b530ca 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -153,7 +153,7 @@ public int getProtocol() { * * @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 String getName() { } /** - * 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 String getVersionIntroducedIn() { } /** - * 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/proxy/InboundConnection.java b/api/src/main/java/com/velocitypowered/api/network/connection/InboundConnection.java similarity index 95% rename from api/src/main/java/com/velocitypowered/api/proxy/InboundConnection.java rename to api/src/main/java/com/velocitypowered/api/network/connection/InboundConnection.java index 46dcbf2336..9199756a81 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/InboundConnection.java +++ b/api/src/main/java/com/velocitypowered/api/network/connection/InboundConnection.java @@ -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; diff --git a/api/src/main/java/com/velocitypowered/api/proxy/LoginPhaseConnection.java b/api/src/main/java/com/velocitypowered/api/network/connection/LoginPhaseConnection.java similarity index 73% rename from api/src/main/java/com/velocitypowered/api/proxy/LoginPhaseConnection.java rename to api/src/main/java/com/velocitypowered/api/network/connection/LoginPhaseConnection.java index 24df0298fe..872eabdceb 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/LoginPhaseConnection.java +++ b/api/src/main/java/com/velocitypowered/api/network/connection/LoginPhaseConnection.java @@ -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); diff --git a/api/src/main/java/com/velocitypowered/api/proxy/ServerConnection.java b/api/src/main/java/com/velocitypowered/api/network/connection/ServerConnection.java similarity index 92% rename from api/src/main/java/com/velocitypowered/api/proxy/ServerConnection.java rename to api/src/main/java/com/velocitypowered/api/network/connection/ServerConnection.java index 816b0f58d5..db5438f223 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/ServerConnection.java +++ b/api/src/main/java/com/velocitypowered/api/network/connection/ServerConnection.java @@ -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; diff --git a/api/src/main/java/com/velocitypowered/api/plugin/Plugin.java b/api/src/main/java/com/velocitypowered/api/plugin/Plugin.java index 523648e674..8f63d64909 100644 --- a/api/src/main/java/com/velocitypowered/api/plugin/Plugin.java +++ b/api/src/main/java/com/velocitypowered/api/plugin/Plugin.java @@ -21,8 +21,8 @@ /** * 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/plugin/PluginContainer.java b/api/src/main/java/com/velocitypowered/api/plugin/PluginContainer.java index 66f784d243..bc0e3a3c63 100644 --- a/api/src/main/java/com/velocitypowered/api/plugin/PluginContainer.java +++ b/api/src/main/java/com/velocitypowered/api/plugin/PluginContainer.java @@ -32,8 +32,7 @@ default Optional instance() { } /** - * 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/plugin/PluginManager.java b/api/src/main/java/com/velocitypowered/api/plugin/PluginManager.java index e0f2b7c474..d78ed9d7e4 100644 --- a/api/src/main/java/com/velocitypowered/api/plugin/PluginManager.java +++ b/api/src/main/java/com/velocitypowered/api/plugin/PluginManager.java @@ -13,8 +13,8 @@ /** * 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); diff --git a/api/src/main/java/com/velocitypowered/api/plugin/meta/PluginDependency.java b/api/src/main/java/com/velocitypowered/api/plugin/meta/PluginDependency.java index 813543b44f..e2c2e29c7e 100644 --- a/api/src/main/java/com/velocitypowered/api/plugin/meta/PluginDependency.java +++ b/api/src/main/java/com/velocitypowered/api/plugin/meta/PluginDependency.java @@ -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) { diff --git a/api/src/main/java/com/velocitypowered/api/proxy/ConnectionRequestBuilder.java b/api/src/main/java/com/velocitypowered/api/proxy/ConnectionRequestBuilder.java index 40fad24e7f..a93116b478 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/ConnectionRequestBuilder.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/ConnectionRequestBuilder.java @@ -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 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/proxy/ConsoleCommandSource.java b/api/src/main/java/com/velocitypowered/api/proxy/ConsoleCommandSource.java index 244a8a8670..646ae40e70 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/ConsoleCommandSource.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/ConsoleCommandSource.java @@ -13,4 +13,5 @@ * Indicates that the executor of the command is the console. */ public interface ConsoleCommandSource extends CommandSource { + } diff --git a/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java b/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java index 7a432913c6..1206187818 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java @@ -13,6 +13,7 @@ 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)}. * *

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.

+ * - 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.

* *

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.

+ * 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.

* * @param url The url where the resource pack can be found * @return a ResourcePackInfo builder diff --git a/api/src/main/java/com/velocitypowered/api/proxy/config/ProxyConfig.java b/api/src/main/java/com/velocitypowered/api/proxy/config/ProxyConfig.java index eae807eba2..18bf08161e 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/config/ProxyConfig.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/config/ProxyConfig.java @@ -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 */ diff --git a/api/src/main/java/com/velocitypowered/api/proxy/crypto/IdentifiedKey.java b/api/src/main/java/com/velocitypowered/api/proxy/crypto/IdentifiedKey.java index 19bb612112..623498736b 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/crypto/IdentifiedKey.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/crypto/IdentifiedKey.java @@ -20,8 +20,7 @@ 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 @@ enum Revision { this.backwardsCompatibleTo = backwardsCompatibleTo; this.applicableTo = applicableTo; } - + public Set backwardsCompatibleTo() { return backwardsCompatibleTo; } - + public Set applicableTo() { return applicableTo; } diff --git a/api/src/main/java/com/velocitypowered/api/proxy/crypto/KeyIdentifiable.java b/api/src/main/java/com/velocitypowered/api/proxy/crypto/KeyIdentifiable.java index bd4f2ed172..d1759d13ea 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/crypto/KeyIdentifiable.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/crypto/KeyIdentifiable.java @@ -15,8 +15,8 @@ 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/proxy/crypto/KeySigned.java b/api/src/main/java/com/velocitypowered/api/proxy/crypto/KeySigned.java index 7f5ee6b600..50e4ef35c2 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/crypto/KeySigned.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/crypto/KeySigned.java @@ -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 @@ default boolean hasExpired() { 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()}. *

DOES NOT WORK YET FOR MESSAGES AND COMMANDS!

* Addendum: Does not work for 1.19.1 until the user has authenticated. * diff --git a/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelIdentifier.java b/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelIdentifier.java index f5bc406b60..8352c731db 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelIdentifier.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelIdentifier.java @@ -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); + } } diff --git a/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelMessageSink.java b/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelMessageSink.java index b310f13bcb..19f0dc268b 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelMessageSink.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelMessageSink.java @@ -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); diff --git a/api/src/main/java/com/velocitypowered/api/proxy/messages/LegacyChannelIdentifier.java b/api/src/main/java/com/velocitypowered/api/proxy/messages/LegacyChannelIdentifier.java index 6e45efb484..539fbb64aa 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/messages/LegacyChannelIdentifier.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/messages/LegacyChannelIdentifier.java @@ -17,7 +17,7 @@ * 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 boolean equals(@Nullable Object o) { @Override public int hashCode() { - return Objects.hash(name); + return name.hashCode(); } @Override diff --git a/api/src/main/java/com/velocitypowered/api/proxy/messages/MinecraftChannelIdentifier.java b/api/src/main/java/com/velocitypowered/api/proxy/messages/MinecraftChannelIdentifier.java index b003d1b206..9d8247c628 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/messages/MinecraftChannelIdentifier.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/messages/MinecraftChannelIdentifier.java @@ -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 @@ * Represents a Minecraft 1.13+ channel identifier. This class is immutable and safe for * multi-threaded use. */ -public final class MinecraftChannelIdentifier implements ChannelIdentifier { - - private static final Pattern VALID_IDENTIFIER_REGEX = Pattern.compile("[a-z0-9/\\-_]*"); - - 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); - } +final class MinecraftChannelIdentifier implements ChannelIdentifier { - /** - * 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; - } + private final Key key; - 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 boolean equals(@Nullable Object o) { 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(); } } diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/ChatSession.java b/api/src/main/java/com/velocitypowered/api/proxy/player/ChatSession.java index 8a9da8f22c..a779c5aa72 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/ChatSession.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/ChatSession.java @@ -14,6 +14,7 @@ * Represents a chat session held by a player. */ public interface ChatSession extends KeyIdentifiable { + /** * Returns the {@link UUID} of the session. * diff --git a/api/src/main/java/com/velocitypowered/api/proxy/Player.java b/api/src/main/java/com/velocitypowered/api/proxy/player/Player.java similarity index 84% rename from api/src/main/java/com/velocitypowered/api/proxy/Player.java rename to api/src/main/java/com/velocitypowered/api/proxy/player/Player.java index 64c2e5a564..a86ac2351c 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/Player.java @@ -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 /** * Note that this method does not send a plugin message to the server the player - * is connected to. 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. 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 asHoverEvent( - @NotNull UnaryOperator op) { + @NotNull UnaryOperator op) { return HoverEvent.showEntity(op.apply(HoverEvent.ShowEntity.showEntity(this, uuid(), - Component.text(username())))); + Component.text(username())))); } diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java b/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java index ce97ceb7ec..9837f564c4 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java @@ -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. */ diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/ResourcePackInfo.java b/api/src/main/java/com/velocitypowered/api/proxy/player/ResourcePackInfo.java index 1cb0a9ac2a..80801be59e 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/ResourcePackInfo.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/ResourcePackInfo.java @@ -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 not guaranteed that + * Returns a copy of this {@link ResourcePackInfo} instance as a builder so that it can be + * modified. It is not 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 @@ interface Builder { /** * 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java b/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java index 59177a8484..8652189d4e 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java @@ -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 @@ default void addEntries(TabListEntry... entries) { * * @param uuid of the entry * @return {@link Optional} containing the removed {@link TabListEntry} if present, otherwise - * {@link Optional#empty()} + * {@link Optional#empty()} */ Optional removeEntry(UUID uuid); @@ -88,7 +87,7 @@ default void addEntries(TabListEntry... entries) { * * @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 getEntry(UUID uuid); @@ -116,7 +115,7 @@ default void addEntries(TabListEntry... entries) { */ @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 @@ default TabListEntry buildEntry(GameProfile profile, @Nullable Component display */ @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 @@ default TabListEntry buildEntry(GameProfile profile, @Nullable Component display */ @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 @@ default TabListEntry buildEntry(GameProfile profile, @Nullable Component display */ @Deprecated TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency, - int gameMode, @Nullable ChatSession chatSession, boolean listed); + int gameMode, @Nullable ChatSession chatSession, boolean listed); } diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/TabListEntry.java b/api/src/main/java/com/velocitypowered/api/proxy/player/TabListEntry.java index e3171137da..3bdd98e8b2 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/TabListEntry.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/TabListEntry.java @@ -18,6 +18,7 @@ * 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 @@ default IdentifiedKey identifiedKey() { * {@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 getDisplayNameComponent(); diff --git a/api/src/main/java/com/velocitypowered/api/proxy/server/PingOptions.java b/api/src/main/java/com/velocitypowered/api/proxy/server/PingOptions.java index 388afb4d2a..640fcb663c 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/server/PingOptions.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/server/PingOptions.java @@ -17,13 +17,13 @@ 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 boolean equals(Object o) { } 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 int hashCode() { @Override public String toString() { return "PingOptions{" - + "protocolVersion=" + protocolVersion - + ", timeout=" + timeout - + '}'; + + "protocolVersion=" + protocolVersion + + ", timeout=" + timeout + + '}'; } /** @@ -95,6 +95,7 @@ public String toString() { * @since 3.2.0 */ public static final class Builder implements AbstractBuilder { + private ProtocolVersion protocolVersion = ProtocolVersion.UNKNOWN; private long timeout = 0; @@ -116,11 +117,9 @@ public Builder version(final @NotNull ProtocolVersion protocolVersion) { /** * 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 Builder timeout(final @NotNull Duration timeout) { /** * 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 */ diff --git a/api/src/main/java/com/velocitypowered/api/proxy/server/QueryResponse.java b/api/src/main/java/com/velocitypowered/api/proxy/server/QueryResponse.java index e829fa16a7..36f82cbed1 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/server/QueryResponse.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/server/QueryResponse.java @@ -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 String gameVersion() { } /** - * 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 Collection plugins() { /** - * Creates a new {@link Builder} instance from data represented by this response, so that you - * may create a new {@link QueryResponse} with new data. It is guaranteed that - * {@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 String toString() { * A builder for {@link QueryResponse} objects. */ public static final class Builder { + private @MonotonicNonNull String hostname; private @MonotonicNonNull String gameVersion; private @MonotonicNonNull String map; diff --git a/api/src/main/java/com/velocitypowered/api/proxy/server/RegisteredServer.java b/api/src/main/java/com/velocitypowered/api/proxy/server/RegisteredServer.java index 64f5390dbb..8d65a9af51 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/server/RegisteredServer.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/server/RegisteredServer.java @@ -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 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 diff --git a/api/src/main/java/com/velocitypowered/api/proxy/server/ServerInfo.java b/api/src/main/java/com/velocitypowered/api/proxy/server/ServerInfo.java index d7ce0f2c11..831cf0a9c4 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/server/ServerInfo.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/server/ServerInfo.java @@ -24,7 +24,7 @@ public final class ServerInfo implements Comparable { /** * 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) { diff --git a/api/src/main/java/com/velocitypowered/api/proxy/server/ServerPing.java b/api/src/main/java/com/velocitypowered/api/proxy/server/ServerPing.java index 0503cb9f47..d4f1688d65 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/server/ServerPing.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/server/ServerPing.java @@ -40,11 +40,11 @@ public ServerPing(Version version, @Nullable Players players, /** * 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 int hashCode() { } /** - * 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 String toString() { } /** - * 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 static final class Version { * 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 int hashCode() { } /** - * 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 static final class Players { * 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 sample) { diff --git a/api/src/main/java/com/velocitypowered/api/scheduler/Scheduler.java b/api/src/main/java/com/velocitypowered/api/scheduler/Scheduler.java index c7666b0381..4c53decbba 100644 --- a/api/src/main/java/com/velocitypowered/api/scheduler/Scheduler.java +++ b/api/src/main/java/com/velocitypowered/api/scheduler/Scheduler.java @@ -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 */ diff --git a/api/src/main/java/com/velocitypowered/api/util/FastUuidSansHyphens.java b/api/src/main/java/com/velocitypowered/api/util/FastUuidSansHyphens.java index 75c237876e..f49c420d4c 100644 --- a/api/src/main/java/com/velocitypowered/api/util/FastUuidSansHyphens.java +++ b/api/src/main/java/com/velocitypowered/api/util/FastUuidSansHyphens.java @@ -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 @@ private 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 @@ static UUID parseUuid(final CharSequence uuidSequence) { * 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 @@ public static String toString(final UUID uuid) { 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 @@ public static String toString(final UUID uuid) { 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); } diff --git a/api/src/main/java/com/velocitypowered/api/util/GameProfile.java b/api/src/main/java/com/velocitypowered/api/util/GameProfile.java index f3bae8d9f2..deb13b2ec4 100644 --- a/api/src/main/java/com/velocitypowered/api/util/GameProfile.java +++ b/api/src/main/java/com/velocitypowered/api/util/GameProfile.java @@ -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 properties) { @@ -38,7 +38,7 @@ public GameProfile(UUID id, String name, List properties) { * 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 properties) { @@ -190,8 +190,8 @@ public static final class Property { /** * 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) { diff --git a/api/src/main/java/com/velocitypowered/api/util/ModInfo.java b/api/src/main/java/com/velocitypowered/api/util/ModInfo.java index 945246178c..1cf9872afd 100644 --- a/api/src/main/java/com/velocitypowered/api/util/ModInfo.java +++ b/api/src/main/java/com/velocitypowered/api/util/ModInfo.java @@ -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 modList) { diff --git a/api/src/main/java/com/velocitypowered/api/util/ProxyVersion.java b/api/src/main/java/com/velocitypowered/api/util/ProxyVersion.java index 5b51573073..797add19a7 100644 --- a/api/src/main/java/com/velocitypowered/api/util/ProxyVersion.java +++ b/api/src/main/java/com/velocitypowered/api/util/ProxyVersion.java @@ -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) { diff --git a/api/src/test/java/com/velocitypowered/api/proxy/messages/MinecraftChannelIdentifierTest.java b/api/src/test/java/com/velocitypowered/api/proxy/messages/MinecraftChannelIdentifierTest.java deleted file mode 100644 index 4c8919f3aa..0000000000 --- a/api/src/test/java/com/velocitypowered/api/proxy/messages/MinecraftChannelIdentifierTest.java +++ /dev/null @@ -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::")) - ); - } - - -} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/velocity-init-manifest.gradle.kts b/build-logic/src/main/kotlin/velocity-init-manifest.gradle.kts index e2e6211313..381bb8f17f 100644 --- a/build-logic/src/main/kotlin/velocity-init-manifest.gradle.kts +++ b/build-logic/src/main/kotlin/velocity-init-manifest.gradle.kts @@ -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 { 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 } } diff --git a/build-logic/src/main/kotlin/velocity-spotless.gradle.kts b/build-logic/src/main/kotlin/velocity-spotless.gradle.kts index cbd3f3d46a..7e01d5c1b6 100644 --- a/build-logic/src/main/kotlin/velocity-spotless.gradle.kts +++ b/build-logic/src/main/kotlin/velocity-spotless.gradle.kts @@ -10,6 +10,7 @@ extensions.configure { } else { licenseHeaderFile(rootProject.file("HEADER.txt")) } + importOrder() removeUnusedImports() } } diff --git a/config/checkstyle/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml index f5da6ed235..3a6f8857e1 100644 --- a/config/checkstyle/checkstyle-suppressions.xml +++ b/config/checkstyle/checkstyle-suppressions.xml @@ -6,7 +6,7 @@ + files="src/main/java/com/velocitypowered/proxy/network/protocol/packet/*"/> + files="src/main/java/com/velocitypowered/proxy/network/protocol/packet/*"/> \ No newline at end of file diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 204cc842fa..bc642712e6 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -32,7 +32,7 @@ + default="checkstyle-suppressions.xml"/> @@ -45,7 +45,8 @@ - + @@ -104,7 +105,7 @@ - + @@ -356,14 +357,14 @@ + default="checkstyle-xpath-suppressions.xml"/> - + - - - + + + diff --git a/native/README.md b/native/README.md index d4efcf1872..a1cb366a09 100644 --- a/native/README.md +++ b/native/README.md @@ -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. \ No newline at end of file +Alpine Linux support is on a "best-effort" basis only. Using `apk add libc6-compat` may enable +native support. \ No newline at end of file diff --git a/native/src/main/java/com/velocitypowered/natives/Native.java b/native/src/main/java/com/velocitypowered/natives/Native.java index c2478dabfd..b7c47b6f61 100644 --- a/native/src/main/java/com/velocitypowered/natives/Native.java +++ b/native/src/main/java/com/velocitypowered/natives/Native.java @@ -23,5 +23,6 @@ * Generic interface for any Velocity native. */ public interface Native { + BufferPreference preferredBufferType(); } diff --git a/native/src/main/java/com/velocitypowered/natives/compression/CompressorUtils.java b/native/src/main/java/com/velocitypowered/natives/compression/CompressorUtils.java index 8230ba2049..c7a9985785 100644 --- a/native/src/main/java/com/velocitypowered/natives/compression/CompressorUtils.java +++ b/native/src/main/java/com/velocitypowered/natives/compression/CompressorUtils.java @@ -21,6 +21,7 @@ import java.util.zip.DataFormatException; class CompressorUtils { + /** * The default preferred output buffer size for zlib. */ diff --git a/native/src/main/java/com/velocitypowered/natives/compression/NativeZlibInflate.java b/native/src/main/java/com/velocitypowered/natives/compression/NativeZlibInflate.java index 2ad7bc41e8..c2b10b3e49 100644 --- a/native/src/main/java/com/velocitypowered/natives/compression/NativeZlibInflate.java +++ b/native/src/main/java/com/velocitypowered/natives/compression/NativeZlibInflate.java @@ -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; } diff --git a/native/src/main/java/com/velocitypowered/natives/compression/VelocityCompressor.java b/native/src/main/java/com/velocitypowered/natives/compression/VelocityCompressor.java index 393104983f..c33d1b6650 100644 --- a/native/src/main/java/com/velocitypowered/natives/compression/VelocityCompressor.java +++ b/native/src/main/java/com/velocitypowered/natives/compression/VelocityCompressor.java @@ -27,6 +27,7 @@ * implementation. */ public interface VelocityCompressor extends Disposable, Native { + void inflate(ByteBuf source, ByteBuf destination, int uncompressedSize) throws DataFormatException; diff --git a/native/src/main/java/com/velocitypowered/natives/encryption/JavaVelocityCipher.java b/native/src/main/java/com/velocitypowered/natives/encryption/JavaVelocityCipher.java index 58a7da5800..7256b2c889 100644 --- a/native/src/main/java/com/velocitypowered/natives/encryption/JavaVelocityCipher.java +++ b/native/src/main/java/com/velocitypowered/natives/encryption/JavaVelocityCipher.java @@ -68,7 +68,7 @@ public void process(ByteBuf source) { 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"); } } diff --git a/native/src/main/java/com/velocitypowered/natives/util/MoreByteBufUtils.java b/native/src/main/java/com/velocitypowered/natives/util/MoreByteBufUtils.java index fbad62bf91..3d2d81594f 100644 --- a/native/src/main/java/com/velocitypowered/natives/util/MoreByteBufUtils.java +++ b/native/src/main/java/com/velocitypowered/natives/util/MoreByteBufUtils.java @@ -25,6 +25,7 @@ * Additional utilities for {@link ByteBuf}. */ public class MoreByteBufUtils { + private MoreByteBufUtils() { throw new AssertionError(); } @@ -34,9 +35,9 @@ private 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 @@ private static boolean isCompatible(Native nativeStuff, ByteBuf buf) { * 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 */ diff --git a/native/src/main/java/com/velocitypowered/natives/util/NativeConstraints.java b/native/src/main/java/com/velocitypowered/natives/util/NativeConstraints.java index f707ab248a..cfc5e6e2f1 100644 --- a/native/src/main/java/com/velocitypowered/natives/util/NativeConstraints.java +++ b/native/src/main/java/com/velocitypowered/natives/util/NativeConstraints.java @@ -25,6 +25,7 @@ * 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; diff --git a/native/src/main/java/com/velocitypowered/natives/util/Natives.java b/native/src/main/java/com/velocitypowered/natives/util/Natives.java index d33ce985d9..50268dda7c 100644 --- a/native/src/main/java/com/velocitypowered/natives/util/Natives.java +++ b/native/src/main/java/com/velocitypowered/natives/util/Natives.java @@ -125,7 +125,7 @@ private static Path createTemporaryNativeFilename(String ext) throws IOException 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) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java index 4febf19eaa..962532516b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java @@ -24,8 +24,7 @@ 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 { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 1eb387c688..1437c8a142 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -28,8 +28,8 @@ 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; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/SuggestionsProvider.java b/proxy/src/main/java/com/velocitypowered/proxy/command/SuggestionsProvider.java index 93088cf623..6fbe72310b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/SuggestionsProvider.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/SuggestionsProvider.java @@ -33,7 +33,7 @@ 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 @@ private CompletableFuture provideAliasSuggestions( } final Collection> aliases = contextSoFar.getRootNode().getChildren(); - @SuppressWarnings("unchecked") - final CompletableFuture[] futures = new CompletableFuture[aliases.size()]; + @SuppressWarnings("unchecked") final CompletableFuture[] futures = + new CompletableFuture[aliases.size()]; int i = 0; for (final CommandNode node : aliases) { CompletableFuture future = Suggestions.empty(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java index 0b743371c6..f2f25e0714 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java @@ -122,15 +122,15 @@ public void register(final CommandMeta meta, final Command command) { final List> 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); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java index 2fc53da7d1..7ade921118 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java @@ -28,8 +28,8 @@ 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; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/SendCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/SendCommand.java index 94c14085a0..85df6a704a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/SendCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/SendCommand.java @@ -25,9 +25,9 @@ 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 @@ * 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 SendCommand(ProxyServer server) { */ public void register() { LiteralCommandNode totalNode = LiteralArgumentBuilder - .literal("send") - .requires(source -> - source.getPermissionValue("velocity.command.send") == TriState.TRUE) - .executes(this::usage) - .build(); + .literal("send") + .requires(source -> + source.getPermissionValue("velocity.command.send") == TriState.TRUE) + .executes(this::usage) + .build(); ArgumentCommandNode playerNode = RequiredArgumentBuilder - .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(); + .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 serverNode = RequiredArgumentBuilder - .argument("server", StringArgumentType.word()) - .suggests((context, builder) -> { - for (RegisteredServer server : server.registeredServers()) { - builder.suggest(server.serverInfo().name()); - } - return builder.buildFuture(); - }) - .executes(this::send) - .build(); + .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 void register() { private int usage(CommandContext 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 @@ private int send(CommandContext context) { 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 @@ private int send(CommandContext context) { && !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; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java index e12712c954..c9ec0e9e1d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java @@ -22,9 +22,9 @@ 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; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java index a7d7c85a1f..1cdbda8608 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java @@ -413,6 +413,7 @@ public boolean hasPermission(final CommandSource source, final String @NonNull [ * Heap SubCommand. */ public static class Heap implements SubCommand { + private static final Logger logger = LogManager.getLogger(Heap.class); private MethodHandle heapGenerator; private Consumer heapConsumer; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java index 0061a7753e..bb87c20098 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -381,8 +381,8 @@ public void setState(StateRegistry state) { public void addPlayPacketQueueHandler() { if (this.channel.pipeline().get(Connections.PLAY_PACKET_QUEUE) == null) { this.channel.pipeline().addAfter(Connections.MINECRAFT_ENCODER, Connections.PLAY_PACKET_QUEUE, - new PlayPacketQueueHandler(this.protocolVersion, - channel.pipeline().get(MinecraftEncoder.class).getDirection())); + new PlayPacketQueueHandler(this.protocolVersion, + channel.pipeline().get(MinecraftEncoder.class).getDirection())); } } @@ -429,7 +429,7 @@ public void setProtocolVersion(ProtocolVersion protocolVersion) { * @param sessionHandler the handler to use */ public void setActiveSessionHandler(StateRegistry registry, - MinecraftSessionHandler sessionHandler) { + MinecraftSessionHandler sessionHandler) { Preconditions.checkNotNull(registry); ensureInEventLoop(); @@ -487,8 +487,8 @@ private void ensureOpen() { } /** - * Sets the compression threshold on the connection. You are responsible for sending {@link - * SetCompression} beforehand. + * Sets the compression threshold on the connection. You are responsible for sending + * {@link SetCompression} beforehand. * * @param threshold the compression threshold to use */ diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhase.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhase.java index 7b89882aeb..ae4a1e41a8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhase.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhase.java @@ -32,8 +32,8 @@ public interface BackendConnectionPhase { /** * Handle a plugin message in the context of this phase. * - * @param server the server connection - * @param player the player + * @param server the server connection + * @param player the player * @param message The message to handle * @return true if handled, false otherwise. */ diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java index 8c2423566b..3ca4e44492 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java @@ -18,10 +18,9 @@ package com.velocitypowered.proxy.connection.backend; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.api.proxy.Player; -import com.velocitypowered.api.proxy.ServerConnection; -import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; -import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; +import com.velocitypowered.api.network.connection.ServerConnection; +import com.velocitypowered.api.proxy.messages.ChannelIdentifier; +import com.velocitypowered.api.proxy.player.Player; import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.ServerInfo; import com.velocitypowered.api.util.UuidUtils; @@ -41,27 +40,28 @@ import java.util.Optional; import java.util.StringJoiner; import net.kyori.adventure.identity.Identity; +import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.ComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; /** - * Handles messages coming from servers trying to communicate with the BungeeCord plugin - * messaging channel interface. + * Handles messages coming from servers trying to communicate with the BungeeCord plugin messaging + * channel interface. */ @SuppressFBWarnings( value = "OS_OPEN_STREAM", justification = "Most methods in this class open " - + "instances of ByteBufDataOutput backed by heap-allocated ByteBufs. Closing them does " - + "nothing." + + "instances of ByteBufDataOutput backed by heap-allocated ByteBufs. Closing them does " + + "nothing." ) public class BungeeCordMessageResponder { - private static final MinecraftChannelIdentifier MODERN_CHANNEL = MinecraftChannelIdentifier - .create("bungeecord", "main"); - private static final LegacyChannelIdentifier LEGACY_CHANNEL = - new LegacyChannelIdentifier("BungeeCord"); + private static final ChannelIdentifier MODERN_CHANNEL = ChannelIdentifier.ofKey( + Key.key("bungeecord", "main")); + private static final ChannelIdentifier LEGACY_CHANNEL = + ChannelIdentifier.legacy("BungeeCord"); private final VelocityServer proxy; private final ConnectedPlayer player; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java index 5ceca080a1..12e7aac29e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java @@ -72,7 +72,7 @@ public class ConfigSessionHandler implements MinecraftSessionHandler { * @param resultFuture the result future */ ConfigSessionHandler(VelocityServer server, VelocityServerConnection serverConn, - CompletableFuture resultFuture) { + CompletableFuture resultFuture) { this.server = server; this.serverConn = serverConn; this.resultFuture = resultFuture; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java index f9166d9a91..81dbee023c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java @@ -20,7 +20,7 @@ import com.velocitypowered.api.event.player.ServerLoginPluginMessageEvent; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; -import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; +import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.config.PlayerInfoForwarding; import com.velocitypowered.proxy.config.VelocityConfiguration; @@ -50,6 +50,7 @@ import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; +import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -108,8 +109,7 @@ public boolean handle(LoginPluginMessage packet) { } final byte[] contents = ByteBufUtil.getBytes(packet.content()); - final MinecraftChannelIdentifier identifier = MinecraftChannelIdentifier - .from(packet.getChannel()); + final ChannelIdentifier identifier = ChannelIdentifier.ofKey(Key.key(packet.getChannel())); this.server.eventManager().fire(new ServerLoginPluginMessageEvent(serverConn, identifier, contents, packet.getId())) .thenAcceptAsync(event -> { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index ed3ec026db..257cab0401 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -24,7 +24,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.velocitypowered.api.network.ProtocolVersion; -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.server.RegisteredServer; import com.velocitypowered.api.proxy.server.ServerInfo; @@ -95,8 +95,8 @@ public VelocityServerConnection(VelocityRegisteredServer registeredServer, /** * Connects to the server. * - * @return a {@link com.velocitypowered.api.proxy.ConnectionRequestBuilder.Result} - * representing whether the connection succeeded + * @return a {@link com.velocitypowered.api.proxy.ConnectionRequestBuilder.Result} representing + * whether the connection succeeded */ public CompletableFuture connect() { CompletableFuture result = new CompletableFuture<>(); @@ -357,8 +357,7 @@ public void setConnectionPhase(BackendConnectionPhase connectionPhase) { } /** - * Gets whether the {@link JoinGame} packet has been - * sent by this server. + * Gets whether the {@link JoinGame} packet has been sent by this server. * * @return Whether the join has been completed. */ diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index d6a9d08e08..816c448a93 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -28,8 +28,6 @@ import com.velocitypowered.api.event.player.TabCompleteEvent; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; -import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; -import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.ConnectionTypes; import com.velocitypowered.proxy.connection.MinecraftConnection; @@ -80,6 +78,7 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentLinkedQueue; +import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.apache.logging.log4j.LogManager; @@ -288,9 +287,9 @@ public boolean handle(PluginMessage packet) { // Handling edge case when packet with FML client handshake (state COMPLETE) // arrives after JoinGame packet from destination server VelocityServerConnection serverConn = - (player.getConnectedServer() == null - && packet.getChannel().equals( - LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) + (player.getConnectedServer() == null + && packet.getChannel().equals( + LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) ? player.getConnectionInFlight() : player.getConnectedServer(); MinecraftConnection backendConn = serverConn != null ? serverConn.getConnection() : null; @@ -303,9 +302,9 @@ public boolean handle(PluginMessage packet) { List channelIdentifiers = new ArrayList<>(); for (String channel : channels) { try { - channelIdentifiers.add(MinecraftChannelIdentifier.from(channel)); + channelIdentifiers.add(ChannelIdentifier.ofKey(Key.key(channel))); } catch (IllegalArgumentException e) { - channelIdentifiers.add(new LegacyChannelIdentifier(channel)); + channelIdentifiers.add(ChannelIdentifier.legacy(channel)); } } server.eventManager() @@ -539,7 +538,7 @@ public void handleBackendJoinGame(JoinGame joinGame, VelocityServerConnection de // Tell the server about the proxy's plugin message channels. ProtocolVersion serverVersion = serverMc.getProtocolVersion(); final Collection channels = server.channelRegistrar() - .getChannelsForProtocol(serverMc.getProtocolVersion()); + .getChannelsForProtocol(serverMc.getProtocolVersion()); if (!channels.isEmpty()) { serverMc.delayedWrite(constructChannelsPacket(serverVersion, channels)); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 6b2607fecd..cd891ac872 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -35,13 +35,13 @@ import com.velocitypowered.api.event.player.PlayerSettingsChangedEvent; import com.velocitypowered.api.event.player.ServerPreConnectEvent; import com.velocitypowered.api.network.ProtocolVersion; +import com.velocitypowered.api.network.connection.ServerConnection; import com.velocitypowered.api.permission.PermissionProvider; import com.velocitypowered.api.proxy.ConnectionRequestBuilder; -import com.velocitypowered.api.proxy.Player; -import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.api.proxy.crypto.KeyIdentifiable; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; +import com.velocitypowered.api.proxy.player.Player; import com.velocitypowered.api.proxy.player.PlayerSettings; import com.velocitypowered.api.proxy.player.ResourcePackInfo; import com.velocitypowered.api.proxy.server.RegisteredServer; @@ -709,7 +709,7 @@ private void handleConnectionException(RegisteredServer rs, } private void handleKickEvent(KickedFromServerEvent originalEvent, Component friendlyReason, - boolean kickedFromCurrent) { + boolean kickedFromCurrent) { server.eventManager().fire(originalEvent).thenAcceptAsync(event -> { // There can't be any connection in flight now. connectionInFlight = null; @@ -1093,7 +1093,7 @@ public boolean onResourcePackResponse(PlayerResourcePackStatusEvent.Status statu */ public void sendKeepAlive() { if (connection.getState() == StateRegistry.PLAY - || connection.getState() == StateRegistry.CONFIG) { + || connection.getState() == StateRegistry.CONFIG) { KeepAlive keepAlive = new KeepAlive(); keepAlive.setRandomId(ThreadLocalRandom.current().nextLong()); connection.write(keepAlive); @@ -1107,7 +1107,7 @@ public void switchToConfigState() { CompletableFuture.runAsync(() -> { connection.write(new StartUpdate()); connection.getChannel().pipeline() - .get(MinecraftEncoder.class).setState(StateRegistry.CONFIG); + .get(MinecraftEncoder.class).setState(StateRegistry.CONFIG); // Make sure we don't send any play packets to the player after update start connection.addPlayPacketQueueHandler(); }, connection.eventLoop()).exceptionally((ex) -> { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java index 083a6cb29c..20d83c1da1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java @@ -30,8 +30,8 @@ import org.apache.logging.log4j.Logger; /** - * Handles the play state between exiting the login phase and establishing the first connection - * to a backend server. + * Handles the play state between exiting the login phase and establishing the first connection to a + * backend server. */ public class InitialConnectSessionHandler implements MinecraftSessionHandler { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java index 24f3aca082..6e5623ebcc 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java @@ -18,7 +18,7 @@ package com.velocitypowered.proxy.connection.client; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.api.proxy.InboundConnection; +import com.velocitypowered.api.network.connection.InboundConnection; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation; import com.velocitypowered.proxy.connection.util.VelocityInboundConnection; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginInboundConnection.java index 894ccc9d8e..b7930f2814 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginInboundConnection.java @@ -18,7 +18,7 @@ package com.velocitypowered.proxy.connection.client; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.api.proxy.LoginPhaseConnection; +import com.velocitypowered.api.network.connection.LoginPhaseConnection; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.api.proxy.crypto.KeyIdentifiable; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeClientPhase.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeClientPhase.java index 6cf2e7a332..8a9af25dff 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeClientPhase.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeClientPhase.java @@ -76,9 +76,9 @@ LegacyForgeHandshakeClientPhase nextPhase() { }, /** - * The Mod list is sent to the server, captured by Velocity. Transition to {@link - * #WAITING_SERVER_DATA} when an ACK is sent, which indicates to the server to start sending state - * data. + * The Mod list is sent to the server, captured by Velocity. Transition to + * {@link #WAITING_SERVER_DATA} when an ACK is sent, which indicates to the server to start + * sending state data. */ MOD_LIST(LegacyForgeConstants.ACK_DISCRIMINATOR) { @Override @@ -139,9 +139,10 @@ LegacyForgeHandshakeClientPhase nextPhase() { * The handshake is complete. The handshake can be reset. * *

Note that a successful connection to a server does not mean that we will be in this state. - * After a handshake reset, if the next server is vanilla we will still be in the {@link - * #NOT_STARTED} phase, which means we must NOT send a reset packet. This is handled by overriding - * the {@link #resetConnectionPhase(ConnectedPlayer)} in this element (it is usually a no-op). + * After a handshake reset, if the next server is vanilla we will still be in the + * {@link #NOT_STARTED} phase, which means we must NOT send a reset packet. This is handled by + * overriding the {@link #resetConnectionPhase(ConnectedPlayer)} in this element (it is usually a + * no-op). */ COMPLETE(null) { @Override @@ -181,8 +182,8 @@ boolean onHandle(ConnectedPlayer player, * * @param packetToAdvanceOn The ID of the packet discriminator that indicates that the client has * moved onto a new phase, and as such, Velocity should do so too - * (inspecting {@link #nextPhase()}. A null indicates there is - * no further phase to transition to. + * (inspecting {@link #nextPhase()}. A null indicates there is no further + * phase to transition to. */ LegacyForgeHandshakeClientPhase(Integer packetToAdvanceOn) { this.packetToAdvanceOn = packetToAdvanceOn; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/ClientConfigData.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/ClientConfigData.java index 84ed2a5bbe..aa6a62a008 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/ClientConfigData.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/ClientConfigData.java @@ -23,8 +23,7 @@ import org.jetbrains.annotations.Nullable; /** - * Holds the registry data that is sent - * to the client during the config stage. + * Holds the registry data that is sent to the client during the config stage. */ public class ClientConfigData { @@ -35,7 +34,7 @@ public class ClientConfigData { private final String brand; private ClientConfigData(@Nullable VelocityResourcePackInfo resourcePackInfo, DataTag tag, - RegistrySync registry, Key[] features, String brand) { + RegistrySync registry, Key[] features, String brand) { this.resourcePackInfo = resourcePackInfo; this.tag = tag; this.registry = registry; @@ -76,6 +75,7 @@ public static ClientConfigData.Builder builder() { * Builder for ClientConfigData. */ public static class Builder { + private VelocityResourcePackInfo resourcePackInfo; private DataTag tag; private RegistrySync registry; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/DataTag.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/DataTag.java index 9a7d0de737..4cb93571aa 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/DataTag.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/DataTag.java @@ -27,6 +27,7 @@ * Represents a data tag. */ public class DataTag { + private final ImmutableList entrySets; public DataTag(ImmutableList entrySets) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionTypeImpl.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionTypeImpl.java index 9e421c5371..127f81ed13 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionTypeImpl.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionTypeImpl.java @@ -53,4 +53,3 @@ public GameProfile addGameProfileTokensIfRequired(GameProfile original, return original; } } - diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java index 76cdff1e8e..af8cd5f6a6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java @@ -75,7 +75,7 @@ private CompletableFuture attemptPingPassthrough(VelocityInboundConn } VelocityRegisteredServer vrs = (VelocityRegisteredServer) rs.get(); pings.add(vrs.ping(connection.getConnection().eventLoop(), PingOptions.builder() - .version(responseProtocolVersion).build())); + .version(responseProtocolVersion).build())); } if (pings.isEmpty()) { return CompletableFuture.completedFuture(fallback); @@ -162,11 +162,10 @@ public CompletableFuture getInitialPing(VelocityInboundConnection co } /** - * Gets the current server ping for this connection, firing {@code ProxyPingEvent} if the - * ping is not cached. + * Gets the current server ping for this connection, firing {@code ProxyPingEvent} if the ping is + * not cached. * * @param connection the connection being pinged - * * @return the server ping as a completable future */ public CompletableFuture getPing(VelocityInboundConnection connection) { @@ -176,11 +175,10 @@ public CompletableFuture getPing(VelocityInboundConnection connectio } /** - * Gets the current server ping for this connection, firing {@code ProxyPingEvent} if the - * ping is not cached. + * Gets the current server ping for this connection, firing {@code ProxyPingEvent} if the ping is + * not cached. * * @param connection the connection being pinged - * * @return the server ping as a completable future */ public CompletableFuture getPacketResponse(VelocityInboundConnection connection) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/VelocityInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/VelocityInboundConnection.java index 31a8863994..c9ea3e0a1e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/VelocityInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/VelocityInboundConnection.java @@ -17,7 +17,7 @@ package com.velocitypowered.proxy.connection.util; -import com.velocitypowered.api.proxy.InboundConnection; +import com.velocitypowered.api.network.connection.InboundConnection; import com.velocitypowered.proxy.connection.MinecraftConnection; /** diff --git a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java index da95f1118a..071bde1ae5 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java @@ -45,14 +45,14 @@ import org.jline.reader.LineReaderBuilder; /** - * Implements the Velocity console, including sending commands and being the recipient - * of messages from plugins. + * Implements the Velocity console, including sending commands and being the recipient of messages + * from plugins. */ public final class VelocityConsole extends SimpleTerminalConsole implements ConsoleCommandSource { private static final Logger logger = LogManager.getLogger(VelocityConsole.class); private static final ComponentLogger componentLogger = ComponentLogger - .logger(VelocityConsole.class); + .logger(VelocityConsole.class); private final VelocityServer server; private PermissionChecker permissionChecker = PermissionChecker.always(TriState.TRUE); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/event/VelocityEventManager.java b/proxy/src/main/java/com/velocitypowered/proxy/event/VelocityEventManager.java index 8d53ce315b..3d2b8d9e15 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/event/VelocityEventManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/event/VelocityEventManager.java @@ -561,8 +561,8 @@ public void run() { } /** - * Executes the task and returns whether the next handler should be executed immediately - * after this one, without additional scheduling. + * Executes the task and returns whether the next handler should be executed immediately after + * this one, without additional scheduling. */ boolean execute() { state = TASK_STATE_EXECUTING; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java index 4fe2f21e74..49adbe3812 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java @@ -27,7 +27,7 @@ import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.plugin.PluginContainer; import com.velocitypowered.api.plugin.PluginDescription; -import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.player.Player; import com.velocitypowered.api.proxy.server.QueryResponse; import com.velocitypowered.proxy.VelocityServer; import io.netty.buffer.ByteBuf; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderV2.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderV2.java index 22c529ca0d..4b3360c26e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderV2.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderV2.java @@ -18,7 +18,7 @@ package com.velocitypowered.proxy.network.protocol.packet.chat.builder; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.player.Player; import com.velocitypowered.proxy.network.protocol.MinecraftPacket; import com.velocitypowered.proxy.network.protocol.packet.chat.ChatType; import java.time.Instant; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginContainer.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginContainer.java index b71c919787..92b3859ed8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginContainer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginContainer.java @@ -59,10 +59,10 @@ public ExecutorService executorService() { String name = this.description.name().orElse(this.description.id()); this.service = Executors.unconfigurableExecutorService( Executors.newCachedThreadPool( - new ThreadFactoryBuilder().setDaemon(true) - .setNameFormat(name + " - Task Executor #%d") - .setDaemon(true) - .build() + new ThreadFactoryBuilder().setDaemon(true) + .setNameFormat(name + " - Task Executor #%d") + .setDaemon(true) + .build() ) ); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/provider/ComponentLoggerProviderImpl.java b/proxy/src/main/java/com/velocitypowered/proxy/provider/ComponentLoggerProviderImpl.java index df29ca56f6..b8ca759ef6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/provider/ComponentLoggerProviderImpl.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/provider/ComponentLoggerProviderImpl.java @@ -29,14 +29,15 @@ */ @SuppressWarnings("UnstableApiUsage") public final class ComponentLoggerProviderImpl implements ComponentLoggerProvider { + private static final ANSIComponentSerializer SERIALIZER = ANSIComponentSerializer.builder() - .flattener(TranslatableMapper.FLATTENER) - .build(); + .flattener(TranslatableMapper.FLATTENER) + .build(); @Override public @NotNull ComponentLogger logger( - final @NotNull LoggerHelper helper, - final @NotNull String name + final @NotNull LoggerHelper helper, + final @NotNull String name ) { return helper.delegating(LoggerFactory.getLogger(name), SERIALIZER::serialize); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java b/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java index 90e65a342b..b53ce133da 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java @@ -53,9 +53,8 @@ /** * The Velocity "scheduler", which is actually a thin wrapper around - * {@link ScheduledExecutorService} and a dynamically-sized {@link ExecutorService}. - * Many plugins are accustomed to the Bukkit Scheduler model, although it is not relevant - * in a proxy context. + * {@link ScheduledExecutorService} and a dynamically-sized {@link ExecutorService}. Many plugins + * are accustomed to the Bukkit Scheduler model, although it is not relevant in a proxy context. */ public class VelocityScheduler implements Scheduler { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/server/PingSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/server/PingSessionHandler.java index 88c0c813ab..fe4ed6b3aa 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/server/PingSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/server/PingSessionHandler.java @@ -34,8 +34,8 @@ import java.util.concurrent.CompletableFuture; /** - * Session handler used to implement {@link VelocityRegisteredServer#ping(EventLoop, - * ProtocolVersion)}. + * Session handler used to implement + * {@link VelocityRegisteredServer#ping(EventLoop, ProtocolVersion)}. */ public class PingSessionHandler implements MinecraftSessionHandler { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java b/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java index 94597e5223..afe8d54f41 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java @@ -21,8 +21,8 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; -import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; +import com.velocitypowered.api.proxy.player.Player; import com.velocitypowered.api.proxy.server.PingOptions; import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.ServerInfo; @@ -83,10 +83,10 @@ public CompletableFuture ping() { } /** - * Pings the specified server using the specified event {@code loop}, claiming to be {@code - * version}. + * Pings the specified server using the specified event {@code loop}, claiming to be + * {@code version}. * - * @param loop the event loop to use + * @param loop the event loop to use * @param pingOptions the options to apply to this ping * @return the server list ping response */ @@ -141,7 +141,7 @@ public boolean sendPluginMessage(ChannelIdentifier identifier, ByteBuf data) { for (ConnectedPlayer player : players.values()) { VelocityServerConnection serverConnection = player.getConnectedServer(); if (serverConnection != null && serverConnection.getConnection() != null - && serverConnection.server() == this) { + && serverConnection.server() == this) { return serverConnection.sendPluginMessage(identifier, data); } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java index ecdb68eea7..8d6762f366 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java @@ -18,10 +18,10 @@ package com.velocitypowered.proxy.tablist; import com.google.common.base.Preconditions; -import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.api.proxy.player.ChatSession; +import com.velocitypowered.api.proxy.player.Player; import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.connection.MinecraftConnection; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/TranslatableMapper.java b/proxy/src/main/java/com/velocitypowered/proxy/util/TranslatableMapper.java index c2ca2366fe..d4c45c577c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/TranslatableMapper.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/TranslatableMapper.java @@ -36,19 +36,19 @@ public enum TranslatableMapper implements BiConsumer componentConsumer + final TranslatableComponent translatableComponent, + final Consumer componentConsumer ) { for (final Translator source : GlobalTranslator.translator().sources()) { if (source instanceof TranslationRegistry - && ((TranslationRegistry) source).contains(translatableComponent.key())) { + && ((TranslationRegistry) source).contains(translatableComponent.key())) { componentConsumer.accept(GlobalTranslator.render(translatableComponent, - ClosestLocaleMatcher.INSTANCE.lookupClosest(Locale.getDefault()))); + ClosestLocaleMatcher.INSTANCE.lookupClosest(Locale.getDefault()))); return; } } @@ -58,10 +58,10 @@ public void accept( } for (final Translator source : GlobalTranslator.translator().sources()) { if (source instanceof TranslationRegistry - && ((TranslationRegistry) source).contains(fallback)) { + && ((TranslationRegistry) source).contains(fallback)) { componentConsumer.accept( - GlobalTranslator.render(Component.translatable(fallback), - ClosestLocaleMatcher.INSTANCE.lookupClosest(Locale.getDefault()))); + GlobalTranslator.render(Component.translatable(fallback), + ClosestLocaleMatcher.INSTANCE.lookupClosest(Locale.getDefault()))); return; } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java b/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java index ff6a978865..25a9c3f47d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java @@ -17,12 +17,9 @@ package com.velocitypowered.proxy.util; -import com.google.common.base.Preconditions; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.api.proxy.messages.ChannelRegistrar; -import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; -import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.proxy.network.protocol.util.PluginMessageUtil; import java.util.Collection; import java.util.HashSet; @@ -37,15 +34,14 @@ public class VelocityChannelRegistrar implements ChannelRegistrar { private final Map identifierMap = new ConcurrentHashMap<>(); + private static boolean isModernIdentifier(ChannelIdentifier identifier) { + return identifier.id().indexOf(':') != -1; + } + @Override public void register(ChannelIdentifier... identifiers) { for (ChannelIdentifier identifier : identifiers) { - Preconditions.checkArgument(identifier instanceof LegacyChannelIdentifier - || identifier instanceof MinecraftChannelIdentifier, "identifier is unknown"); - } - - for (ChannelIdentifier identifier : identifiers) { - if (identifier instanceof MinecraftChannelIdentifier) { + if (isModernIdentifier(identifier)) { identifierMap.put(identifier.id(), identifier); } else { String rewritten = PluginMessageUtil.transformLegacyToModernChannel(identifier.id()); @@ -58,13 +54,7 @@ public void register(ChannelIdentifier... identifiers) { @Override public void unregister(ChannelIdentifier... identifiers) { for (ChannelIdentifier identifier : identifiers) { - Preconditions.checkArgument(identifier instanceof LegacyChannelIdentifier - || identifier instanceof MinecraftChannelIdentifier, - "identifier is unknown"); - } - - for (ChannelIdentifier identifier : identifiers) { - if (identifier instanceof MinecraftChannelIdentifier) { + if (isModernIdentifier(identifier)) { identifierMap.remove(identifier.id()); } else { String rewritten = PluginMessageUtil.transformLegacyToModernChannel(identifier.id()); @@ -95,7 +85,7 @@ public Collection getLegacyChannelIds() { public Collection getModernChannelIds() { Collection ids = new HashSet<>(); for (ChannelIdentifier value : identifierMap.values()) { - if (value instanceof MinecraftChannelIdentifier) { + if (isModernIdentifier(value)) { ids.add(value.id()); } else { ids.add(PluginMessageUtil.transformLegacyToModernChannel(value.id())); diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages.properties index f5b6ae9b4a..8179efd58c 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=You are already connected to this server! velocity.error.already-connected-proxy=You are already connected to this proxy! velocity.error.already-connecting=You are already trying to connect to a server! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ar_SA.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ar_SA.properties index c4ecba29ec..979d72865f 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ar_SA.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ar_SA.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=أنت بالفعل متصل بهذا السيرفر\! velocity.error.already-connected-proxy=أنت بالفعل متصل بهذا الوكيل\! velocity.error.already-connecting=أنت بالفعل تحاول الاتصال بأحد السيرفرات\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_bg_BG.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_bg_BG.properties index 33d8333dde..54f7263691 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_bg_BG.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_bg_BG.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=You are already connected to this server\! velocity.error.already-connected-proxy=You are already connected to this proxy\! velocity.error.already-connecting=You are already trying to connect to a server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_cs_CZ.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_cs_CZ.properties index 6e6a0fe4d2..d80d106ef9 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_cs_CZ.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_cs_CZ.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=K tomuto serveru jsi již připojen\! velocity.error.already-connected-proxy=K tomuto proxy serveru jsi již připojen\! velocity.error.already-connecting=Již se pokoušíš o připojení k serveru\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_da_DK.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_da_DK.properties index 4205eb1672..946d9c6705 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_da_DK.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_da_DK.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Du er allerede tilsluttet til den server\! velocity.error.already-connected-proxy=Du er allerede tilsluttet til proxyen\! velocity.error.already-connecting=Du forsøger allerede at oprette forbindelse til en server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_de_DE.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_de_DE.properties index fe42c07a7d..9dd1eec8f1 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_de_DE.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_de_DE.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Du bist bereits mit diesem Server verbunden\! velocity.error.already-connected-proxy=Du bist bereits mit diesem Proxy verbunden\! velocity.error.already-connecting=Du versuchst bereits eine Verbindung mit dem Server herzustellen\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_es_ES.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_es_ES.properties index 5c73de752e..12129dcc46 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_es_ES.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_es_ES.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=¡Ya estás conectado a este servidor\! velocity.error.already-connected-proxy=¡Ya estás conectado a este proxy\! velocity.error.already-connecting=¡Ya estás intentando conectarte a un servidor\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_et_EE.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_et_EE.properties index 9a2581296f..ee6b4991f6 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_et_EE.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_et_EE.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Sa oled juba antud serveriga ühendatud\! velocity.error.already-connected-proxy=Sa oled juba antud proksiga ühendatud\! velocity.error.already-connecting=Sa juba ühendad severiga\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_fi_FI.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_fi_FI.properties index 725a7c8494..c10693f8c5 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_fi_FI.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_fi_FI.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Olet jo yhteydessä tälle palvelimelle\! velocity.error.already-connected-proxy=Olet jo yhteydessä tälle välityspalvelimelle\! velocity.error.already-connecting=Yrität jo yhdistää palvelimeen\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_fr_FR.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_fr_FR.properties index 9de65eba73..9064c530b1 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_fr_FR.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_fr_FR.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Vous êtes déjà connecté(e) à ce serveur \! velocity.error.already-connected-proxy=Vous êtes déjà connecté(e) à ce proxy \! velocity.error.already-connecting=Vous êtes déjà en train d'essayer de vous connecter à un serveur \! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_he_IL.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_he_IL.properties index 809682225c..5d331d9bfe 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_he_IL.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_he_IL.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=אתה כבר מחובר לשרת זה\! velocity.error.already-connected-proxy=אתה כבר מחובר ל- proxy זה\! velocity.error.already-connecting=אתה כבר מנסה להתחבר לשרת\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_hu_HU.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_hu_HU.properties index ce11388b96..e9d5837c8d 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_hu_HU.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_hu_HU.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Már csatlakozva vagy ehhez a szerverhez\! velocity.error.already-connected-proxy=Már csatlakozva vagy ehhez a proxyhoz\! velocity.error.already-connecting=Jelenleg is csatlakozol egy szerverre\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_it_IT.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_it_IT.properties index e4e2843362..cce7a44455 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_it_IT.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_it_IT.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Sei già connesso a questo server\! velocity.error.already-connected-proxy=Sei già connesso a questo proxy\! velocity.error.already-connecting=Stai già cercando di connetterti a un server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ja_JP.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ja_JP.properties index b0eca4bd22..e34f996056 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ja_JP.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ja_JP.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=すでにこのサーバーに接続されています。 velocity.error.already-connected-proxy=すでにこのプロキシに接続されています。 velocity.error.already-connecting=すでにサーバーに接続しようとしています! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ko_KR.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ko_KR.properties index b98f490c3a..16aba4cadb 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ko_KR.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ko_KR.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=이미 이 서버에 연결되어 있습니다\! velocity.error.already-connected-proxy=이미 이 프록시에 연결되어 있습니다\! velocity.error.already-connecting=이미 이 서버에 연결하는 중입니다\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nb_NO.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nb_NO.properties index 9c4f85d972..1955a0dd1e 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nb_NO.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nb_NO.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Du er allerede tilkoblet denne serveren\! velocity.error.already-connected-proxy=Du er allerede tilkoblet denne proxyen\! velocity.error.already-connecting=Du tilkobles allerede en server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nl_NL.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nl_NL.properties index efb5ced5f2..c75a652d7f 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nl_NL.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nl_NL.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Je bent al met deze server verbonden\! velocity.error.already-connected-proxy=Je bent al met deze proxy verbonden\! velocity.error.already-connecting=Je probeert al verbinding te maken met een server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nn_NO.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nn_NO.properties index c525f916d4..e7f32bf2dc 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nn_NO.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_nn_NO.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Du er allereie tilkopla denne sørvaren\! velocity.error.already-connected-proxy=Du er allereie tilkopla denne proxyen\! velocity.error.already-connecting=Du tilkoplas allereie ein sørvar\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_pl_PL.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_pl_PL.properties index d4c0f73ffe..c76fa1c62d 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_pl_PL.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_pl_PL.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Już jesteś połączony z tym serwerem\! velocity.error.already-connected-proxy=Już jesteś połączony z tym serwerem proxy\! velocity.error.already-connecting=Już próbujesz połączyć się z serwerem\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_pt_BR.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_pt_BR.properties index d1c4faecbc..2263ffa319 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_pt_BR.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_pt_BR.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Você já está conectado a esse servidor\! velocity.error.already-connected-proxy=Você já está conectado a esse proxy\! velocity.error.already-connecting=Você já está tentando se conectar a um servidor\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ru_RU.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ru_RU.properties index 80339767a2..cac8880698 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ru_RU.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_ru_RU.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Вы уже подключены к этому серверу\! velocity.error.already-connected-proxy=Игрок с таким ником уже играет на сервере\! velocity.error.already-connecting=Вы уже подключаетесь к серверу\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sk_SK.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sk_SK.properties index 66f86f05db..8cd374c522 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sk_SK.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sk_SK.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Na tento server si už pripojený\! velocity.error.already-connected-proxy=Na tento proxy server si už pripojený\! velocity.error.already-connecting=Už sa pokúšaš o pripojenie na server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sq_AL.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sq_AL.properties index a0f2295467..88f6ecca30 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sq_AL.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sq_AL.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Ju tashmë jeni lidhur me këtë server\! velocity.error.already-connected-proxy=Ju jeni lidhur tashmë me këtë përfaqësues\! velocity.error.already-connecting=Ju tashmë po përpiqeni të lidheni me një server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sr_CS.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sr_CS.properties index 6313a69b65..63b121e7c0 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sr_CS.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sr_CS.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Već ste povezani na ovaj server\! velocity.error.already-connected-proxy=Već ste povezani na ovaj proxy\! velocity.error.already-connecting=Već pokušavate da se povežete na server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sv_SE.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sv_SE.properties index 33d8333dde..54f7263691 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sv_SE.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_sv_SE.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=You are already connected to this server\! velocity.error.already-connected-proxy=You are already connected to this proxy\! velocity.error.already-connecting=You are already trying to connect to a server\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_tl_PH.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_tl_PH.properties index 240af05f9d..568802eb18 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_tl_PH.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_tl_PH.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Nakakonekta ka na sa serbidor na ito\! velocity.error.already-connected-proxy=Nakakonekta ka na sa proxy na ito\! velocity.error.already-connecting=Sinusubukan mo na makakonekta sa isang serbidor\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_tr_TR.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_tr_TR.properties index affab97fe2..d643822e4c 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_tr_TR.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_tr_TR.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=Bu sunucuya zaten bağlısın\! velocity.error.already-connected-proxy=Bu sunucuya zaten bağlısın\! velocity.error.already-connecting=Bu sunucuya zaten bağlanmaya çalışıyorsun\! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_zh_CN.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_zh_CN.properties index 528cad3f22..3a76aa9141 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_zh_CN.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_zh_CN.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=您已经连接到此服务器了! velocity.error.already-connected-proxy=您已经连接到此代理服务器了! velocity.error.already-connecting=您已经在尝试连接服务器了! diff --git a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_zh_HK.properties b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_zh_HK.properties index 96ec4bf269..eb1892223e 100644 --- a/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_zh_HK.properties +++ b/proxy/src/main/resources/com/velocitypowered/proxy/l10n/messages_zh_HK.properties @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - velocity.error.already-connected=You are already connected to this server\! velocity.error.already-connected-proxy=You are already connected to this proxy\! velocity.error.already-connecting=You are already trying to connect to a server\! diff --git a/proxy/src/main/resources/log4j2.component.properties b/proxy/src/main/resources/log4j2.component.properties index 16151e3247..3d4e8c6934 100644 --- a/proxy/src/main/resources/log4j2.component.properties +++ b/proxy/src/main/resources/log4j2.component.properties @@ -14,6 +14,5 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - log4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector log4j.skipJansi=true diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandTestSuite.java b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandTestSuite.java index c2edd69f3c..ea69c441f5 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandTestSuite.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandTestSuite.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.when; import com.velocitypowered.api.command.CommandSource; -import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.player.Player; import com.velocitypowered.proxy.event.MockEventManager; import com.velocitypowered.proxy.event.VelocityEventManager; import java.util.Arrays; diff --git a/proxy/src/test/java/com/velocitypowered/proxy/event/EventTest.java b/proxy/src/test/java/com/velocitypowered/proxy/event/EventTest.java index fae6cc45e0..8a025e00bb 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/event/EventTest.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/event/EventTest.java @@ -399,7 +399,8 @@ void testFancyContinuationParameter() throws Exception { + "the second is the fancy continuation"); } }, - new TypeToken>() {}, + new TypeToken>() { + }, invokeFunction -> (instance, event) -> EventTask.withContinuation(continuation -> invokeFunction.accept(instance, event, new FancyContinuationImpl(continuation)) diff --git a/proxy/src/test/java/com/velocitypowered/proxy/util/VelocityChannelRegistrarTest.java b/proxy/src/test/java/com/velocitypowered/proxy/util/VelocityChannelRegistrarTest.java index 75e3dfb581..ed2f1bc9b3 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/util/VelocityChannelRegistrarTest.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/util/VelocityChannelRegistrarTest.java @@ -20,21 +20,21 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import com.google.common.collect.ImmutableSet; -import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; -import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; +import com.velocitypowered.api.proxy.messages.ChannelIdentifier; +import net.kyori.adventure.key.Key; import org.junit.jupiter.api.Test; class VelocityChannelRegistrarTest { - private static final MinecraftChannelIdentifier MODERN = MinecraftChannelIdentifier - .create("velocity", "test"); - private static final LegacyChannelIdentifier SIMPLE_LEGACY = - new LegacyChannelIdentifier("VelocityTest"); + private static final ChannelIdentifier MODERN = ChannelIdentifier.ofKey( + Key.key("velocity", "test")); + private static final ChannelIdentifier SIMPLE_LEGACY = + ChannelIdentifier.legacy("VelocityTest"); - private static final MinecraftChannelIdentifier MODERN_SPECIAL_REMAP = MinecraftChannelIdentifier - .create("bungeecord", "main"); - private static final LegacyChannelIdentifier SPECIAL_REMAP_LEGACY = - new LegacyChannelIdentifier("BungeeCord"); + private static final ChannelIdentifier MODERN_SPECIAL_REMAP = ChannelIdentifier.ofKey( + Key.key("bungeecord", "main")); + private static final ChannelIdentifier SPECIAL_REMAP_LEGACY = + ChannelIdentifier.legacy("BungeeCord"); private static final String SIMPLE_LEGACY_REMAPPED = "legacy:velocitytest"; diff --git a/settings.gradle.kts b/settings.gradle.kts index 0c31266f95..660425ca9d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,9 +24,9 @@ plugins { rootProject.name = "velocity" sequenceOf( - "api", - "native", - "proxy", + "api", + "native", + "proxy", ).forEach { val project = ":velocity-$it" include(project)