mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-13 15:20:10 +01:00
Remove extra setters and congregate into refreshServerInformation
This commit is contained in:
parent
fce63a91d5
commit
61242dc185
@ -746,7 +746,7 @@ public final class MinecraftServer {
|
||||
* @param responseDataConsumer the response data consumer, can be null
|
||||
* @throws IllegalStateException if called before {@link #init()} or if the server is already running
|
||||
*
|
||||
* @deprecated use {@link #start(String, int)} and listen to the {@link net.minestom.server.event.server.StatusRequestEvent} event instead of ResponseDataConsumer
|
||||
* @deprecated use {@link #start(String, int)} and listen to the {@link net.minestom.server.event.server.ServerListPingEvent} event instead of ResponseDataConsumer
|
||||
*/
|
||||
@Deprecated
|
||||
public void start(@NotNull String address, int port, @Nullable ResponseDataConsumer responseDataConsumer) {
|
||||
|
@ -66,6 +66,7 @@ public class HandshakePacket implements ClientPreplayPacket {
|
||||
final SocketAddress socketAddress = new java.net.InetSocketAddress(split[1],
|
||||
((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort());
|
||||
nettyPlayerConnection.setRemoteAddress(socketAddress);
|
||||
|
||||
UUID playerUuid = UUID.fromString(
|
||||
split[2]
|
||||
.replaceFirst(
|
||||
@ -90,18 +91,19 @@ public class HandshakePacket implements ClientPreplayPacket {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (connection instanceof NettyPlayerConnection) {
|
||||
// Give to the connection the server info that the client used
|
||||
((NettyPlayerConnection) connection).refreshServerInformation(serverAddress, serverPort, protocolVersion);
|
||||
}
|
||||
|
||||
switch (nextState) {
|
||||
case 1:
|
||||
connection.setConnectionState(ConnectionState.STATUS);
|
||||
break;
|
||||
case 2:
|
||||
if (connection instanceof NettyPlayerConnection) {
|
||||
((NettyPlayerConnection) connection).setProtocolVersion(protocolVersion);
|
||||
((NettyPlayerConnection) connection).refreshServerInformation(serverAddress, serverPort);
|
||||
}
|
||||
if (protocolVersion == MinecraftServer.PROTOCOL_VERSION) {
|
||||
connection.setConnectionState(ConnectionState.LOGIN);
|
||||
|
||||
} else {
|
||||
// Incorrect client version
|
||||
connection.sendPacket(new LoginDisconnectPacket(INVALID_VERSION_TEXT));
|
||||
|
@ -42,5 +42,5 @@ public class FakePlayerConnection extends PlayerConnection {
|
||||
Check.argCondition(!(player instanceof FakePlayer), "FakePlayerController needs a FakePlayer object");
|
||||
super.setPlayer(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -240,23 +240,6 @@ public class NettyPlayerConnection extends PlayerConnection {
|
||||
this.remoteAddress = remoteAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the protocol version of a client.
|
||||
*
|
||||
* @return protocol version of client.
|
||||
*/
|
||||
public int getProtocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the protocol version of a connecting client.
|
||||
* @param protocolVersion the protocol version of the client
|
||||
*/
|
||||
public void setProtocolVersion(int protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
@ -313,6 +296,30 @@ public class NettyPlayerConnection extends PlayerConnection {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the protocol version of a client.
|
||||
*
|
||||
* @return protocol version of client.
|
||||
*/
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used in {@link net.minestom.server.network.packet.client.handshake.HandshakePacket} to change the internal fields.
|
||||
*
|
||||
* @param serverAddress the server address which the client used
|
||||
* @param serverPort the server port which the client used
|
||||
* @param protocolVersion the protocol version which the client used
|
||||
*/
|
||||
public void refreshServerInformation(@Nullable String serverAddress, int serverPort, int protocolVersion) {
|
||||
this.serverAddress = serverAddress;
|
||||
this.serverPort = serverPort;
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public UUID getBungeeUuid() {
|
||||
@ -332,17 +339,6 @@ public class NettyPlayerConnection extends PlayerConnection {
|
||||
this.bungeeSkin = bungeeSkin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used in {@link net.minestom.server.network.packet.client.handshake.HandshakePacket} to change the internal fields.
|
||||
*
|
||||
* @param serverAddress the server address which the client used
|
||||
* @param serverPort the server port which the client used
|
||||
*/
|
||||
public void refreshServerInformation(@Nullable String serverAddress, int serverPort) {
|
||||
this.serverAddress = serverAddress;
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
/**
|
||||
* Adds an entry to the plugin request map.
|
||||
* <p>
|
||||
|
Loading…
Reference in New Issue
Block a user