Bump com.puppycrawl.tools:checkstyle to 14.1.0 and fix warnings that were false-negatives before [ci skip]

Checkstyle fixed a bunch of false-negatives; linting errors in the source that should've been caught according to our settings. Rather than updating `checkstyle.xml` to work around these, this commit also properly fixes these checkstyle errors.
This commit is contained in:
Wouter Gritter
2026-09-13 14:01:39 +02:00
parent 15b6ddd1bf
commit bc55300123
20 changed files with 66 additions and 50 deletions
@@ -73,6 +73,7 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
/** /**
* Returns the UUID of the connecting player. * Returns the UUID of the connecting player.
*
* <p>This value is {@code null} on 1.19.2 and lower, * <p>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.</p> * up to 1.20.1 it is optional and from 1.20.2 it will always be available.</p>
* *
@@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
/** /**
* This event is executed when a player entered the configuration state and can be configured by Velocity. * This event is executed when a player entered the configuration state and can be configured by Velocity.
*
* <p>Velocity will wait for this event before continuing/ending the configuration state.</p> * <p>Velocity will wait for this event before continuing/ending the configuration state.</p>
* *
* @param player The player who can be configured. * @param player The player who can be configured.
@@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
/** /**
* This event is executed when a player is about to enter the configuration state. * This event is executed when a player is about to enter the configuration state.
* It is <b>not</b> called for the initial configuration of a player after login. * It is <b>not</b> called for the initial configuration of a player after login.
*
* <p>Velocity will wait for this event before asking the client to enter configuration state. * <p>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.</p> * Velocity will only wait for a maximum of 5 seconds.</p>
@@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
/** /**
* This event is executed when a player has entered the configuration state. * This event is executed when a player has entered the configuration state.
*
* <p>From this moment on, until the {@link PlayerFinishedConfigurationEvent} is executed, * <p>From this moment on, until the {@link PlayerFinishedConfigurationEvent} is executed,
* the {@linkplain Player#getProtocolState()} method is guaranteed * the {@linkplain Player#getProtocolState()} method is guaranteed
* to return {@link ProtocolState#CONFIGURATION}.</p> * to return {@link ProtocolState#CONFIGURATION}.</p>
@@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
/** /**
* This event is executed when a player is about to finish the configuration state. * This event is executed when a player is about to finish the configuration state.
*
* <p>Velocity will wait for this event before asking the client to finish the configuration state. * <p>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 * Velocity will only wait for a maximum of 5 seconds. If you need to hold a player in configuration
@@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
/** /**
* This event is executed when a player has finished the configuration state. * This event is executed when a player has finished the configuration state.
*
* <p>From this moment on, the {@link Player#getProtocolState()} method * <p>From this moment on, the {@link Player#getProtocolState()} method
* will return {@link ProtocolState#PLAY}.</p> * will return {@link ProtocolState#PLAY}.</p>
* *
@@ -16,6 +16,7 @@ package com.velocitypowered.api.network;
public enum ProtocolState { public enum ProtocolState {
/** /**
* Initial connection State. * Initial connection State.
*
* <p>This status can be caused by a {@link HandshakeIntent#STATUS}, * <p>This status can be caused by a {@link HandshakeIntent#STATUS},
* {@link HandshakeIntent#LOGIN} or {@link HandshakeIntent#TRANSFER} intent.</p> * {@link HandshakeIntent#LOGIN} or {@link HandshakeIntent#TRANSFER} intent.</p>
* If the intent is LOGIN or TRANSFER, the next state will be {@link #LOGIN}, * If the intent is LOGIN or TRANSFER, the next state will be {@link #LOGIN},
@@ -24,6 +25,7 @@ public enum ProtocolState {
HANDSHAKE, HANDSHAKE,
/** /**
* Ping State of a connection. * Ping State of a connection.
*
* <p>Connections with the {@link HandshakeIntent#STATUS} intent will pass through this state * <p>Connections with the {@link HandshakeIntent#STATUS} intent will pass through this state
* and be disconnected after it requests the ping from the server * and be disconnected after it requests the ping from the server
* and the server responds with the respective ping.</p> * and the server responds with the respective ping.</p>
@@ -31,11 +33,13 @@ public enum ProtocolState {
STATUS, STATUS,
/** /**
* Authentication State of a connection. * Authentication State of a connection.
*
* <p>At this moment the player is authenticating with the authentication servers.</p> * <p>At this moment the player is authenticating with the authentication servers.</p>
*/ */
LOGIN, LOGIN,
/** /**
* Configuration State of a connection. * Configuration State of a connection.
*
* <p>At this point the player allows the server to send information * <p>At this point the player allows the server to send information
* such as resource packs and plugin messages, at the same time the player * such as resource packs and plugin messages, at the same time the player
* will send his client brand and the respective plugin messages * will send his client brand and the respective plugin messages
@@ -46,6 +50,7 @@ public enum ProtocolState {
CONFIGURATION, CONFIGURATION,
/** /**
* Game State of a connection. * Game State of a connection.
*
* <p>In this state is where the whole game runs, the server is able to change * <p>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.</p> * the player's state to {@link #CONFIGURATION} as needed in versions 1.20.2 and higher.</p>
*/ */
@@ -15,7 +15,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* Represents three different states of a setting. * Represents three different states of a setting.
* *
* <p>Possible values:</p> * <p>Possible values:</p>
* <p></p>
* <ul> * <ul>
* <li>{@link #TRUE} - a positive setting</li> * <li>{@link #TRUE} - a positive setting</li>
* <li>{@link #FALSE} - a negative (negated) setting</li> * <li>{@link #FALSE} - a negative (negated) setting</li>
@@ -244,7 +244,7 @@ public interface Player extends
* Gets the {@link ResourcePackInfo} of the currently applied * Gets the {@link ResourcePackInfo} of the currently applied
* resource-pack or null if none. * resource-pack or null if none.
* *
* <p> Note that since 1.20.3 it is no longer recommended to use * <p>Note that since 1.20.3 it is no longer recommended to use
* this method as it will only return the last applied * this method as it will only return the last applied
* resource pack. To get all applied resource packs, use * resource pack. To get all applied resource packs, use
* {@link #getAppliedResourcePacks()} instead. </p> * {@link #getAppliedResourcePacks()} instead. </p>
@@ -260,7 +260,7 @@ public interface Player extends
* the user is currently downloading or is currently * the user is currently downloading or is currently
* prompted to install or null if none. * prompted to install or null if none.
* *
* <p> Note that since 1.20.3 it is no longer recommended to use * <p>Note that since 1.20.3 it is no longer recommended to use
* this method as it will only return the last pending * this method as it will only return the last pending
* resource pack. To get all pending resource packs, use * resource pack. To get all pending resource packs, use
* {@link #getPendingResourcePacks()} instead. </p> * {@link #getPendingResourcePacks()} instead. </p>
@@ -315,6 +315,7 @@ public interface Player extends
/** /**
* {@inheritDoc} * {@inheritDoc}
*
* <p><strong>Note that this method does not send a plugin message to the server the player * <p><strong>Note that this method does not send a plugin message to the server the player
* is connected to.</strong> You should only use this method if you are trying to communicate * is connected to.</strong> You should only use this method if you are trying to communicate
* with a mod that is installed on the player's client.</p> * with a mod that is installed on the player's client.</p>
@@ -56,6 +56,7 @@ public interface KeySigned {
* Validates the signature, expiry temporal and key against the * Validates the signature, expiry temporal and key against the
* signer public key. Note: This will **not** check for * signer public key. Note: This will **not** check for
* expiry. You can check for expiry with {@link KeySigned#hasExpired()}. * expiry. You can check for expiry with {@link KeySigned#hasExpired()}.
*
* <p>DOES NOT WORK YET FOR MESSAGES AND COMMANDS!</p> * <p>DOES NOT WORK YET FOR MESSAGES AND COMMANDS!</p>
* Addendum: Does not work for 1.19.1 until the user has authenticated. * Addendum: Does not work for 1.19.1 until the user has authenticated.
* *
@@ -237,8 +237,11 @@ public interface TabListEntry extends KeyIdentifiable {
/** /**
* Sets the {@link IdentifiedKey} of the {@link TabListEntry}. * Sets the {@link IdentifiedKey} of the {@link TabListEntry}.
*
* <p>This only works for players currently <b>not</b> connected to this proxy.</p> * <p>This only works for players currently <b>not</b> connected to this proxy.</p>
*
* <p>For any player currently connected to this proxy this will be filled automatically.</p> * <p>For any player currently connected to this proxy this will be filled automatically.</p>
*
* <p>Will ignore mismatching key revisions data.</p> * <p>Will ignore mismatching key revisions data.</p>
* *
* @param chatSession session to set * @param chatSession session to set
+1 -1
View File
@@ -20,7 +20,7 @@ brigadier = "com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT"
bstats = "org.bstats:bstats-base:3.2.1" bstats = "org.bstats:bstats-base:3.2.1"
caffeine = "com.github.ben-manes.caffeine:caffeine:3.2.4" caffeine = "com.github.ben-manes.caffeine:caffeine:3.2.4"
checker-qual = "org.checkerframework:checker-qual:4.2.3" checker-qual = "org.checkerframework:checker-qual:4.2.3"
checkstyle = "com.puppycrawl.tools:checkstyle:10.9.3" checkstyle = "com.puppycrawl.tools:checkstyle:14.1.0"
completablefutures = "com.spotify:completable-futures:0.3.6" completablefutures = "com.spotify:completable-futures:0.3.6"
configurate3-hocon = { module = "org.spongepowered:configurate-hocon", version.ref = "configurate3" } configurate3-hocon = { module = "org.spongepowered:configurate-hocon", version.ref = "configurate3" }
configurate3-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate3" } configurate3-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate3" }
@@ -653,7 +653,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
} }
/** /**
* 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 * @param explicitExit whether the user explicitly shut down the proxy
*/ */
@@ -37,7 +37,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
/** /**
* Modern (Minecraft 1.20.3+) ResourcePackHandler * Modern (Minecraft 1.20.3+) ResourcePackHandler.
*/ */
public final class ModernResourcePackHandler extends ResourcePackHandler { public final class ModernResourcePackHandler extends ResourcePackHandler {
private final ListMultimap<UUID, ResourcePackInfo> outstandingResourcePacks = private final ListMultimap<UUID, ResourcePackInfo> outstandingResourcePacks =
@@ -118,6 +118,7 @@ public abstract sealed class ResourcePackHandler
/** /**
* Processes a client response to a sent resource-pack. * Processes a client response to a sent resource-pack.
*
* <p>Cases in which no action will be taken:</p> * <p>Cases in which no action will be taken:</p>
* <ul> * <ul>
* *
@@ -545,6 +545,36 @@ public class VelocityEventManager implements EventManager {
} }
} }
private <E> void fire(final @Nullable CompletableFuture<E> future, final E event,
final int offset, final boolean currentlyAsync, final HandlerRegistration[] registrations) {
for (int i = offset; i < registrations.length; i++) {
final HandlerRegistration registration = registrations[i];
try {
final EventTask eventTask = registration.handler.executeAsync(event);
if (eventTask == null) {
continue;
}
final ContinuationTask<E> continuationTask = new ContinuationTask<>(eventTask,
registrations, future, event, i, currentlyAsync);
if (currentlyAsync || !eventTask.requiresAsync()) {
if (continuationTask.execute()) {
continue;
}
} else {
registration.plugin.getExecutorService().execute(continuationTask);
}
// fire will continue in another thread once the async task is
// executed and the continuation is resumed
return;
} catch (final Throwable t) {
logHandlerException(registration, t);
}
}
if (future != null) {
future.complete(event);
}
}
private static final int TASK_STATE_DEFAULT = 0; private static final int TASK_STATE_DEFAULT = 0;
private static final int TASK_STATE_EXECUTING = 1; private static final int TASK_STATE_EXECUTING = 1;
private static final int TASK_STATE_CONTINUE_IMMEDIATELY = 2; private static final int TASK_STATE_CONTINUE_IMMEDIATELY = 2;
@@ -669,36 +699,6 @@ public class VelocityEventManager implements EventManager {
} }
} }
private <E> void fire(final @Nullable CompletableFuture<E> future, final E event,
final int offset, final boolean currentlyAsync, final HandlerRegistration[] registrations) {
for (int i = offset; i < registrations.length; i++) {
final HandlerRegistration registration = registrations[i];
try {
final EventTask eventTask = registration.handler.executeAsync(event);
if (eventTask == null) {
continue;
}
final ContinuationTask<E> continuationTask = new ContinuationTask<>(eventTask,
registrations, future, event, i, currentlyAsync);
if (currentlyAsync || !eventTask.requiresAsync()) {
if (continuationTask.execute()) {
continue;
}
} else {
registration.plugin.getExecutorService().execute(continuationTask);
}
// fire will continue in another thread once the async task is
// executed and the continuation is resumed
return;
} catch (final Throwable t) {
logHandlerException(registration, t);
}
}
if (future != null) {
future.complete(event);
}
}
private static void logHandlerException( private static void logHandlerException(
final HandlerRegistration registration, final Throwable t) { final HandlerRegistration registration, final Throwable t) {
final PluginDescription pluginDescription = registration.plugin.getDescription(); final PluginDescription pluginDescription = registration.plugin.getDescription();
@@ -644,7 +644,7 @@ public enum ProtocolUtils {
private static final int FORGE_MAX_ARRAY_LENGTH = Integer.MAX_VALUE & 0x1FFF9A; private static final int FORGE_MAX_ARRAY_LENGTH = Integer.MAX_VALUE & 0x1FFF9A;
/** /**
* Reads an byte array for legacy version 1.7 from the specified {@code buf} * Reads an byte array for legacy version 1.7 from the specified {@code buf}.
* *
* @param buf the buffer to read from * @param buf the buffer to read from
* @return the read byte array * @return the read byte array
@@ -685,7 +685,7 @@ public enum ProtocolUtils {
} }
/** /**
* Writes an byte array for legacy version 1.7 to the specified {@code buf} * Writes an byte array for legacy version 1.7 to the specified {@code buf}.
* *
* @param b array * @param b array
* @param buf buf * @param buf buf
@@ -709,7 +709,7 @@ public enum ProtocolUtils {
} }
/** /**
* Writes an {@link ByteBuf} for legacy version 1.7 to the specified {@code buf} * Writes an {@link ByteBuf} for legacy version 1.7 to the specified {@code buf}.
* *
* @param b array * @param b array
* @param buf buf * @param buf buf