diff --git a/api/build.gradle.kts b/api/build.gradle.kts
index 56bb3c49c..aa6778fca 100644
--- a/api/build.gradle.kts
+++ b/api/build.gradle.kts
@@ -73,7 +73,8 @@ tasks {
o.tags(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
- "implNote:a:Implementation Note:"
+ "implNote:a:Implementation Note:",
+ "sinceMinecraft:a:Since Minecraft:"
)
// Disable the crazy super-strict doclint tool in Java 8
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 6ac3f57e1..952cb091b 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
@@ -72,9 +72,12 @@ public final class PreLoginEvent implements ResultedEvent
This status can be caused by a STATUS, LOGIN or TRANSFER intent.
+ * If the intent is LOGIN or TRANSFER, the next state will be {@link #LOGIN}, + * otherwise, it will go to the {@link #STATUS} state. + */ + HANDSHAKE, + /** + * Ping State of a connection. + *Connections with the STATUS HandshakeIntent will pass through this state + * and be disconnected after it requests the ping from the server + * and the server responds with the respective ping.
+ */ + 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 + * if it is a modded client.
+ * + * @sinceMinecraft 1.20.2 + */ + 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.
+ */ + PLAY +} diff --git a/api/src/main/java/com/velocitypowered/api/proxy/InboundConnection.java b/api/src/main/java/com/velocitypowered/api/proxy/InboundConnection.java index e92c38bc7..224abbd6e 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/InboundConnection.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/InboundConnection.java @@ -7,6 +7,7 @@ package com.velocitypowered.api.proxy; +import com.velocitypowered.api.network.ProtocolState; import com.velocitypowered.api.network.ProtocolVersion; import java.net.InetSocketAddress; import java.util.Optional; @@ -43,4 +44,11 @@ public interface InboundConnection { * @return the protocol version the connection uses */ ProtocolVersion getProtocolVersion(); + + /** + * Returns the current protocol state of this connection. + * + * @return the protocol state of the connection + */ + ProtocolState getProtocolState(); } 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 eb41401b2..a73ff451b 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/Player.java @@ -190,7 +190,7 @@ public interface Player extends * * @param reason component with the reason */ - void disconnect(net.kyori.adventure.text.Component reason); + void disconnect(Component reason); /** * Sends chat input onto the players current server as if they typed it into the client chat box. diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java b/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java index 4745eea17..320b1c203 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java @@ -64,6 +64,7 @@ public interface PlayerSettings { * This feature was introduced in 1.18. * * @return whether or not the client explicitly allows listing. Always false on older clients. + * @sinceMinecraft 1.18 */ boolean isClientListingAllowed(); 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 79ad81636..935a3c481 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 @@ -33,6 +33,7 @@ import com.velocitypowered.api.event.player.KickedFromServerEvent.ServerKickResu import com.velocitypowered.api.event.player.PlayerModInfoEvent; import com.velocitypowered.api.event.player.PlayerSettingsChangedEvent; import com.velocitypowered.api.event.player.ServerPreConnectEvent; +import com.velocitypowered.api.network.ProtocolState; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.permission.PermissionFunction; import com.velocitypowered.api.permission.PermissionProvider; @@ -1170,6 +1171,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player, } } + @Override + public ProtocolState getProtocolState() { + return connection.getState().toProtocolState(); + } + private final class ConnectionRequestBuilderImpl implements ConnectionRequestBuilder { private final RegisteredServer toConnect; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java index f1fc2d49f..5c5e928fe 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java @@ -20,6 +20,7 @@ package com.velocitypowered.proxy.connection.client; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.velocitypowered.api.event.connection.ConnectionHandshakeEvent; +import com.velocitypowered.api.network.ProtocolState; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.config.PlayerInfoForwarding; @@ -247,9 +248,9 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler { @Override public String toString() { - boolean isPlayerAddressLoggingEnabled = connection.server.getConfiguration() + final boolean isPlayerAddressLoggingEnabled = connection.server.getConfiguration() .isPlayerAddressLoggingEnabled(); - String playerIp = + final String playerIp = isPlayerAddressLoggingEnabled ? this.getRemoteAddress().toString() : "