Add InboundConnection#getHandshakeIntent (#1493)
* Add InboundConnection#getHandshakeIntent
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.proxy;
|
package com.velocitypowered.api.proxy;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.network.HandshakeIntent;
|
||||||
import com.velocitypowered.api.network.ProtocolState;
|
import com.velocitypowered.api.network.ProtocolState;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
@@ -60,4 +61,11 @@ public interface InboundConnection {
|
|||||||
* @return the protocol state of the connection
|
* @return the protocol state of the connection
|
||||||
*/
|
*/
|
||||||
ProtocolState getProtocolState();
|
ProtocolState getProtocolState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the initial intent for the connection.
|
||||||
|
*
|
||||||
|
* @return the intent of the connection
|
||||||
|
*/
|
||||||
|
HandshakeIntent getHandshakeIntent();
|
||||||
}
|
}
|
||||||
|
@@ -97,7 +97,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
|
|||||||
// Initiate a regular connection and move over to it.
|
// Initiate a regular connection and move over to it.
|
||||||
ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(),
|
ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(),
|
||||||
mcConnection, inbound.getVirtualHost().orElse(null), inbound.getRawVirtualHost().orElse(null), onlineMode,
|
mcConnection, inbound.getVirtualHost().orElse(null), inbound.getRawVirtualHost().orElse(null), onlineMode,
|
||||||
inbound.getIdentifiedKey());
|
inbound.getHandshakeIntent(), inbound.getIdentifiedKey());
|
||||||
this.connectedPlayer = player;
|
this.connectedPlayer = player;
|
||||||
if (!server.canRegisterConnection(player)) {
|
if (!server.canRegisterConnection(player)) {
|
||||||
player.disconnect0(
|
player.disconnect0(
|
||||||
|
@@ -38,6 +38,7 @@ import com.velocitypowered.api.event.player.PlayerModInfoEvent;
|
|||||||
import com.velocitypowered.api.event.player.PlayerSettingsChangedEvent;
|
import com.velocitypowered.api.event.player.PlayerSettingsChangedEvent;
|
||||||
import com.velocitypowered.api.event.player.ServerPreConnectEvent;
|
import com.velocitypowered.api.event.player.ServerPreConnectEvent;
|
||||||
import com.velocitypowered.api.event.player.configuration.PlayerEnterConfigurationEvent;
|
import com.velocitypowered.api.event.player.configuration.PlayerEnterConfigurationEvent;
|
||||||
|
import com.velocitypowered.api.network.HandshakeIntent;
|
||||||
import com.velocitypowered.api.network.ProtocolState;
|
import com.velocitypowered.api.network.ProtocolState;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.permission.PermissionFunction;
|
import com.velocitypowered.api.permission.PermissionFunction;
|
||||||
@@ -156,6 +157,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
private final MinecraftConnection connection;
|
private final MinecraftConnection connection;
|
||||||
private final @Nullable InetSocketAddress virtualHost;
|
private final @Nullable InetSocketAddress virtualHost;
|
||||||
private final @Nullable String rawVirtualHost;
|
private final @Nullable String rawVirtualHost;
|
||||||
|
private final HandshakeIntent handshakeIntent;
|
||||||
private GameProfile profile;
|
private GameProfile profile;
|
||||||
private PermissionFunction permissionFunction;
|
private PermissionFunction permissionFunction;
|
||||||
private int tryIndex = 0;
|
private int tryIndex = 0;
|
||||||
@@ -193,12 +195,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
|
|
||||||
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
||||||
@Nullable InetSocketAddress virtualHost, @Nullable String rawVirtualHost, boolean onlineMode,
|
@Nullable InetSocketAddress virtualHost, @Nullable String rawVirtualHost, boolean onlineMode,
|
||||||
@Nullable IdentifiedKey playerKey) {
|
HandshakeIntent handshakeIntent, @Nullable IdentifiedKey playerKey) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.virtualHost = virtualHost;
|
this.virtualHost = virtualHost;
|
||||||
this.rawVirtualHost = rawVirtualHost;
|
this.rawVirtualHost = rawVirtualHost;
|
||||||
|
this.handshakeIntent = handshakeIntent;
|
||||||
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
|
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
|
||||||
this.connectionPhase = connection.getType().getInitialClientPhase();
|
this.connectionPhase = connection.getType().getInitialClientPhase();
|
||||||
this.onlineMode = onlineMode;
|
this.onlineMode = onlineMode;
|
||||||
@@ -1335,6 +1338,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
return connection.getState().toProtocolState();
|
return connection.getState().toProtocolState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandshakeIntent getHandshakeIntent() {
|
||||||
|
return handshakeIntent;
|
||||||
|
}
|
||||||
|
|
||||||
private final class ConnectionRequestBuilderImpl implements ConnectionRequestBuilder {
|
private final class ConnectionRequestBuilderImpl implements ConnectionRequestBuilder {
|
||||||
|
|
||||||
private final RegisteredServer toConnect;
|
private final RegisteredServer toConnect;
|
||||||
|
@@ -277,5 +277,10 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
public ProtocolState getProtocolState() {
|
public ProtocolState getProtocolState() {
|
||||||
return connection.getState().toProtocolState();
|
return connection.getState().toProtocolState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandshakeIntent getHandshakeIntent() {
|
||||||
|
return HandshakeIntent.STATUS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.proxy.connection.client;
|
package com.velocitypowered.proxy.connection.client;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.network.HandshakeIntent;
|
||||||
import com.velocitypowered.api.network.ProtocolState;
|
import com.velocitypowered.api.network.ProtocolState;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.proxy.InboundConnection;
|
import com.velocitypowered.api.proxy.InboundConnection;
|
||||||
@@ -98,6 +99,11 @@ public final class InitialInboundConnection implements VelocityInboundConnection
|
|||||||
return connection.getState().toProtocolState();
|
return connection.getState().toProtocolState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandshakeIntent getHandshakeIntent() {
|
||||||
|
return handshake.getIntent();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects the connection from the server.
|
* Disconnects the connection from the server.
|
||||||
*
|
*
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.proxy.connection.client;
|
package com.velocitypowered.proxy.connection.client;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.network.HandshakeIntent;
|
||||||
import com.velocitypowered.api.network.ProtocolState;
|
import com.velocitypowered.api.network.ProtocolState;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.proxy.LoginPhaseConnection;
|
import com.velocitypowered.api.proxy.LoginPhaseConnection;
|
||||||
@@ -177,4 +178,9 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
|
|||||||
public ProtocolState getProtocolState() {
|
public ProtocolState getProtocolState() {
|
||||||
return delegate.getProtocolState();
|
return delegate.getProtocolState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandshakeIntent getHandshakeIntent() {
|
||||||
|
return delegate.getHandshakeIntent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user