Returning max version if using ip forwarding

This commit is contained in:
Nanit 2022-01-26 18:47:31 +02:00
parent 088570b28e
commit 018d7b1e6f
3 changed files with 11 additions and 2 deletions

View File

@ -91,6 +91,10 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
return address;
}
public Version getClientVersion() {
return clientVersion;
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
if (state.equals(State.PLAY)) {

View File

@ -19,9 +19,13 @@ public class PacketStatusResponse implements PacketOut {
@Override
public void encode(ByteMessage msg, Version version) {
int protocol = server.getConfig().getInfoForwarding().isNone()
? version.getProtocolNumber()
: Version.getMax().getProtocolNumber();
String ver = server.getConfig().getPingData().getVersion();
String desc = server.getConfig().getPingData().getDescription();
String json = getResponseJson(ver, version.getProtocolNumber(),
String json = getResponseJson(ver, protocol,
server.getConfig().getMaxPlayers(), server.getConnections().getCount(), desc);
msg.writeString(json);

View File

@ -27,7 +27,8 @@ public final class Connections {
public void addConnection(ClientConnection connection) {
connections.put(connection.getUuid(), connection);
Logger.info("Player %s connected (%s)", connection.getUsername(), connection.getAddress());
Logger.info("Player %s connected (%s) [%s]", connection.getUsername(),
connection.getAddress(), connection.getClientVersion());
}
public void removeConnection(ClientConnection connection) {