diff --git a/api/build.gradle.kts b/api/build.gradle.kts
index 268a8197ba..aeda343341 100644
--- a/api/build.gradle.kts
+++ b/api/build.gradle.kts
@@ -66,7 +66,7 @@ tasks {
"https://www.javadocs.dev/org.slf4j/slf4j-api/${libs.slf4j.get().version}/",
"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/17/docs/api/",
+ "https://docs.oracle.com/en/java/javase/21/docs/api/",
"https://jd.advntr.dev/api/${libs.adventure.bom.get().version}/",
"https://jd.advntr.dev/text-minimessage/${libs.adventure.bom.get().version}/",
"https://jd.advntr.dev/key/${libs.adventure.bom.get().version}/",
diff --git a/api/src/main/java/com/velocitypowered/api/command/CommandSource.java b/api/src/main/java/com/velocitypowered/api/command/CommandSource.java
index c94dec4c67..067b908f45 100644
--- a/api/src/main/java/com/velocitypowered/api/command/CommandSource.java
+++ b/api/src/main/java/com/velocitypowered/api/command/CommandSource.java
@@ -25,7 +25,7 @@ public interface CommandSource extends Audience, PermissionSubject {
* @param message MiniMessage content
* @see MiniMessage docs
* for more information on the format.
- **/
+ */
default void sendRichMessage(final @NotNull String message) {
this.sendMessage(MiniMessage.miniMessage().deserialize(message, this));
}
@@ -41,19 +41,19 @@ default void sendRichMessage(final @NotNull String message) {
*/
default void sendRichMessage(
final @NotNull String message,
- final @NotNull TagResolver @NotNull... resolvers
+ final @NotNull TagResolver @NotNull ... resolvers
) {
this.sendMessage(MiniMessage.miniMessage().deserialize(message, this, resolvers));
}
/**
- * Sends a plain message to this source.
- *
- * @param message plain message
- * @apiNote This method will not apply any form of parse to the text provided,
- * however, it is recommended not to use legacy color codes as this is a deprecated format
+ * Sends a plain message to this source.
+ *
+ * @param message plain message
+ * @apiNote This method will not apply any form of parse to the text provided,
+ * however, it is recommended not to use legacy color codes as this is a deprecated format
* and not recommended.
- */
+ */
default void sendPlainMessage(final @NotNull String message) {
this.sendMessage(Component.text(message));
}
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..11ab424aef 100644
--- a/api/src/main/java/com/velocitypowered/api/event/Continuation.java
+++ b/api/src/main/java/com/velocitypowered/api/event/Continuation.java
@@ -22,4 +22,4 @@ public interface Continuation {
* Resumes the continuation after the executed task failed.
*/
void resumeWithException(Throwable exception);
-}
\ No newline at end of file
+}
diff --git a/api/src/main/java/com/velocitypowered/api/event/connection/PreLoginEvent.java b/api/src/main/java/com/velocitypowered/api/event/connection/PreLoginEvent.java
index 952cb091b7..3a7025757e 100644
--- a/api/src/main/java/com/velocitypowered/api/event/connection/PreLoginEvent.java
+++ b/api/src/main/java/com/velocitypowered/api/event/connection/PreLoginEvent.java
@@ -23,11 +23,9 @@
* with the login process, but you should try to limit the work done in any event that fires during
* the login process.
*
- *
- * 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 com.velocitypowered.api.proxy.LoginPhaseConnection} to allow a
+ * proxy plugin to send login plugin messages to the client.
*/
@AwaitingEvent
public final class PreLoginEvent implements ResultedEvent {
@@ -73,6 +71,7 @@ public String getUsername() {
/**
* Returns the UUID of the connecting player.
+ *
*
This value is {@code null} on 1.19.2 and lower,
* up to 1.20.1 it is optional and from 1.20.2 it will always be available.
*
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 bb682255d7..a55dc12aec 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
@@ -18,11 +18,9 @@
* order to set up the game profile for the user. This can be used to configure a custom profile for
* a user, i.e. skin replacement.
*
- *
- * 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
public final class GameProfileRequestEvent {
@@ -92,5 +90,4 @@ public String toString() {
+ "}";
}
-
}
diff --git a/api/src/main/java/com/velocitypowered/api/event/player/PlayerClientBrandEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/PlayerClientBrandEvent.java
index 268d5b6a19..2a671ac6d2 100644
--- a/api/src/main/java/com/velocitypowered/api/event/player/PlayerClientBrandEvent.java
+++ b/api/src/main/java/com/velocitypowered/api/event/player/PlayerClientBrandEvent.java
@@ -40,9 +40,9 @@ 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/configuration/PlayerConfigurationEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerConfigurationEvent.java
index 6e042af1c7..60b172f6c5 100644
--- a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerConfigurationEvent.java
+++ b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerConfigurationEvent.java
@@ -14,6 +14,7 @@
/**
* This event is executed when a player entered the configuration state and can be configured by Velocity.
+ *
*
Velocity will wait for this event before continuing/ending the configuration state.
*
* @param player The player who can be configured.
diff --git a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerEnterConfigurationEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerEnterConfigurationEvent.java
index 05d6c2af02..97a2ded0e0 100644
--- a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerEnterConfigurationEvent.java
+++ b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerEnterConfigurationEvent.java
@@ -15,8 +15,9 @@
/**
* This event is executed when a player is about to enter the configuration state.
* It is not called for the initial configuration of a player after login.
+ *
*
Velocity will wait for this event before asking the client to enter configuration state.
- * However due to backend server being unable to keep the connection alive during state changes,
+ * However, due to backend server being unable to keep the connection alive during state changes,
* Velocity will only wait for a maximum of 5 seconds.
*
* @param player The player who is about to enter configuration state.
diff --git a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerEnteredConfigurationEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerEnteredConfigurationEvent.java
index c16777066c..6560f7bc43 100644
--- a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerEnteredConfigurationEvent.java
+++ b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerEnteredConfigurationEvent.java
@@ -14,6 +14,7 @@
/**
* This event is executed when a player has entered the configuration state.
+ *
*
From this moment on, until the {@link PlayerFinishedConfigurationEvent} is executed,
* the {@linkplain Player#getProtocolState()} method is guaranteed
* to return {@link ProtocolState#CONFIGURATION}.
diff --git a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerFinishConfigurationEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerFinishConfigurationEvent.java
index 50df5a8abe..1cd3f2833c 100644
--- a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerFinishConfigurationEvent.java
+++ b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerFinishConfigurationEvent.java
@@ -14,8 +14,9 @@
/**
* This event is executed when a player is about to finish the configuration state.
+ *
*
Velocity will wait for this event before asking the client to finish the configuration state.
- * However due to backend server being unable to keep the connection alive during state changes,
+ * However, due to backend server being unable to keep the connection alive during state changes,
* Velocity will only wait for a maximum of 5 seconds. If you need to hold a player in configuration
* state, use the {@link PlayerConfigurationEvent}.
*
diff --git a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerFinishedConfigurationEvent.java b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerFinishedConfigurationEvent.java
index 517f119cfe..994a1d4111 100644
--- a/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerFinishedConfigurationEvent.java
+++ b/api/src/main/java/com/velocitypowered/api/event/player/configuration/PlayerFinishedConfigurationEvent.java
@@ -14,6 +14,7 @@
/**
* This event is executed when a player has finished the configuration state.
+ *
*
From this moment on, the {@link Player#getProtocolState()} method
* will return {@link ProtocolState#PLAY}.
This status can be caused by a {@link HandshakeIntent#STATUS},
* {@link HandshakeIntent#LOGIN} or {@link HandshakeIntent#TRANSFER} intent.
* If the intent is LOGIN or TRANSFER, the next state will be {@link #LOGIN},
@@ -24,6 +25,7 @@ public enum ProtocolState {
HANDSHAKE,
/**
* Ping State of a connection.
+ *
*
Connections with the {@link HandshakeIntent#STATUS} intent will pass through this state
* and be disconnected after it requests the ping from the server
* and the server responds with the respective ping.
@@ -31,11 +33,13 @@ public enum ProtocolState {
STATUS,
/**
* Authentication State of a connection.
+ *
*
At this moment the player is authenticating with the authentication servers.
*/
LOGIN,
/**
* Configuration State of a connection.
+ *
*
At this point the player allows the server to send information
* such as resource packs and plugin messages, at the same time the player
* will send his client brand and the respective plugin messages
@@ -46,6 +50,7 @@ public enum ProtocolState {
CONFIGURATION,
/**
* Game State of a connection.
+ *
*
In this state is where the whole game runs, the server is able to change
* the player's state to {@link #CONFIGURATION} as needed in versions 1.20.2 and higher.
*/
diff --git a/api/src/main/java/com/velocitypowered/api/permission/Tristate.java b/api/src/main/java/com/velocitypowered/api/permission/Tristate.java
index ddbe26a866..003759e82b 100644
--- a/api/src/main/java/com/velocitypowered/api/permission/Tristate.java
+++ b/api/src/main/java/com/velocitypowered/api/permission/Tristate.java
@@ -15,7 +15,7 @@
* Represents three different states of a setting.
*
*
Possible values:
- *
+ *
*
*
{@link #TRUE} - a positive setting
*
{@link #FALSE} - a negative (negated) setting
@@ -81,7 +81,6 @@ public static Tristate fromOptionalBoolean(Optional val) {
return val.map(Tristate::fromBoolean).orElse(UNDEFINED);
}
-
private final boolean booleanValue;
Tristate(boolean booleanValue) {
diff --git a/api/src/main/java/com/velocitypowered/api/proxy/Player.java b/api/src/main/java/com/velocitypowered/api/proxy/Player.java
index 057b8a2398..8af3a07356 100644
--- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java
+++ b/api/src/main/java/com/velocitypowered/api/proxy/Player.java
@@ -244,7 +244,7 @@ default void clearHeaderAndFooter() {
* Gets the {@link ResourcePackInfo} of the currently applied
* resource-pack or null if none.
*
- *
Note that since 1.20.3 it is no longer recommended to use
+ *
Note that since 1.20.3 it is no longer recommended to use
* this method as it will only return the last applied
* resource pack. To get all applied resource packs, use
* {@link #getAppliedResourcePacks()} instead.
@@ -260,7 +260,7 @@ default void clearHeaderAndFooter() {
* the user is currently downloading or is currently
* prompted to install or null if none.
*
- *
Note that since 1.20.3 it is no longer recommended to use
+ *
Note that since 1.20.3 it is no longer recommended to use
* this method as it will only return the last pending
* resource pack. To get all pending resource packs, use
* {@link #getPendingResourcePacks()} instead.
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.
@@ -400,7 +401,7 @@ default void applySkinToPlayerHeadContents(
* and will not perform any actions.
* @see #playSound(Sound, Sound.Emitter)
* @see
- * Unsupported Adventure Operations
+ * Unsupported Adventure Operations
*/
@Override
default void playSound(@NotNull Sound sound) {
@@ -413,7 +414,7 @@ default void playSound(@NotNull Sound sound) {
* and will not perform any actions.
* @see #playSound(Sound, Sound.Emitter)
* @see
- * Unsupported Adventure Operations
+ * Unsupported Adventure Operations
*/
@Override
default void playSound(@NotNull Sound sound, double x, double y, double z) {
@@ -456,7 +457,7 @@ default void stopSound(@NotNull SoundStop stop) {
* and will not perform any actions.
*
* @see
- * Unsupported Adventure Operations
+ * Unsupported Adventure Operations
*/
@Override
default void openBook(@NotNull Book book) {
@@ -469,7 +470,7 @@ default void openBook(@NotNull Book book) {
* and will not perform any actions.
*
* @see
- * Unsupported Adventure Operations
+ * Unsupported Adventure Operations
*/
@Override
default void showDialog(@NotNull DialogLike dialog) {
@@ -482,7 +483,7 @@ default void showDialog(@NotNull DialogLike dialog) {
* and will not perform any actions.
*
* @see
- * Unsupported Adventure Operations
+ * Unsupported Adventure Operations
*/
@Override
default void closeDialog() {
@@ -532,4 +533,4 @@ default void closeDialog() {
* @sinceMinecraft 1.21
*/
void setServerLinks(@NotNull List links);
-}
\ No newline at end of file
+}
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 d2a6cc94e3..8365c07964 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
@@ -28,7 +28,6 @@ public interface IdentifiedKey extends KeySigned {
*/
PublicKey getSignedPublicKey();
-
/**
* Validates a signature against this public key.
*
@@ -69,11 +68,11 @@ enum Revision implements Ordered {
this.backwardsCompatibleTo = backwardsCompatibleTo;
this.applicableTo = applicableTo;
}
-
+
public Set getBackwardsCompatibleTo() {
return backwardsCompatibleTo;
}
-
+
public Set getApplicableTo() {
return applicableTo;
}
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 8ad64c1811..83fd402f5f 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
@@ -34,7 +34,6 @@ public interface KeySigned {
*/
Instant getExpiryTemporal();
-
/**
* Check if the signature has expired.
*
@@ -56,6 +55,7 @@ default boolean 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/ChannelMessageSink.java b/api/src/main/java/com/velocitypowered/api/proxy/messages/ChannelMessageSink.java
index 3c1031f438..f4ac0863df 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
@@ -22,7 +22,7 @@ public interface ChannelMessageSink {
* @param data the data to send
* @return whether or not the message could be sent
*/
- boolean sendPluginMessage(@NotNull ChannelIdentifier identifier, byte @NotNull[] data);
+ boolean sendPluginMessage(@NotNull ChannelIdentifier identifier, byte @NotNull [] data);
/**
* Sends a plugin message to this target.
@@ -41,7 +41,6 @@ public interface ChannelMessageSink {
* @return whether the message could be sent
*/
@ApiStatus.Experimental
- boolean sendPluginMessage(
- @NotNull ChannelIdentifier identifier,
- @NotNull PluginMessageEncoder dataEncoder);
+ boolean sendPluginMessage(@NotNull ChannelIdentifier identifier,
+ @NotNull PluginMessageEncoder dataEncoder);
}
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 82937685ab..584ca96489 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
@@ -87,11 +87,11 @@ public interface ResourcePackInfo extends ResourcePackRequestLike {
/**
* Returns a copy of this {@link ResourcePackInfo} instance as a builder, using the new URL.
- *
- * It is not guaranteed that
+ *
+ *
It is not guaranteed that
* {@code resourcePackInfo.asBuilder(resourcePackInfo.getUrl()).build().equals(resourcePackInfo)}
* is true, because the {@link ResourcePackInfo#getOrigin()} and
- * {@link ResourcePackInfo#getOriginalOrigin()} fields are transient.
+ * {@link ResourcePackInfo#getOriginalOrigin()} fields are transient.
*
* @param newUrl The new URL to use in the updated builder.
*
@@ -174,4 +174,4 @@ enum Origin {
*/
PLUGIN_ON_PROXY
}
-}
\ No newline at end of file
+}
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 aea45287fc..57a42392d3 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
@@ -237,8 +237,11 @@ public Builder profile(GameProfile profile) {
/**
* Sets the {@link IdentifiedKey} of the {@link TabListEntry}.
+ *
*
This only works for players currently not connected to this proxy.
+ *
*
For any player currently connected to this proxy this will be filled automatically.
+ *
*
Will ignore mismatching key revisions data.
*
* @param chatSession session to set
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 6c794bf4c4..a43b675a9a 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
@@ -147,7 +147,6 @@ public Collection getPlugins() {
return plugins;
}
-
/**
* Creates a new {@link Builder} instance from data represented by this response, so that you
* may create a new {@link QueryResponse} with new data. It is guaranteed that
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 fd686297ee..46b2c411ab 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
@@ -32,11 +32,11 @@ public ServerInfo(String name, InetSocketAddress address) {
this.address = Preconditions.checkNotNull(address, "address");
}
- public final String getName() {
+ public String getName() {
return name;
}
- public final InetSocketAddress getAddress() {
+ public InetSocketAddress getAddress() {
return address;
}
@@ -49,7 +49,7 @@ public String toString() {
}
@Override
- public final boolean equals(@Nullable Object o) {
+ public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
@@ -62,7 +62,7 @@ public final boolean equals(@Nullable Object o) {
}
@Override
- public final int hashCode() {
+ public int hashCode() {
return Objects.hash(name, 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 eb86f93ea1..c0f8b49625 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
@@ -22,7 +22,6 @@
import net.kyori.adventure.text.Component;
import org.jspecify.annotations.Nullable;
-
/**
* Represents a 1.7 and above server list ping response. This class is immutable.
*/
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index caa82d812f..287fb8d8d2 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -2,26 +2,27 @@
configurate3 = "3.7.3"
configurate4 = "4.2.0"
flare = "2.0.1"
-log4j = "2.25.3"
-netty = "4.2.10.Final"
+log4j = "2.26.0"
+netty = "4.2.14.Final"
+jline = "3.30.13"
[plugins]
-fill = "io.papermc.fill.gradle:1.0.10"
-shadow = "com.gradleup.shadow:9.3.1"
-spotless = "com.diffplug.spotless:8.2.0"
+fill = "io.papermc.fill.gradle:1.0.11"
+shadow = "com.gradleup.shadow:9.4.1"
+spotless = "com.diffplug.spotless:8.5.1"
[libraries]
adventure-bom = "net.kyori:adventure-bom:4.26.1"
adventure-text-serializer-json-legacy-impl = "net.kyori:adventure-text-serializer-json-legacy-impl:4.26.1"
adventure-facet = "net.kyori:adventure-platform-facet:4.4.1"
-asm = "org.ow2.asm:asm:9.9.1"
+asm = "org.ow2.asm:asm:9.10"
auto-service = "com.google.auto.service:auto-service:1.1.1"
auto-service-annotations = "com.google.auto.service:auto-service-annotations:1.1.1"
brigadier = "com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT"
-bstats = "org.bstats:bstats-base:3.1.0"
-caffeine = "com.github.ben-manes.caffeine:caffeine:3.2.3"
-checker-qual = "org.checkerframework:checker-qual:3.53.0"
-checkstyle = "com.puppycrawl.tools:checkstyle:10.9.3"
+bstats = "org.bstats:bstats-base:3.2.1"
+caffeine = "com.github.ben-manes.caffeine:caffeine:3.2.4"
+checker-qual = "org.checkerframework:checker-qual:4.1.0"
+checkstyle = "com.puppycrawl.tools:checkstyle:13.4.2"
completablefutures = "com.spotify:completable-futures:0.3.6"
configurate3-hocon = { module = "org.spongepowered:configurate-hocon", version.ref = "configurate3" }
configurate3-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate3" }
@@ -30,24 +31,27 @@ configurate4-hocon = { module = "org.spongepowered:configurate-hocon", version.r
configurate4-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate4" }
configurate4-gson = { module = "org.spongepowered:configurate-gson", version.ref = "configurate4" }
disruptor = "com.lmax:disruptor:4.0.0"
-fastutil = "it.unimi.dsi:fastutil:8.5.15"
+fastutil = "it.unimi.dsi:fastutil:8.5.18"
flare-core = { module = "space.vectrix.flare:flare", version.ref = "flare" }
flare-fastutil = { module = "space.vectrix.flare:flare-fastutil", version.ref = "flare" }
-jline = "org.jline:jline-terminal-jansi:3.30.6"
+jline-terminal = { module = "org.jline:jline-terminal", version.ref = "jline" }
+jline-reader = { module = "org.jline:jline-reader", version.ref = "jline" }
+jline-terminal-jni = { module = "org.jline:jline-terminal-jni", version.ref = "jline" }
+jline-terminal-ffm = { module = "org.jline:jline-terminal-ffm", version.ref = "jline" }
jopt = "net.sf.jopt-simple:jopt-simple:5.0.4"
-junit = "org.junit.jupiter:junit-jupiter:5.14.2"
+junit = "org.junit.jupiter:junit-jupiter:6.1.0"
jspecify = "org.jspecify:jspecify:1.0.0"
kyori-ansi = "net.kyori:ansi:1.1.1"
-guava = "com.google.guava:guava:33.5.0-jre"
-gson = "com.google.code.gson:gson:2.13.2"
+guava = "com.google.guava:guava:33.6.0-jre"
+gson = "com.google.code.gson:gson:2.14.0"
guice = "com.google.inject:guice:7.0.0"
-lmbda = "org.lanternpowered:lmbda:2.0.0"
+lmbda = "org.lanternpowered:lmbda:3.0.0"
log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" }
log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
log4j-slf4j-impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version.ref = "log4j" }
log4j-iostreams = { module = "org.apache.logging.log4j:log4j-iostreams", version.ref = "log4j" }
log4j-jul = { module = "org.apache.logging.log4j:log4j-jul", version.ref = "log4j" }
-mockito = "org.mockito:mockito-core:5.21.0"
+mockito = "org.mockito:mockito-core:5.23.0"
netty-codec = { module = "io.netty:netty-codec", version.ref = "netty" }
netty-codec-haproxy = { module = "io.netty:netty-codec-haproxy", version.ref = "netty" }
netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }
@@ -55,9 +59,9 @@ netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
netty-transport-native-epoll = { module = "io.netty:netty-transport-native-epoll", version.ref = "netty" }
netty-transport-native-kqueue = { module = "io.netty:netty-transport-native-kqueue", version.ref = "netty" }
netty-transport-native-iouring = { module = "io.netty:netty-transport-native-io_uring", version.ref = "netty" }
-nightconfig = "com.electronwill.night-config:toml:3.8.3"
-slf4j = "org.slf4j:slf4j-api:2.0.17"
-snakeyaml = "org.yaml:snakeyaml:2.5"
+nightconfig = "com.electronwill.night-config:toml:3.8.4"
+slf4j = "org.slf4j:slf4j-api:2.0.18"
+snakeyaml = "org.yaml:snakeyaml:2.6"
spotbugs-annotations = "com.github.spotbugs:spotbugs-annotations:4.9.8"
terminalconsoleappender = "net.minecrell:terminalconsoleappender:1.3.0"
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 61285a659d..b1b8ef56b4 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 19a6bdeb84..df6a6ad763 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
networkTimeout=10000
+retries=0
+retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index adff685a03..b9bb139f79 100755
--- a/gradlew
+++ b/gradlew
@@ -57,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
diff --git a/gradlew.bat b/gradlew.bat
index e509b2dd8f..aa5f10b069 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -23,8 +23,8 @@
@rem
@rem ##########################################################################
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
+@rem Set local scope for the variables, and ensure extensions are enabled
+setlocal EnableExtensions
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@@ -51,7 +51,7 @@ echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
-goto fail
+"%COMSPEC%" /c exit 1
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
@@ -65,7 +65,7 @@ echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
-goto fail
+"%COMSPEC%" /c exit 1
:execute
@rem Setup the command line
@@ -73,21 +73,10 @@ goto fail
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
+@rem which allows us to clear the local environment before executing the java command
+endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
-:end
-@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-set EXIT_CODE=%ERRORLEVEL%
-if %EXIT_CODE% equ 0 set EXIT_CODE=1
-if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
-exit /b %EXIT_CODE%
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+:exitWithErrorLevel
+@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
+"%COMSPEC%" /c exit %ERRORLEVEL%
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 13f4f0c570..886f20818b 100644
--- a/native/src/main/java/com/velocitypowered/natives/util/MoreByteBufUtils.java
+++ b/native/src/main/java/com/velocitypowered/natives/util/MoreByteBufUtils.java
@@ -54,8 +54,8 @@ private static boolean isCompatible(Native nativeStuff, ByteBuf buf) {
BufferPreference preferred = nativeStuff.preferredBufferType();
return switch (preferred) {
case DIRECT_PREFERRED, HEAP_PREFERRED ->
- // The native prefers this type, but doesn't strictly require we provide it.
- true;
+ // The native prefers this type, but doesn't strictly require we provide it.
+ true;
case DIRECT_REQUIRED -> buf.hasMemoryAddress();
case HEAP_REQUIRED -> buf.hasArray();
};
diff --git a/proxy/build.gradle.kts b/proxy/build.gradle.kts
index c7164c1501..b6d8b33a94 100644
--- a/proxy/build.gradle.kts
+++ b/proxy/build.gradle.kts
@@ -14,10 +14,6 @@ application {
}
tasks {
- withType {
- exclude("**/com/velocitypowered/proxy/protocol/packet/**")
- }
-
jar {
manifest {
attributes["Implementation-Title"] = "Velocity"
@@ -33,7 +29,7 @@ tasks {
transform(Log4j2PluginsCacheFileTransformer::class.java)
- // Exclude all the collection types we don"t intend to use
+ // Exclude all the collection types we don't intend to use
exclude("it/unimi/dsi/fastutil/booleans/**")
exclude("it/unimi/dsi/fastutil/bytes/**")
exclude("it/unimi/dsi/fastutil/chars/**")
@@ -42,7 +38,7 @@ tasks {
exclude("it/unimi/dsi/fastutil/longs/**")
exclude("it/unimi/dsi/fastutil/shorts/**")
- // Exclude the fastutil IO utilities - we don"t use them.
+ // Exclude the fastutil IO utilities - we don't use them.
exclude("it/unimi/dsi/fastutil/io/**")
// Exclude most of the int types - Object2IntMap have a values() method that returns an
@@ -154,7 +150,10 @@ dependencies {
implementation(libs.jopt)
implementation(libs.terminalconsoleappender)
- runtimeOnly(libs.jline)
+ implementation(libs.jline.terminal)
+ implementation(libs.jline.reader)
+ runtimeOnly(libs.jline.terminal.jni)
+ runtimeOnly(libs.jline.terminal.ffm)
runtimeOnly(libs.disruptor)
implementation(libs.fastutil)
implementation(platform(libs.adventure.bom))
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Metrics.java b/proxy/src/main/java/com/velocitypowered/proxy/Metrics.java
index 7feeb25fdd..7123f2b0bb 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/Metrics.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/Metrics.java
@@ -140,7 +140,7 @@ static void startMetrics(VelocityServer server, VelocityConfiguration.Metrics me
} else {
// of course, it really wouldn't be all that simple if they didn't add a quirk, now
// would it valid strings for the major may potentially include values such as -ea to
- // denote a pre release
+ // denote a prerelease
Matcher versionMatcher = Pattern.compile("\\d+").matcher(majorVersion);
if (versionMatcher.find()) {
majorVersion = versionMatcher.group(0);
@@ -154,4 +154,4 @@ static void startMetrics(VelocityServer server, VelocityConfiguration.Metrics me
}
}
-}
\ No newline at end of file
+}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java
index 95f10bcbb0..c1abb571a6 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java
@@ -367,7 +367,6 @@ private void registerTranslations() {
}
});
}
-
}
try (final Stream files = Files.walk(langPath)) {
@@ -650,7 +649,7 @@ public void shutdown(boolean explicitExit, Component reason) {
}
/**
- * Calls {@link #shutdown(boolean, Component)} with the default reason "Proxy shutting down."
+ * Calls {@link #shutdown(boolean, Component)} with the default reason "Proxy shutting down.".
*
* @param explicitExit whether the user explicitly shut down the proxy
*/
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/adventure/BossBarImplementationProvider.java b/proxy/src/main/java/com/velocitypowered/proxy/adventure/BossBarImplementationProvider.java
index 559d8661cd..e61b811947 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/adventure/BossBarImplementationProvider.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/adventure/BossBarImplementationProvider.java
@@ -21,8 +21,10 @@
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.bossbar.BossBarImplementation;
+/**
+ * The {@link BossBarImplementation.Provider} that supplies Velocity's boss bar implementation.
+ */
@AutoService(BossBarImplementation.Provider.class)
-@SuppressWarnings("MissingJavadocType")
public class BossBarImplementationProvider implements BossBarImplementation.Provider {
@Override
public BossBarImplementation create(final BossBar bar) {
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/adventure/VelocityBossBarImplementation.java b/proxy/src/main/java/com/velocitypowered/proxy/adventure/VelocityBossBarImplementation.java
index e2451188ad..4b0395ba26 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/adventure/VelocityBossBarImplementation.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/adventure/VelocityBossBarImplementation.java
@@ -31,7 +31,6 @@
/**
* Implementation of a {@link BossBarImplementation}.
*/
-@SuppressWarnings("MissingJavadocMethod")
public final class VelocityBossBarImplementation implements BossBar.Listener,
BossBarImplementation {
private final Set viewers = Collections.newSetFromMap(
@@ -47,6 +46,13 @@ public static VelocityBossBarImplementation get(final BossBar bar) {
this.bar = bar;
}
+ /**
+ * Registers the given player as a viewer of this boss bar, sending them the boss bar if they
+ * were not already viewing it.
+ *
+ * @param viewer the player to add as a viewer
+ * @return {@code true} if the player was newly added, {@code false} if already a viewer
+ */
public boolean viewerAdd(final ConnectedPlayer viewer) {
if (this.viewers.add(viewer)) {
final ComponentHolder name = new ComponentHolder(
@@ -59,6 +65,12 @@ public boolean viewerAdd(final ConnectedPlayer viewer) {
return false;
}
+ /**
+ * Sends this boss bar to the given player by writing the add packet directly to their
+ * connection, without registering them as a tracked viewer.
+ *
+ * @param viewer the player to send the boss bar to
+ */
public void createDirect(final ConnectedPlayer viewer) {
final ComponentHolder name = new ComponentHolder(
viewer.getProtocolVersion(),
@@ -67,6 +79,13 @@ public void createDirect(final ConnectedPlayer viewer) {
viewer.getConnection().write(BossBarPacket.createAddPacket(this.id, this.bar, name));
}
+ /**
+ * Unregisters the given player as a viewer of this boss bar, sending them the removal packet
+ * if they were viewing it.
+ *
+ * @param viewer the player to remove as a viewer
+ * @return {@code true} if the player was a viewer and has been removed
+ */
public boolean viewerRemove(final ConnectedPlayer viewer) {
if (this.viewers.remove(viewer)) {
viewer.getBossBarManager().remove(this, BossBarPacket.createRemovePacket(this.id, this.bar));
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/CallbackCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/CallbackCommand.java
index e85ec873fa..af736e68e5 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/CallbackCommand.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/CallbackCommand.java
@@ -31,7 +31,11 @@
*/
public final class CallbackCommand implements Command {
- @SuppressWarnings("checkstyle:MissingJavadocMethod")
+ /**
+ * Creates the brigadier command that backs Adventure click callbacks.
+ *
+ * @return the {@code velocity:callback} command
+ */
public static BrigadierCommand create() {
final LiteralCommandNode node = BrigadierCommand
.literalArgumentBuilder("velocity:callback")
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 99fd348df7..686f9b23b1 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
@@ -46,7 +46,13 @@ public final class ServerCommand {
private static final String SERVER_ARG = "server";
public static final int MAX_SERVERS_TO_LIST = 50;
- @SuppressWarnings("checkstyle:MissingJavadocMethod")
+ /**
+ * Creates the {@code /server} command, which lists the available servers and connects the
+ * player to a chosen one.
+ *
+ * @param server the proxy server
+ * @return the {@code /server} command
+ */
public static BrigadierCommand create(final ProxyServer server) {
final LiteralCommandNode node = BrigadierCommand
.literalArgumentBuilder("server")
@@ -124,7 +130,7 @@ private static void outputServerInformation(final Player executor,
}
private static TextComponent formatServerComponent(final String currentPlayerServer,
- final RegisteredServer server) {
+ final RegisteredServer server) {
final ServerInfo serverInfo = server.getServerInfo();
final TextComponent.Builder serverTextComponent = Component.text()
.content(serverInfo.getName());
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 562efee42b..253f2981df 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
@@ -72,7 +72,13 @@
public final class VelocityCommand {
private static final String USAGE = "/velocity <%s>";
- @SuppressWarnings("checkstyle:MissingJavadocMethod")
+ /**
+ * Creates the {@code /velocity} command, including its {@code dump}, {@code heap},
+ * {@code info}, {@code plugins}, and {@code reload} subcommands.
+ *
+ * @param server the proxy server
+ * @return the {@code /velocity} command
+ */
public static BrigadierCommand create(final VelocityServer server) {
final LiteralCommandNode dump = BrigadierCommand.literalArgumentBuilder("dump")
.requires(source -> source.getPermissionValue("velocity.command.dump") == Tristate.TRUE)
@@ -269,7 +275,6 @@ private TextComponent componentForPlugin(PluginDescription description) {
private record Dump(ProxyServer server) implements Command {
private static final Logger logger = LogManager.getLogger(Dump.class);
-
@Override
public int run(final CommandContext context) {
final CommandSource source = context.getSource();
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 47d59a7186..ee30cac74d 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
@@ -1289,8 +1289,8 @@ public void removeResourcePacks(@NotNull ResourcePackRequestLike request) {
}
@Override
- @SuppressWarnings("checkstyle:linelength")
- public void removeResourcePacks(@NotNull ResourcePackInfoLike request, @NotNull ResourcePackInfoLike @NotNull ... others) {
+ public void removeResourcePacks(@NotNull ResourcePackInfoLike request,
+ @NotNull ResourcePackInfoLike @NotNull ... others) {
removeResourcePacks(request.asResourcePackInfo().id());
for (final ResourcePackInfoLike other : others) {
removeResourcePacks(other.asResourcePackInfo().id());
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/ResourcePackResponseBundle.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/ResourcePackResponseBundle.java
index 052f7080a3..bbcde58d81 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/ResourcePackResponseBundle.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/ResourcePackResponseBundle.java
@@ -20,7 +20,14 @@
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
import java.util.UUID;
-@SuppressWarnings("checkstyle:MissingJavadocType")
+/**
+ * Bundles the details of a resource pack response: the pack it refers to and the status the
+ * player reported for it.
+ *
+ * @param uuid the unique id of the resource pack
+ * @param hash the hash of the resource pack
+ * @param status the status the player reported for the pack
+ */
public record ResourcePackResponseBundle(UUID uuid, String hash,
PlayerResourcePackStatusEvent.Status status) {
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/VelocityResourcePackInfo.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/VelocityResourcePackInfo.java
index 4292710e0c..a6d454169f 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/VelocityResourcePackInfo.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/VelocityResourcePackInfo.java
@@ -73,7 +73,7 @@ public boolean getShouldForce() {
}
@Override
- public byte @Nullable[] getHash() {
+ public byte @Nullable [] getHash() {
return hash == null ? null : hash.clone(); // Thanks spotbugs, very helpful.
}
@@ -122,11 +122,15 @@ public Builder asBuilder(String newUrl) {
.build();
}
- @SuppressWarnings("checkstyle:MissingJavadocMethod")
- public static ResourcePackInfo fromAdventureRequest(
- final ResourcePackRequest request,
- final net.kyori.adventure.resource.ResourcePackInfo pack
- ) {
+ /**
+ * Creates a resource pack info from an Adventure resource pack request and one of its packs.
+ *
+ * @param request the Adventure resource pack request supplying the forced flag and prompt
+ * @param pack the individual Adventure pack to convert
+ * @return the resource pack info
+ */
+ public static ResourcePackInfo fromAdventureRequest(final ResourcePackRequest request,
+ final net.kyori.adventure.resource.ResourcePackInfo pack) {
return new BuilderImpl(pack.uri().toString())
.setHash(pack.hash().isEmpty() ? null : ByteBufUtil.decodeHexDump(pack.hash()))
.setId(pack.id())
@@ -192,4 +196,4 @@ public BuilderImpl setOrigin(Origin origin) {
}
}
-}
\ No newline at end of file
+}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/handler/ModernResourcePackHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/handler/ModernResourcePackHandler.java
index f0fd5e084c..f091e3ca19 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/handler/ModernResourcePackHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/handler/ModernResourcePackHandler.java
@@ -37,7 +37,7 @@
import org.jetbrains.annotations.Nullable;
/**
- * Modern (Minecraft 1.20.3+) ResourcePackHandler
+ * Modern (Minecraft 1.20.3+) ResourcePackHandler.
*/
public final class ModernResourcePackHandler extends ResourcePackHandler {
private final ListMultimap outstandingResourcePacks =
@@ -168,7 +168,7 @@ public boolean onResourcePackResponse(
pendingResourcePacks.remove(uuid);
appliedResourcePacks.remove(uuid);
}
- // The other cases in which no action is taken are documented in the javadocs.
+ // The other cases in which no action is taken are documented in the Javadocs.
default -> {
}
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/handler/ResourcePackHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/handler/ResourcePackHandler.java
index b384388534..e25c4f595f 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/handler/ResourcePackHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/player/resourcepack/handler/ResourcePackHandler.java
@@ -56,7 +56,7 @@ protected ResourcePackHandler(final ConnectedPlayer player, final VelocityServer
* @return a new ResourcePackHandler
*/
public static @NotNull ResourcePackHandler create(final ConnectedPlayer player,
- final VelocityServer server) {
+ final VelocityServer server) {
final ProtocolVersion protocolVersion = player.getProtocolVersion();
if (protocolVersion.lessThan(ProtocolVersion.MINECRAFT_1_17)) {
return new LegacyResourcePackHandler(player, server);
@@ -118,6 +118,7 @@ protected void sendResourcePackRequestPacket(final @NotNull ResourcePackInfo que
/**
* Processes a client response to a sent resource-pack.
+ *
*
Cases in which no action will be taken:
*
*
@@ -171,7 +172,12 @@ protected boolean handleResponseResult(
*/
public abstract boolean hasPackAppliedByHash(final byte[] hash);
- @SuppressWarnings("checkstyle:MissingJavadocMethod")
+ /**
+ * Ensures the resource pack with the given hash has not already been applied to the player.
+ *
+ * @param hash the resource pack hash to check
+ * @throws IllegalStateException if a pack with this hash has already been applied
+ */
public void checkAlreadyAppliedPack(final byte[] hash) {
if (this.hasPackAppliedByHash(hash)) {
throw new IllegalStateException("Cannot apply a resource pack already applied");
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/event/CustomHandlerAdapter.java b/proxy/src/main/java/com/velocitypowered/proxy/event/CustomHandlerAdapter.java
index 8b9df6dded..884f0f617f 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/event/CustomHandlerAdapter.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/event/CustomHandlerAdapter.java
@@ -60,9 +60,7 @@ final class CustomHandlerAdapter {
UntargetedEventHandler buildUntargetedHandler(final Method method)
throws IllegalAccessException {
final MethodHandle methodHandle = methodHandlesLookup.unreflect(method);
- final MethodHandles.Lookup defineLookup = MethodHandles.privateLookupIn(
- method.getDeclaringClass(), methodHandlesLookup);
- final LambdaType lambdaType = functionType.defineClassesWith(defineLookup);
+ final LambdaType lambdaType = functionType.defineClassesWith(methodHandlesLookup);
final F invokeFunction = LambdaFactory.create(lambdaType, methodHandle);
final BiFunction
*
- * Note that this is effectively unused for 1.20.5+ clients, as commands without any signature do not send 'last seen'
- * updates.
+ *
Note that this is effectively unused for 1.20.5+ clients, as commands without any signature do not send 'last seen'
+ * updates.
*/
public static class ChatState {
private static final int MINIMUM_DELAYED_ACK_COUNT = LastSeenMessages.WINDOW_SIZE;
@@ -160,6 +167,13 @@ public static class ChatState {
private ChatState() {
}
+ /**
+ * Updates the tracked chat state from an incoming message and resolves its last-seen messages.
+ *
+ * @param timestamp the message timestamp, or {@code null} if the message is unsigned
+ * @param lastSeenMessages the last-seen messages reported by the message, or {@code null}
+ * @return the resolved last-seen messages, or {@code null} if unavailable
+ */
@Nullable
public LastSeenMessages updateFromMessage(@Nullable Instant timestamp, @Nullable LastSeenMessages lastSeenMessages) {
if (timestamp != null) {
@@ -174,6 +188,12 @@ public LastSeenMessages updateFromMessage(@Nullable Instant timestamp, @Nullable
return null;
}
+ /**
+ * Accumulates pending acknowledgements and reports how many should now be forwarded.
+ *
+ * @param ackCount the number of newly acknowledged messages
+ * @return the number of acknowledgements to forward
+ */
public int accumulateAckCount(int ackCount) {
int delayedAckCount = this.delayedAckCount.addAndGet(ackCount);
int ackCountToForward = delayedAckCount - MINIMUM_DELAYED_ACK_COUNT;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatTimeKeeper.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatTimeKeeper.java
index 94fc535678..3874c77236 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatTimeKeeper.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatTimeKeeper.java
@@ -19,6 +19,9 @@
import java.time.Instant;
+/**
+ * Tracks chat message timestamps to detect out-of-order or future-dated messages.
+ */
public class ChatTimeKeeper {
private Instant lastTimestamp;
@@ -27,6 +30,12 @@ public ChatTimeKeeper() {
this.lastTimestamp = Instant.MIN;
}
+ /**
+ * Records the given timestamp and reports whether it is valid relative to the last one seen.
+ *
+ * @param instant the timestamp of the latest message
+ * @return {@code true} if the timestamp is in order
+ */
public boolean update(Instant instant) {
if (instant.isBefore(this.lastTimestamp)) {
this.lastTimestamp = instant;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatType.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatType.java
index 66e4e98841..dfa0b55e26 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatType.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatType.java
@@ -17,6 +17,9 @@
package com.velocitypowered.proxy.protocol.packet.chat;
+/**
+ * The categories of chat message recognized by the legacy chat protocol.
+ */
public enum ChatType {
CHAT((byte) 0),
SYSTEM((byte) 1),
@@ -31,4 +34,4 @@ public enum ChatType {
public byte getId() {
return raw;
}
-}
\ No newline at end of file
+}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/CommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/CommandHandler.java
index 8e39d78a30..510c18942f 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/CommandHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/CommandHandler.java
@@ -31,6 +31,11 @@
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * Handles inbound player command packets of a specific type.
+ *
+ * @param the command packet type handled by this handler
+ */
public interface CommandHandler {
Logger logger = LogManager.getLogger(CommandHandler.class);
@@ -39,6 +44,12 @@ public interface CommandHandler {
void handlePlayerCommandInternal(T packet);
+ /**
+ * Handles the given packet if it matches this handler's packet type.
+ *
+ * @param packet the packet to handle
+ * @return {@code true} if the packet was handled by this handler
+ */
default boolean handlePlayerCommand(MinecraftPacket packet) {
if (packetClass().isInstance(packet)) {
handlePlayerCommandInternal(packetClass().cast(packet));
@@ -54,25 +65,36 @@ default CompletableFuture runCommand(VelocityServer server,
.thenApply(hasRunPacketFunction);
}
+ /**
+ * Runs the command event and queues the resulting packet so it is sent in chat order.
+ *
+ * @param server the proxy server
+ * @param player the player who issued the command
+ * @param futurePacketCreator builds the packet to forward once the command event completes
+ * @param message the raw command text
+ * @param timestamp the time the command was issued
+ * @param lastSeenMessages the last-seen messages reported with the command, or {@code null}
+ * @param invocationInfo the command invocation metadata
+ */
default void queueCommandResult(VelocityServer server, ConnectedPlayer player,
BiFunction> futurePacketCreator,
String message, Instant timestamp, @Nullable LastSeenMessages lastSeenMessages,
CommandExecuteEvent.InvocationInfo invocationInfo) {
- CompletableFuture eventFuture = server.getCommandManager().callCommandEvent(player, message,
- invocationInfo);
- player.getChatQueue().queuePacket(
+ CompletableFuture eventFuture = server.getCommandManager().callCommandEvent(player, message,
+ invocationInfo);
+ player.getChatQueue().queuePacket(
newLastSeenMessages -> eventFuture
- .thenComposeAsync(event -> futurePacketCreator.apply(event, newLastSeenMessages))
- .thenApply(pkt -> {
- if (server.getConfiguration().isLogCommandExecutions()) {
- logger.info("{} -> executed command /{}", player, message);
- }
- return pkt;
- }).exceptionally(e -> {
- logger.info("Exception occurred while running command for {}", player.getUsername(), e);
- player.sendMessage(
- Component.translatable("velocity.command.generic-error", NamedTextColor.RED));
- return null;
- }), timestamp, lastSeenMessages);
+ .thenComposeAsync(event -> futurePacketCreator.apply(event, newLastSeenMessages))
+ .thenApply(pkt -> {
+ if (server.getConfiguration().isLogCommandExecutions()) {
+ logger.info("{} -> executed command /{}", player, message);
+ }
+ return pkt;
+ }).exceptionally(e -> {
+ logger.info("Exception occurred while running command for {}", player.getUsername(), e);
+ player.sendMessage(
+ Component.translatable("velocity.command.generic-error", NamedTextColor.RED));
+ return null;
+ }), timestamp, lastSeenMessages);
}
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java
index 0b00332607..32558ffd94 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java
@@ -25,6 +25,9 @@
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import net.kyori.adventure.nbt.BinaryTag;
import net.kyori.adventure.nbt.BinaryTagIO;
import net.kyori.adventure.nbt.BinaryTagType;
@@ -47,10 +50,10 @@
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
+/**
+ * Holds a chat component in whichever form it was received and converts between the JSON,
+ * binary tag, and parsed representations on demand.
+ */
public class ComponentHolder {
private static final Logger logger = LogManager.getLogger(ComponentHolder.class);
public static final int DEFAULT_MAX_STRING_SIZE = 262143;
@@ -75,6 +78,11 @@ public ComponentHolder(ProtocolVersion version, BinaryTag binaryTag) {
this.binaryTag = binaryTag;
}
+ /**
+ * Returns this holder's value as a parsed component, converting it if necessary.
+ *
+ * @return the component
+ */
public Component getComponent() {
if (component == null) {
if (json != null) {
@@ -95,6 +103,11 @@ public Component getComponent() {
return component;
}
+ /**
+ * Returns this holder's value as a JSON string, converting it if necessary.
+ *
+ * @return the JSON representation
+ */
public String getJson() {
if (json == null) {
json = ProtocolUtils.getJsonChatSerializer(version).serialize(getComponent());
@@ -102,6 +115,11 @@ public String getJson() {
return json;
}
+ /**
+ * Returns this holder's value as a binary tag, converting it if necessary.
+ *
+ * @return the binary tag representation
+ */
public BinaryTag getBinaryTag() {
if (binaryTag == null) {
// TODO: replace this with adventure-text-serializer-nbt
@@ -110,6 +128,12 @@ public BinaryTag getBinaryTag() {
return binaryTag;
}
+ /**
+ * Converts a JSON component tree into its equivalent binary tag form.
+ *
+ * @param json the JSON element to convert
+ * @return the equivalent binary tag
+ */
public static BinaryTag serialize(JsonElement json) {
if (json instanceof JsonPrimitive jsonPrimitive) {
if (jsonPrimitive.isNumber()) {
@@ -162,36 +186,40 @@ public static BinaryTag serialize(JsonElement json) {
}
switch (listType.id()) {
- case 1://BinaryTagTypes.BYTE:
+ case 1 -> { // BinaryTagTypes.BYTE:
byte[] bytes = new byte[jsonArray.size()];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = jsonArray.get(i).getAsNumber().byteValue();
}
return ByteArrayBinaryTag.byteArrayBinaryTag(bytes);
- case 3://BinaryTagTypes.INT:
+ }
+ case 3 -> { // BinaryTagTypes.INT:
int[] ints = new int[jsonArray.size()];
for (int i = 0; i < ints.length; i++) {
ints[i] = jsonArray.get(i).getAsNumber().intValue();
}
return IntArrayBinaryTag.intArrayBinaryTag(ints);
- case 4://BinaryTagTypes.LONG:
+ }
+ case 4 -> { // BinaryTagTypes.LONG:
long[] longs = new long[jsonArray.size()];
for (int i = 0; i < longs.length; i++) {
longs[i] = jsonArray.get(i).getAsNumber().longValue();
}
return LongArrayBinaryTag.longArrayBinaryTag(longs);
- case 10://BinaryTagTypes.COMPOUND:
- tagItems.replaceAll(tag -> {
- if (tag.type() == BinaryTagTypes.COMPOUND) {
- return tag;
- } else {
- return CompoundBinaryTag.builder().put("", tag).build();
- }
- });
- break;
+ }
+ case 10 -> // BinaryTagTypes.COMPOUND:
+ tagItems.replaceAll(tag -> {
+ if (tag.type() == BinaryTagTypes.COMPOUND) {
+ return tag;
+ } else {
+ return CompoundBinaryTag.builder().put("", tag).build();
+ }
+ });
+ default -> {
+ }
}
return ListBinaryTag.listBinaryTag(listType, tagItems);
@@ -200,21 +228,27 @@ public static BinaryTag serialize(JsonElement json) {
return EndBinaryTag.endBinaryTag();
}
+ /**
+ * Converts a binary tag component tree into its equivalent JSON form.
+ *
+ * @param tag the binary tag to convert
+ * @return the equivalent JSON element
+ */
public static JsonElement deserialize(BinaryTag tag) {
return switch (tag.type().id()) {
- //BinaryTagTypes.BYTE
+ // BinaryTagTypes.BYTE
case 1 -> new JsonPrimitive(((ByteBinaryTag) tag).value());
- //BinaryTagTypes.SHORT
+ // BinaryTagTypes.SHORT
case 2 -> new JsonPrimitive(((ShortBinaryTag) tag).value());
- //BinaryTagTypes.INT:
+ // BinaryTagTypes.INT:
case 3 -> new JsonPrimitive(((IntBinaryTag) tag).value());
- //BinaryTagTypes.LONG:
+ // BinaryTagTypes.LONG:
case 4 -> new JsonPrimitive(((LongBinaryTag) tag).value());
- //BinaryTagTypes.FLOAT:
+ // BinaryTagTypes.FLOAT:
case 5 -> new JsonPrimitive(((FloatBinaryTag) tag).value());
- //BinaryTagTypes.DOUBLE:
+ // BinaryTagTypes.DOUBLE:
case 6 -> new JsonPrimitive(((DoubleBinaryTag) tag).value());
- //BinaryTagTypes.BYTE_ARRAY:
+ // BinaryTagTypes.BYTE_ARRAY:
case 7 -> {
byte[] byteArray = ((ByteArrayBinaryTag) tag).value();
@@ -225,9 +259,9 @@ public static JsonElement deserialize(BinaryTag tag) {
yield jsonByteArray;
}
- //BinaryTagTypes.STRING:
+ // BinaryTagTypes.STRING:
case 8 -> new JsonPrimitive(((StringBinaryTag) tag).value());
- //BinaryTagTypes.LIST:
+ // BinaryTagTypes.LIST:
case 9 -> {
ListBinaryTag items = (ListBinaryTag) tag;
JsonArray jsonList = new JsonArray(items.size());
@@ -238,7 +272,7 @@ public static JsonElement deserialize(BinaryTag tag) {
yield jsonList;
}
- //BinaryTagTypes.COMPOUND:
+ // BinaryTagTypes.COMPOUND:
case 10 -> {
CompoundBinaryTag compound = (CompoundBinaryTag) tag;
JsonObject jsonObject = new JsonObject();
@@ -247,14 +281,14 @@ public static JsonElement deserialize(BinaryTag tag) {
// [{"text":"test1"},"test2"] can't be represented as a binary list tag
// it is represented by a list tag with two compound tags
// the second compound tag will have an empty key mapped to "test2"
- // without this fix this would lead to an invalid json component:
+ // without this fix this would lead to an invalid JSON component:
// [{"text":"test1"},{"":"test2"}]
jsonObject.add(key.isEmpty() ? "text" : key, deserialize(compound.get(key)));
});
yield jsonObject;
}
- //BinaryTagTypes.INT_ARRAY:
+ // BinaryTagTypes.INT_ARRAY:
case 11 -> {
int[] intArray = ((IntArrayBinaryTag) tag).value();
@@ -265,7 +299,7 @@ public static JsonElement deserialize(BinaryTag tag) {
yield jsonIntArray;
}
- //BinaryTagTypes.LONG_ARRAY:
+ // BinaryTagTypes.LONG_ARRAY:
case 12 -> {
long[] longArray = ((LongArrayBinaryTag) tag).value();
@@ -280,6 +314,13 @@ public static JsonElement deserialize(BinaryTag tag) {
};
}
+ /**
+ * Reads a component from the buffer in the form appropriate to the protocol version.
+ *
+ * @param buf the buffer to read from
+ * @param version the protocol version being decoded
+ * @return the component holder
+ */
public static ComponentHolder read(ByteBuf buf, ProtocolVersion version) {
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
return new ComponentHolder(version,
@@ -291,6 +332,11 @@ public static ComponentHolder read(ByteBuf buf, ProtocolVersion version) {
}
}
+ /**
+ * Writes this component to the buffer in the form appropriate to the protocol version.
+ *
+ * @param buf the buffer to write to
+ */
public void write(ByteBuf buf) {
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
ProtocolUtils.writeBinaryTag(buf, version, getBinaryTag());
@@ -298,4 +344,4 @@ public void write(ByteBuf buf) {
ProtocolUtils.writeString(buf, getJson());
}
}
-}
\ No newline at end of file
+}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/LastSeenMessages.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/LastSeenMessages.java
index c03e5f8c3f..9bcf1276c2 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/LastSeenMessages.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/LastSeenMessages.java
@@ -23,6 +23,10 @@
import java.util.Arrays;
import java.util.BitSet;
+/**
+ * Represents the set of recently seen chat messages a client acknowledges when sending signed
+ * chat.
+ */
public class LastSeenMessages {
public static final int WINDOW_SIZE = 20;
@@ -35,12 +39,25 @@ public LastSeenMessages() {
this(0, new BitSet(), (byte) 0);
}
+ /**
+ * Creates a last-seen messages record with the given values.
+ *
+ * @param offset the index offset of the acknowledged window
+ * @param acknowledged the bit set of acknowledged messages
+ * @param checksum the checksum of the acknowledged messages
+ */
public LastSeenMessages(int offset, BitSet acknowledged, byte checksum) {
this.offset = offset;
this.acknowledged = acknowledged;
this.checksum = checksum;
}
+ /**
+ * Reads a last-seen messages record from the buffer.
+ *
+ * @param buf the buffer to read from
+ * @param protocolVersion the protocol version being decoded
+ */
public LastSeenMessages(ByteBuf buf, ProtocolVersion protocolVersion) {
this.offset = ProtocolUtils.readVarInt(buf);
@@ -53,6 +70,12 @@ public LastSeenMessages(ByteBuf buf, ProtocolVersion protocolVersion) {
}
}
+ /**
+ * Writes this last-seen messages record to the buffer.
+ *
+ * @param buf the buffer to write to
+ * @param protocolVersion the protocol version being encoded
+ */
public void encode(ByteBuf buf, ProtocolVersion protocolVersion) {
ProtocolUtils.writeVarInt(buf, offset);
buf.writeBytes(Arrays.copyOf(acknowledged.toByteArray(), DIV_FLOOR));
@@ -75,10 +98,10 @@ public LastSeenMessages offset(final int offset) {
@Override
public String toString() {
- return "LastSeenMessages{" +
- "offset=" + offset +
- ", acknowledged=" + acknowledged +
- ", checksum=" + checksum +
- '}';
+ return "LastSeenMessages{"
+ + "offset=" + offset
+ + ", acknowledged=" + acknowledged
+ + ", checksum=" + checksum
+ + '}';
}
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/PlayerChatCompletionPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/PlayerChatCompletionPacket.java
index d07b798a52..17cec26e04 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/PlayerChatCompletionPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/PlayerChatCompletionPacket.java
@@ -23,6 +23,9 @@
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
+/**
+ * The clientbound packet that adds, removes, or sets the chat auto-completion suggestions.
+ */
public class PlayerChatCompletionPacket implements MinecraftPacket {
private String[] completions;
@@ -71,6 +74,9 @@ public boolean handle(MinecraftSessionHandler handler) {
return handler.handle(this);
}
+ /**
+ * The operations a {@link PlayerChatCompletionPacket} can perform on the completion list.
+ */
public enum Action {
ADD,
REMOVE,
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RateLimitedCommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RateLimitedCommandHandler.java
index e582364359..f60bdf4959 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RateLimitedCommandHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RateLimitedCommandHandler.java
@@ -22,37 +22,43 @@
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import net.kyori.adventure.text.Component;
+/**
+ * A command handler that applies the proxy's command rate limit before dispatching a command.
+ *
+ * @param the command packet type handled by this handler
+ */
public abstract class RateLimitedCommandHandler implements CommandHandler {
- private final Player player;
- private final VelocityServer velocityServer;
+ private final Player player;
+ private final VelocityServer velocityServer;
- private int failedAttempts;
+ private int failedAttempts;
- protected RateLimitedCommandHandler(Player player, VelocityServer velocityServer) {
- this.player = player;
- this.velocityServer = velocityServer;
- }
+ protected RateLimitedCommandHandler(Player player, VelocityServer velocityServer) {
+ this.player = player;
+ this.velocityServer = velocityServer;
+ }
- @Override
- public boolean handlePlayerCommand(MinecraftPacket packet) {
- if (packetClass().isInstance(packet)) {
- if (!velocityServer.getCommandRateLimiter().attempt(player.getUniqueId())) {
- if (velocityServer.getConfiguration().isKickOnCommandRateLimit() && failedAttempts++ >= velocityServer.getConfiguration().getKickAfterRateLimitedCommands()) {
- player.disconnect(Component.translatable("velocity.kick.command-rate-limit"));
- }
-
- if (velocityServer.getConfiguration().isForwardCommandsIfRateLimited()) {
- return false; // Send the packet to the server
- }
- } else {
- failedAttempts = 0;
- }
-
- handlePlayerCommandInternal(packetClass().cast(packet));
- return true;
+ @Override
+ public boolean handlePlayerCommand(MinecraftPacket packet) {
+ if (packetClass().isInstance(packet)) {
+ if (!velocityServer.getCommandRateLimiter().attempt(player.getUniqueId())) {
+ if (velocityServer.getConfiguration().isKickOnCommandRateLimit()
+ && failedAttempts++ >= velocityServer.getConfiguration().getKickAfterRateLimitedCommands()) {
+ player.disconnect(Component.translatable("velocity.kick.command-rate-limit"));
}
- return false;
+ if (velocityServer.getConfiguration().isForwardCommandsIfRateLimited()) {
+ return false; // Send the packet to the server
+ }
+ } else {
+ failedAttempts = 0;
+ }
+
+ handlePlayerCommandInternal(packetClass().cast(packet));
+ return true;
}
+
+ return false;
+ }
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RemoteChatSession.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RemoteChatSession.java
index 9dd5950a97..c991e54da2 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RemoteChatSession.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RemoteChatSession.java
@@ -26,6 +26,10 @@
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * Represents a player's signed chat session, holding the session id and public key used to
+ * verify messages.
+ */
public class RemoteChatSession implements ChatSession {
private final @Nullable UUID sessionId;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/SystemChatPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/SystemChatPacket.java
index 1a26affda4..c553c6dec2 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/SystemChatPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/SystemChatPacket.java
@@ -23,6 +23,9 @@
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
+/**
+ * The clientbound packet carrying a system chat message, which is not attributed to a player.
+ */
public class SystemChatPacket implements MinecraftPacket {
public SystemChatPacket() {
@@ -47,7 +50,7 @@ public ComponentHolder getComponent() {
@Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
component = ComponentHolder.read(buf, version);
- if (version.noLessThan(ProtocolVersion.MINECRAFT_1_19_1)){
+ if (version.noLessThan(ProtocolVersion.MINECRAFT_1_19_1)) {
type = buf.readBoolean() ? ChatType.GAME_INFO : ChatType.SYSTEM;
} else {
type = ChatType.values()[ProtocolUtils.readVarInt(buf)];
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderFactory.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderFactory.java
index b0d2f12af0..1deec8f4f8 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderFactory.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderFactory.java
@@ -23,11 +23,19 @@
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionChatBuilder;
import java.util.function.Function;
+/**
+ * Creates the chat builder appropriate to a given protocol version.
+ */
public class ChatBuilderFactory {
private final ProtocolVersion version;
private final Function builderFunction;
+ /**
+ * Creates a chat builder factory targeting the given protocol version.
+ *
+ * @param version the protocol version to build chat packets for
+ */
public ChatBuilderFactory(ProtocolVersion version) {
this.version = version;
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_19_3)) {
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderV2.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderV2.java
index 9ac0286460..9546fce7e1 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderV2.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderV2.java
@@ -28,6 +28,9 @@
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * The base class for protocol-version-specific builders that assemble outbound chat packets.
+ */
public abstract class ChatBuilderV2 {
protected final ProtocolVersion version;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatBuilder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatBuilder.java
index d654c619c7..ed99518660 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatBuilder.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatBuilder.java
@@ -26,6 +26,9 @@
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
import net.kyori.adventure.text.Component;
+/**
+ * A chat builder that produces keyed (1.19-1.19.1) signed chat packets.
+ */
public class KeyedChatBuilder extends ChatBuilderV2 {
public KeyedChatBuilder(ProtocolVersion version) {
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatHandler.java
index f8fc906abb..e37c806faa 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatHandler.java
@@ -30,6 +30,9 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+/**
+ * Handles keyed (1.19-1.19.1) signed player chat packets.
+ */
public class KeyedChatHandler implements
com.velocitypowered.proxy.protocol.packet.chat.ChatHandler {
@@ -48,6 +51,12 @@ public Class packetClass() {
return KeyedPlayerChatPacket.class;
}
+ /**
+ * Logs that a plugin attempted to cancel a signed chat message, which is no longer permitted.
+ *
+ * @param logger the logger to report through
+ * @param player the player whose message was affected
+ */
public static void invalidCancel(Logger logger, ConnectedPlayer player) {
logger.fatal("A plugin tried to cancel a signed chat message."
+ " This is no longer possible in 1.19.1 and newer. "
@@ -56,6 +65,12 @@ public static void invalidCancel(Logger logger, ConnectedPlayer player) {
+ "Contact your network administrator."));
}
+ /**
+ * Logs that a plugin attempted to modify a signed chat message, which is no longer permitted.
+ *
+ * @param logger the logger to report through
+ * @param player the player whose message was affected
+ */
public static void invalidChange(Logger logger, ConnectedPlayer player) {
logger.fatal("A plugin tried to change a signed chat message. "
+ "This is no longer possible in 1.19.1 and newer. "
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedCommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedCommandHandler.java
index b10332f026..53afc2ac34 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedCommandHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedCommandHandler.java
@@ -26,11 +26,20 @@
import java.util.concurrent.CompletableFuture;
import net.kyori.adventure.text.Component;
+/**
+ * Handles keyed (1.19-1.19.1) signed player command packets.
+ */
public class KeyedCommandHandler extends RateLimitedCommandHandler {
private final ConnectedPlayer player;
private final VelocityServer server;
+ /**
+ * Creates a keyed command handler for the given player.
+ *
+ * @param player the player whose commands are handled
+ * @param server the proxy server
+ */
public KeyedCommandHandler(ConnectedPlayer player, VelocityServer server) {
super(player, server);
this.player = player;
@@ -112,6 +121,7 @@ public void handlePlayerCommandInternal(KeyedPlayerCommandPacket packet) {
}
return null;
});
- }, packet.getCommand(), packet.getTimestamp(), null, new CommandExecuteEvent.InvocationInfo(CommandExecuteEvent.SignedState.UNSUPPORTED, CommandExecuteEvent.Source.PLAYER));
+ }, packet.getCommand(), packet.getTimestamp(), null, new CommandExecuteEvent.InvocationInfo(CommandExecuteEvent.SignedState.UNSUPPORTED,
+ CommandExecuteEvent.Source.PLAYER));
}
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerChatPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerChatPacket.java
index 74fa88f5a5..4e80ea75a0 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerChatPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerChatPacket.java
@@ -29,6 +29,9 @@
import java.time.Instant;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * A keyed (1.19-1.19.1) signed player chat message.
+ */
public class KeyedPlayerChatPacket implements MinecraftPacket {
private String message;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerCommandPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerCommandPacket.java
index 0bb43ec8e9..47095da379 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerCommandPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerCommandPacket.java
@@ -35,6 +35,9 @@
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * A keyed (1.19-1.19.1) signed player command, including its per-argument signatures.
+ */
public class KeyedPlayerCommandPacket implements MinecraftPacket {
private static final int MAX_NUM_ARGUMENTS = 8;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatBuilder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatBuilder.java
index 77df43bb42..811db99705 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatBuilder.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatBuilder.java
@@ -25,6 +25,9 @@
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
+/**
+ * A chat builder that produces legacy (pre-1.19) chat packets.
+ */
public class LegacyChatBuilder extends ChatBuilderV2 {
public LegacyChatBuilder(ProtocolVersion version) {
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatHandler.java
index b7a641ca98..d9eb1eca07 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatHandler.java
@@ -23,6 +23,9 @@
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler;
+/**
+ * Handles legacy (pre-1.19) player chat packets.
+ */
public class LegacyChatHandler implements ChatHandler {
private final VelocityServer server;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatPacket.java
index f5bb6b4f9a..6ffc289d4e 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatPacket.java
@@ -25,6 +25,9 @@
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * The legacy (pre-1.19) chat packet, used for both player and system messages.
+ */
public class LegacyChatPacket implements MinecraftPacket {
public static final byte CHAT_TYPE = (byte) 0;
@@ -45,6 +48,7 @@ private static int getMaxServerboundMessageLength() {
try {
return Integer.parseInt(value.trim());
} catch (final NumberFormatException e) {
+ // Exception has been handled
}
}
return 100;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyCommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyCommandHandler.java
index 4f88ee34a6..24e131ed08 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyCommandHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyCommandHandler.java
@@ -21,15 +21,23 @@
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.protocol.packet.chat.RateLimitedCommandHandler;
-
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
+/**
+ * Handles commands issued through the legacy (pre-1.19) chat packet.
+ */
public class LegacyCommandHandler extends RateLimitedCommandHandler {
private final ConnectedPlayer player;
private final VelocityServer server;
+ /**
+ * Creates a legacy command handler for the given player.
+ *
+ * @param player the player whose commands are handled
+ * @param server the proxy server
+ */
public LegacyCommandHandler(ConnectedPlayer player, VelocityServer server) {
super(player, server);
this.player = player;
@@ -64,6 +72,7 @@ public void handlePlayerCommandInternal(LegacyChatPacket packet) {
}
return null;
});
- }, command, Instant.now(), null, new CommandExecuteEvent.InvocationInfo(CommandExecuteEvent.SignedState.UNSUPPORTED, CommandExecuteEvent.Source.PLAYER));
+ }, command, Instant.now(), null, new CommandExecuteEvent.InvocationInfo(CommandExecuteEvent.SignedState.UNSUPPORTED,
+ CommandExecuteEvent.Source.PLAYER));
}
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatBuilder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatBuilder.java
index eb74123fc7..30a970569b 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatBuilder.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatBuilder.java
@@ -26,6 +26,9 @@
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
import net.kyori.adventure.text.Component;
+/**
+ * A chat builder that produces session-signed (1.19.1+) chat packets.
+ */
public class SessionChatBuilder extends ChatBuilderV2 {
public SessionChatBuilder(ProtocolVersion version) {
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatHandler.java
index 74b5747f92..d1c81a194a 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatHandler.java
@@ -26,11 +26,13 @@
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler;
import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue;
+import java.util.concurrent.CompletableFuture;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import java.util.concurrent.CompletableFuture;
-
+/**
+ * Handles session-signed (1.19.1+) player chat packets.
+ */
public class SessionChatHandler implements ChatHandler {
private static final Logger logger = LogManager.getLogger(SessionChatHandler.class);
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionCommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionCommandHandler.java
index 6978f8ee26..11f0198817 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionCommandHandler.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionCommandHandler.java
@@ -22,17 +22,25 @@
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgementPacket;
-import java.util.concurrent.CompletableFuture;
-
import com.velocitypowered.proxy.protocol.packet.chat.RateLimitedCommandHandler;
+import java.util.concurrent.CompletableFuture;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * Handles session-signed (1.19.1+) player command packets.
+ */
public class SessionCommandHandler extends RateLimitedCommandHandler {
private final ConnectedPlayer player;
private final VelocityServer server;
+ /**
+ * Creates a session command handler for the given player.
+ *
+ * @param player the player whose commands are handled
+ * @param server the proxy server
+ */
public SessionCommandHandler(ConnectedPlayer player, VelocityServer server) {
super(player, server);
this.player = player;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerChatPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerChatPacket.java
index 8a00452c6c..b536aade02 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerChatPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerChatPacket.java
@@ -25,6 +25,9 @@
import io.netty.buffer.ByteBuf;
import java.time.Instant;
+/**
+ * A session-signed (1.19.1+) player chat message.
+ */
public class SessionPlayerChatPacket implements MinecraftPacket {
protected String message;
@@ -100,6 +103,12 @@ protected static byte[] readMessageSignature(ByteBuf buf) {
return signature;
}
+ /**
+ * Returns a copy of this packet carrying the given last-seen messages.
+ *
+ * @param lastSeenMessages the last-seen messages to attach
+ * @return the copied packet
+ */
public SessionPlayerChatPacket withLastSeenMessages(LastSeenMessages lastSeenMessages) {
SessionPlayerChatPacket packet = new SessionPlayerChatPacket();
packet.message = message;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerCommandPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerCommandPacket.java
index f4ea3a1e2d..ccb464a4d7 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerCommandPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerCommandPacket.java
@@ -26,11 +26,13 @@
import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages;
import com.velocitypowered.proxy.util.except.QuietDecoderException;
import io.netty.buffer.ByteBuf;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
import java.time.Instant;
import java.util.List;
+import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * A session-signed (1.19.1+) player command, including its per-argument signatures.
+ */
public class SessionPlayerCommandPacket implements MinecraftPacket {
protected String command;
@@ -71,7 +73,8 @@ public boolean isSigned() {
}
public CommandExecuteEvent.SignedState getEventSignedState() {
- return !this.argumentSignatures.isEmpty() ? CommandExecuteEvent.SignedState.SIGNED_WITH_ARGS : CommandExecuteEvent.SignedState.SIGNED_WITHOUT_ARGS;
+ return !this.argumentSignatures.isEmpty() ? CommandExecuteEvent.SignedState.SIGNED_WITH_ARGS
+ : CommandExecuteEvent.SignedState.SIGNED_WITHOUT_ARGS;
}
@Override
@@ -81,15 +84,23 @@ public boolean handle(MinecraftSessionHandler handler) {
@Override
public String toString() {
- return "SessionPlayerCommand{" +
- "command='" + command + '\'' +
- ", timeStamp=" + timeStamp +
- ", salt=" + salt +
- ", argumentSignatures=" + argumentSignatures +
- ", lastSeenMessages=" + lastSeenMessages +
- '}';
+ return "SessionPlayerCommand{"
+ + "command='" + command + '\''
+ + ", timeStamp=" + timeStamp
+ + ", salt=" + salt
+ + ", argumentSignatures=" + argumentSignatures
+ + ", lastSeenMessages=" + lastSeenMessages
+ + '}';
}
+ /**
+ * Returns a command packet carrying the given last-seen messages, producing an unsigned
+ * command when none are supplied.
+ *
+ * @param lastSeenMessages the last-seen messages to attach, or {@code null} for an unsigned
+ * command
+ * @return the resulting command packet
+ */
public SessionPlayerCommandPacket withLastSeenMessages(@Nullable LastSeenMessages lastSeenMessages) {
if (lastSeenMessages == null) {
UnsignedPlayerCommandPacket packet = new UnsignedPlayerCommandPacket();
@@ -105,6 +116,9 @@ public SessionPlayerCommandPacket withLastSeenMessages(@Nullable LastSeenMessage
return packet;
}
+ /**
+ * The collection of per-argument signatures attached to a signed command.
+ */
public static class ArgumentSignatures {
private final List entries;
@@ -113,6 +127,11 @@ public ArgumentSignatures() {
this.entries = List.of();
}
+ /**
+ * Reads a set of argument signatures from the buffer.
+ *
+ * @param buf the buffer to read from
+ */
public ArgumentSignatures(ByteBuf buf) {
int size = ProtocolUtils.readVarInt(buf);
if (size > 8) {
@@ -130,20 +149,29 @@ public boolean isEmpty() {
return this.entries.isEmpty();
}
+ /**
+ * Writes these argument signatures to the buffer.
+ *
+ * @param buf the buffer to write to
+ */
public void encode(ByteBuf buf) {
ProtocolUtils.writeVarInt(buf, entries.size());
for (ArgumentSignature entry : entries) {
entry.encode(buf);
}
}
+
@Override
public String toString() {
- return "ArgumentSignatures{" +
- "entries=" + entries +
- '}';
+ return "ArgumentSignatures{"
+ + "entries=" + entries
+ + '}';
}
}
+ /**
+ * A single argument name paired with its signature bytes.
+ */
public static class ArgumentSignature {
private final String name;
@@ -161,9 +189,9 @@ public void encode(ByteBuf buf) {
@Override
public String toString() {
- return "ArgumentSignature{" +
- "name='" + name + '\'' +
- '}';
+ return "ArgumentSignature{"
+ + "name='" + name + '\''
+ + '}';
}
}
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/UnsignedPlayerCommandPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/UnsignedPlayerCommandPacket.java
index 915f0cfbc7..9307bb479d 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/UnsignedPlayerCommandPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/UnsignedPlayerCommandPacket.java
@@ -24,6 +24,9 @@
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * A player command that carries no signature, used when a signed command is not required.
+ */
public class UnsignedPlayerCommandPacket extends SessionPlayerCommandPacket {
@Override
@@ -52,8 +55,8 @@ public CommandExecuteEvent.SignedState getEventSignedState() {
@Override
public String toString() {
- return "UnsignedPlayerCommandPacket{" +
- "command='" + command + '\'' +
- '}';
+ return "UnsignedPlayerCommandPacket{"
+ + "command='" + command + '\''
+ + '}';
}
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ActiveFeaturesPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ActiveFeaturesPacket.java
index 79c94b641b..09102c6506 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ActiveFeaturesPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ActiveFeaturesPacket.java
@@ -24,6 +24,9 @@
import io.netty.buffer.ByteBuf;
import net.kyori.adventure.key.Key;
+/**
+ * The clientbound configuration packet listing the feature flags active on the server.
+ */
public class ActiveFeaturesPacket implements MinecraftPacket {
private Key[] activeFeatures;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundCustomReportDetailsPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundCustomReportDetailsPacket.java
index 05f535d42c..482c554fab 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundCustomReportDetailsPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundCustomReportDetailsPacket.java
@@ -24,43 +24,47 @@
import io.netty.buffer.ByteBuf;
import java.util.Map;
+/**
+ * The clientbound packet supplying custom key-value details to include in client crash
+ * reports.
+ */
public class ClientboundCustomReportDetailsPacket implements MinecraftPacket {
- private Map details;
+ private Map details;
- public ClientboundCustomReportDetailsPacket() {
- }
+ public ClientboundCustomReportDetailsPacket() {
+ }
- public ClientboundCustomReportDetailsPacket(Map details) {
- this.details = details;
- }
+ public ClientboundCustomReportDetailsPacket(Map details) {
+ this.details = details;
+ }
- @Override
- public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
- int detailsCount = ProtocolUtils.readVarInt(buf);
+ @Override
+ public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
+ int detailsCount = ProtocolUtils.readVarInt(buf);
- this.details = ProtocolUtils.newMap(detailsCount);
- for (int i = 0; i < detailsCount; i++) {
- details.put(ProtocolUtils.readString(buf), ProtocolUtils.readString(buf));
- }
+ this.details = ProtocolUtils.newMap(detailsCount);
+ for (int i = 0; i < detailsCount; i++) {
+ details.put(ProtocolUtils.readString(buf), ProtocolUtils.readString(buf));
}
+ }
- @Override
- public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
- ProtocolUtils.writeVarInt(buf, details.size());
+ @Override
+ public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
+ ProtocolUtils.writeVarInt(buf, details.size());
- details.forEach((key, detail) -> {
- ProtocolUtils.writeString(buf, key);
- ProtocolUtils.writeString(buf, detail);
- });
- }
+ details.forEach((key, detail) -> {
+ ProtocolUtils.writeString(buf, key);
+ ProtocolUtils.writeString(buf, detail);
+ });
+ }
- @Override
- public boolean handle(MinecraftSessionHandler handler) {
- return handler.handle(this);
- }
+ @Override
+ public boolean handle(MinecraftSessionHandler handler) {
+ return handler.handle(this);
+ }
- public Map getDetails() {
- return details;
- }
+ public Map getDetails() {
+ return details;
+ }
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundServerLinksPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundServerLinksPacket.java
index e30c8a7d27..0e620872e8 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundServerLinksPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundServerLinksPacket.java
@@ -25,64 +25,74 @@
import io.netty.buffer.ByteBuf;
import java.util.List;
+/**
+ * The clientbound packet that provides the client with a set of server links.
+ */
public class ClientboundServerLinksPacket implements MinecraftPacket {
- private List serverLinks;
+ private List serverLinks;
- public ClientboundServerLinksPacket() {
- }
+ public ClientboundServerLinksPacket() {
+ }
- public ClientboundServerLinksPacket(List serverLinks) {
- this.serverLinks = serverLinks;
- }
+ public ClientboundServerLinksPacket(List serverLinks) {
+ this.serverLinks = serverLinks;
+ }
- @Override
- public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
- int linksCount = ProtocolUtils.readVarInt(buf);
+ @Override
+ public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
+ int linksCount = ProtocolUtils.readVarInt(buf);
- this.serverLinks = ProtocolUtils.newList(linksCount);
- for (int i = 0; i < linksCount; i++) {
- serverLinks.add(ServerLink.read(buf, version));
- }
+ this.serverLinks = ProtocolUtils.newList(linksCount);
+ for (int i = 0; i < linksCount; i++) {
+ serverLinks.add(ServerLink.read(buf, version));
}
+ }
- @Override
- public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
- ProtocolUtils.writeVarInt(buf, serverLinks.size());
+ @Override
+ public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
+ ProtocolUtils.writeVarInt(buf, serverLinks.size());
- for (ServerLink serverLink : serverLinks) {
- serverLink.write(buf);
- }
+ for (ServerLink serverLink : serverLinks) {
+ serverLink.write(buf);
}
+ }
- @Override
- public boolean handle(MinecraftSessionHandler handler) {
- return handler.handle(this);
- }
+ @Override
+ public boolean handle(MinecraftSessionHandler handler) {
+ return handler.handle(this);
+ }
- public List getServerLinks() {
- return serverLinks;
- }
+ public List getServerLinks() {
+ return serverLinks;
+ }
- public record ServerLink(int id, ComponentHolder displayName, String url) {
+ /**
+ * A single server link entry.
+ *
+ * @param id the built-in link type id, or {@code -1} when a custom label is used
+ * @param displayName the label shown for the link
+ * @param url the link target
+ */
+ public record ServerLink(int id, ComponentHolder displayName, String url) {
- private static ServerLink read(ByteBuf buf, ProtocolVersion version) {
- if (buf.readBoolean()) {
- return new ServerLink(ProtocolUtils.readVarInt(buf), null, ProtocolUtils.readString(buf));
- } else {
- return new ServerLink(-1, ComponentHolder.read(buf, version), ProtocolUtils.readString(buf));
- }
- }
+ private static ServerLink read(ByteBuf buf, ProtocolVersion version) {
+ if (buf.readBoolean()) {
+ return new ServerLink(ProtocolUtils.readVarInt(buf), null, ProtocolUtils.readString(buf));
+ } else {
+ return new ServerLink(-1, ComponentHolder.read(buf, version), ProtocolUtils.readString(buf));
+ }
+ }
- private void write(ByteBuf buf) {
- if (id >= 0) {
- buf.writeBoolean(true);
- ProtocolUtils.writeVarInt(buf, id);
- } else {
- buf.writeBoolean(false);
- displayName.write(buf);
- }
- ProtocolUtils.writeString(buf, url);
- }
+ private void write(ByteBuf buf) {
+ if (id >= 0) {
+ buf.writeBoolean(true);
+ ProtocolUtils.writeVarInt(buf, id);
+ } else {
+ buf.writeBoolean(false);
+ displayName.write(buf);
+ }
+ ProtocolUtils.writeString(buf, url);
}
+ }
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/CodeOfConductAcceptPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/CodeOfConductAcceptPacket.java
index 6cd338c417..5e5ac25280 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/CodeOfConductAcceptPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/CodeOfConductAcceptPacket.java
@@ -23,6 +23,10 @@
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
import io.netty.buffer.ByteBuf;
+/**
+ * The serverbound configuration packet by which the client accepts the server's code of
+ * conduct.
+ */
public class CodeOfConductAcceptPacket implements MinecraftPacket {
public static final CodeOfConductAcceptPacket INSTANCE = new CodeOfConductAcceptPacket();
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/CodeOfConductPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/CodeOfConductPacket.java
index 41433307ef..0169757947 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/CodeOfConductPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/CodeOfConductPacket.java
@@ -24,6 +24,9 @@
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
import io.netty.buffer.ByteBuf;
+/**
+ * The clientbound configuration packet carrying the server's code of conduct text.
+ */
public class CodeOfConductPacket extends DeferredByteBufHolder implements MinecraftPacket {
public CodeOfConductPacket() {
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/FinishedUpdatePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/FinishedUpdatePacket.java
index 20d40fd4be..6bd2e9c85a 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/FinishedUpdatePacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/FinishedUpdatePacket.java
@@ -23,6 +23,10 @@
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
+/**
+ * The packet that signals completion of the configuration phase, returning the connection to
+ * the play phase.
+ */
public class FinishedUpdatePacket implements MinecraftPacket {
public static final FinishedUpdatePacket INSTANCE = new FinishedUpdatePacket();
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/KnownPacksPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/KnownPacksPacket.java
index 196e876787..e0dd4d9360 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/KnownPacksPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/KnownPacksPacket.java
@@ -25,55 +25,65 @@
import io.netty.buffer.ByteBuf;
import java.util.List;
+/**
+ * The configuration packet exchanging the set of data packs known to each side.
+ */
public class KnownPacksPacket implements MinecraftPacket {
- private static final int MAX_LENGTH_PACKS = Integer.getInteger("velocity.max-known-packs", 64);
- private static final QuietDecoderException TOO_MANY_PACKS =
+ private static final int MAX_LENGTH_PACKS = Integer.getInteger("velocity.max-known-packs", 64);
+ private static final QuietDecoderException TOO_MANY_PACKS =
new QuietDecoderException("too many known packs");
- private List packs;
-
- @Override
- public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
- ProtocolVersion protocolVersion) {
- final int packCount = ProtocolUtils.readVarInt(buf);
- if (direction == ProtocolUtils.Direction.SERVERBOUND && packCount > MAX_LENGTH_PACKS) {
- throw TOO_MANY_PACKS;
- }
+ private List packs;
- final List packs = ProtocolUtils.newList(packCount);
+ @Override
+ public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
+ ProtocolVersion protocolVersion) {
+ final int packCount = ProtocolUtils.readVarInt(buf);
+ if (direction == ProtocolUtils.Direction.SERVERBOUND && packCount > MAX_LENGTH_PACKS) {
+ throw TOO_MANY_PACKS;
+ }
- for (int i = 0; i < packCount; i++) {
- packs.add(KnownPack.read(buf));
- }
+ final List packs = ProtocolUtils.newList(packCount);
- this.packs = packs;
+ for (int i = 0; i < packCount; i++) {
+ packs.add(KnownPack.read(buf));
}
- @Override
- public void encode(ByteBuf buf, ProtocolUtils.Direction direction,
- ProtocolVersion protocolVersion) {
- ProtocolUtils.writeVarInt(buf, packs.size());
+ this.packs = packs;
+ }
- for (KnownPack pack : packs) {
- pack.write(buf);
- }
- }
+ @Override
+ public void encode(ByteBuf buf, ProtocolUtils.Direction direction,
+ ProtocolVersion protocolVersion) {
+ ProtocolUtils.writeVarInt(buf, packs.size());
- @Override
- public boolean handle(MinecraftSessionHandler handler) {
- return handler.handle(this);
+ for (KnownPack pack : packs) {
+ pack.write(buf);
}
+ }
+
+ @Override
+ public boolean handle(MinecraftSessionHandler handler) {
+ return handler.handle(this);
+ }
- public record KnownPack(String namespace, String id, String version) {
- private static KnownPack read(ByteBuf buf) {
- return new KnownPack(ProtocolUtils.readString(buf), ProtocolUtils.readString(buf), ProtocolUtils.readString(buf));
- }
+ /**
+ * A single known data pack.
+ *
+ * @param namespace the pack namespace
+ * @param id the pack id
+ * @param version the pack version
+ */
+ public record KnownPack(String namespace, String id, String version) {
+ private static KnownPack read(ByteBuf buf) {
+ return new KnownPack(ProtocolUtils.readString(buf), ProtocolUtils.readString(buf), ProtocolUtils.readString(buf));
+ }
- private void write(ByteBuf buf) {
- ProtocolUtils.writeString(buf, namespace);
- ProtocolUtils.writeString(buf, id);
- ProtocolUtils.writeString(buf, version);
- }
+ private void write(ByteBuf buf) {
+ ProtocolUtils.writeString(buf, namespace);
+ ProtocolUtils.writeString(buf, id);
+ ProtocolUtils.writeString(buf, version);
}
+ }
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/RegistrySyncPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/RegistrySyncPacket.java
index 2d9ed230e6..7027a28eb0 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/RegistrySyncPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/RegistrySyncPacket.java
@@ -25,6 +25,9 @@
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
import io.netty.buffer.ByteBuf;
+/**
+ * The clientbound configuration packet that synchronizes a game registry with the client.
+ */
public class RegistrySyncPacket extends DeferredByteBufHolder implements MinecraftPacket {
public RegistrySyncPacket() {
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/StartUpdatePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/StartUpdatePacket.java
index d41265ce56..2188c77e04 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/StartUpdatePacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/StartUpdatePacket.java
@@ -23,6 +23,9 @@
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
+/**
+ * The packet that moves a connection from the play phase back into the configuration phase.
+ */
public class StartUpdatePacket implements MinecraftPacket {
public static final StartUpdatePacket INSTANCE = new StartUpdatePacket();
@@ -41,7 +44,7 @@ public void encode(ByteBuf buf, ProtocolUtils.Direction direction,
@Override
public int decodeExpectedMaxLength(ByteBuf buf, ProtocolUtils.Direction direction,
- ProtocolVersion version) {
+ ProtocolVersion version) {
return 0;
}
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/TagsUpdatePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/TagsUpdatePacket.java
index c0cf414e0c..a6b8983936 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/TagsUpdatePacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/TagsUpdatePacket.java
@@ -24,9 +24,11 @@
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
import io.netty.buffer.ByteBuf;
-
import java.util.Map;
+/**
+ * The clientbound configuration packet that updates the client's registry tags.
+ */
public class TagsUpdatePacket implements MinecraftPacket {
private Map> tags;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/legacyping/LegacyMinecraftPingVersion.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/legacyping/LegacyMinecraftPingVersion.java
index d5ef296a41..702bf72f2a 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/legacyping/LegacyMinecraftPingVersion.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/legacyping/LegacyMinecraftPingVersion.java
@@ -17,6 +17,9 @@
package com.velocitypowered.proxy.protocol.packet.legacyping;
+/**
+ * The legacy server list ping protocol versions, distinguishing the pre-1.7 ping formats.
+ */
public enum LegacyMinecraftPingVersion {
MINECRAFT_1_3,
MINECRAFT_1_4,
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/GenericTitlePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/GenericTitlePacket.java
index 8641173e74..3f17a68eaf 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/GenericTitlePacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/GenericTitlePacket.java
@@ -23,8 +23,14 @@
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import io.netty.buffer.ByteBuf;
+/**
+ * The base class for the family of packets that control on-screen titles.
+ */
public abstract class GenericTitlePacket implements MinecraftPacket {
+ /**
+ * The kinds of title update that a title packet can represent.
+ */
public enum ActionType {
SET_TITLE(0),
SET_SUBTITLE(1),
@@ -45,7 +51,6 @@ public int getAction(ProtocolVersion version) {
}
}
-
private ActionType action;
protected void setAction(ActionType action) {
@@ -88,10 +93,9 @@ public void setFadeOut(int fadeOut) {
throw new UnsupportedOperationException("Invalid function for this TitlePacket ActionType");
}
-
@Override
public final void decode(ByteBuf buf, ProtocolUtils.Direction direction,
- ProtocolVersion version) {
+ ProtocolVersion version) {
throw new UnsupportedOperationException(); // encode only
}
@@ -103,7 +107,7 @@ public final void decode(ByteBuf buf, ProtocolUtils.Direction direction,
* @return GenericTitlePacket instance that follows the invoker type/version
*/
public static GenericTitlePacket constructTitlePacket(ActionType type, ProtocolVersion version) {
- GenericTitlePacket packet = null;
+ GenericTitlePacket packet;
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_17)) {
packet = switch (type) {
case SET_ACTION_BAR -> new TitleActionbarPacket();
@@ -111,7 +115,6 @@ public static GenericTitlePacket constructTitlePacket(ActionType type, ProtocolV
case SET_TIMES -> new TitleTimesPacket();
case SET_TITLE -> new TitleTextPacket();
case HIDE, RESET -> new TitleClearPacket();
- default -> throw new IllegalArgumentException("Invalid ActionType");
};
} else {
packet = new LegacyTitlePacket();
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/LegacyTitlePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/LegacyTitlePacket.java
index ebae8a9e5b..77bad8c78d 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/LegacyTitlePacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/LegacyTitlePacket.java
@@ -24,6 +24,9 @@
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
+/**
+ * The legacy combined title packet used before titles were split into separate packets.
+ */
public class LegacyTitlePacket extends GenericTitlePacket {
private @Nullable ComponentHolder component;
@@ -51,10 +54,10 @@ && getAction() == ActionType.SET_ACTION_BAR) {
buf.writeInt(stay);
buf.writeInt(fadeOut);
}
- case HIDE, RESET -> {}
+ case HIDE, RESET -> {
+ }
default -> throw new UnsupportedOperationException("Unknown action " + getAction());
}
-
}
@Override
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleActionbarPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleActionbarPacket.java
index f34983eaf9..f607eae7b1 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleActionbarPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleActionbarPacket.java
@@ -23,6 +23,9 @@
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import io.netty.buffer.ByteBuf;
+/**
+ * The packet that sets the player's action bar text.
+ */
public class TitleActionbarPacket extends GenericTitlePacket {
private ComponentHolder component;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleClearPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleClearPacket.java
index 1b3489691f..fa136df26d 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleClearPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleClearPacket.java
@@ -22,6 +22,9 @@
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
+/**
+ * The packet that clears the currently displayed title.
+ */
public class TitleClearPacket extends GenericTitlePacket {
public TitleClearPacket() {
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleSubtitlePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleSubtitlePacket.java
index 0f375ae20a..99273f6d6d 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleSubtitlePacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleSubtitlePacket.java
@@ -23,6 +23,9 @@
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import io.netty.buffer.ByteBuf;
+/**
+ * The packet that sets the player's subtitle text.
+ */
public class TitleSubtitlePacket extends GenericTitlePacket {
private ComponentHolder component;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTextPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTextPacket.java
index ae75f5d618..ddd60cca74 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTextPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTextPacket.java
@@ -23,6 +23,9 @@
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import io.netty.buffer.ByteBuf;
+/**
+ * The packet that sets the player's main title text.
+ */
public class TitleTextPacket extends GenericTitlePacket {
private ComponentHolder component;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTimesPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTimesPacket.java
index 8764a12fab..14e861eb93 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTimesPacket.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTimesPacket.java
@@ -22,6 +22,9 @@
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
+/**
+ * The packet that sets the fade-in, stay, and fade-out timings for titles.
+ */
public class TitleTimesPacket extends GenericTitlePacket {
private int fadeIn;
diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/IntervalledCounter.java b/proxy/src/main/java/com/velocitypowered/proxy/util/IntervalledCounter.java
index 9b986dca2f..adff853b5b 100644
--- a/proxy/src/main/java/com/velocitypowered/proxy/util/IntervalledCounter.java
+++ b/proxy/src/main/java/com/velocitypowered/proxy/util/IntervalledCounter.java
@@ -30,7 +30,6 @@
*
This class is not thread-safe. If multiple threads access an instance concurrently,
* external synchronization is required.
*/
-@SuppressWarnings("checkstyle:WhitespaceAfter") // Not our class
public final class IntervalledCounter {
private static final int INITIAL_SIZE = 8;
@@ -219,7 +218,7 @@ private void resize() {
* @return the rate in units per second for the current window
*/
public double getRate() {
- return (double)this.sum / ((double)this.interval * 1.0E-9);
+ return (double) this.sum / ((double) this.interval * 1.0E-9);
}
/**
diff --git a/proxy/src/main/resources/default-velocity.toml b/proxy/src/main/resources/default-velocity.toml
index 6aa5ceaa88..b0de64ef1f 100644
--- a/proxy/src/main/resources/default-velocity.toml
+++ b/proxy/src/main/resources/default-velocity.toml
@@ -42,7 +42,7 @@ forwarding-secret-file = "forwarding.secret"
# Announce whether or not your server supports Forge. If you run a modded server, we
# suggest turning this on.
-#
+#
# If your network runs one modpack consistently, consider using ping-passthrough = "mods"
# instead for a nicer display in the server list.
announce-forge = false