mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
improve some log messages, fix wrong ping calculation (instant send, wait for response packet first)
This commit is contained in:
parent
4c3abc0a30
commit
ee37e092cb
@ -29,7 +29,6 @@ import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.handshaking.PacketHandshake;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.login.PacketLoginStart;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusPing;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusRequest;
|
||||
import de.bixilon.minosoft.protocol.ping.ServerListPing;
|
||||
import de.bixilon.minosoft.protocol.protocol.*;
|
||||
@ -62,7 +61,7 @@ public class Connection {
|
||||
ConnectionStates state = ConnectionStates.DISCONNECTED;
|
||||
ConnectionReasons reason;
|
||||
ConnectionReasons nextReason;
|
||||
ConnectionPing connectionStatusPing;
|
||||
public ConnectionPing connectionStatusPing;
|
||||
ServerListPing lastPing;
|
||||
Exception lastException;
|
||||
|
||||
@ -318,10 +317,8 @@ public class Connection {
|
||||
setConnectionState(next);
|
||||
}
|
||||
case STATUS -> {
|
||||
// send status request and ping
|
||||
// send status request
|
||||
network.sendPacket(new PacketStatusRequest());
|
||||
connectionStatusPing = new ConnectionPing();
|
||||
network.sendPacket(new PacketStatusPing(connectionStatusPing));
|
||||
}
|
||||
case LOGIN -> network.sendPacket(new PacketLoginStart(player));
|
||||
case DISCONNECTED -> {
|
||||
|
@ -192,7 +192,7 @@ public class SocketNetwork implements Network {
|
||||
packet = connection.getPacketByCommand(connection.getConnectionState(), inPacketBuffer.getCommand());
|
||||
if (packet == null) {
|
||||
disconnect();
|
||||
lastException = new UnknownPacketException(String.format("Invalid packet 0x%x", inPacketBuffer.getCommand()));
|
||||
lastException = new UnknownPacketException(String.format("Server sent us a invalid packet (id=0x%x, length=%d, data=%s)", inPacketBuffer.getCommand(), length, inPacketBuffer.getBase64()));
|
||||
throw lastException;
|
||||
}
|
||||
Class<? extends ClientboundPacket> clazz = packet.getClazz();
|
||||
@ -228,7 +228,7 @@ public class SocketNetwork implements Network {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.printException(e, LogLevels.DEBUG);
|
||||
Log.protocol(String.format("An error occurred while parsing an packet (%s): %s", packet, e));
|
||||
Log.protocol(String.format("An error occurred while parsing a packet (%s): %s", packet, e));
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
|
@ -41,6 +41,7 @@ import de.bixilon.minosoft.protocol.packets.serverbound.login.PacketEncryptionRe
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketConfirmTeleport;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketKeepAliveResponse;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketPlayerPositionAndRotationSending;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusPing;
|
||||
import de.bixilon.minosoft.util.nbt.tag.CompoundTag;
|
||||
import de.bixilon.minosoft.util.nbt.tag.StringTag;
|
||||
|
||||
@ -77,6 +78,8 @@ public class PacketHandler {
|
||||
}
|
||||
Log.info(String.format("Status response received: %s/%s online. MotD: '%s'", pkg.getResponse().getPlayerOnline(), pkg.getResponse().getMaxPlayers(), pkg.getResponse().getMotd().getANSIColoredMessage()));
|
||||
connection.handlePingCallbacks(pkg.getResponse());
|
||||
connection.connectionStatusPing = new ConnectionPing();
|
||||
connection.sendPacket(new PacketStatusPing(connection.connectionStatusPing));
|
||||
}
|
||||
|
||||
public void handle(PacketStatusPong pkg) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user