3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Only print handshake errors when debug is enabled

The exceptions only now showed up with the new print handling, but 100% of the printed cases have just been invalid packets, which we can (and should) just ignore.
Fixes #1854
Dieser Commit ist enthalten in:
KennyTV 2020-07-01 09:11:46 +02:00
Ursprung 3ba2191829
Commit b99b79f44a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 19 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -88,7 +88,7 @@ public class TagRewriter {
}
// Send new tags if present
if (newTags != null) {
if (newTags != null && !newTags.isEmpty()) {
for (TagData tag : newTags) {
wrapper.write(Type.STRING, tag.identifier);
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, tag.entries);

Datei anzeigen

@ -27,16 +27,27 @@ public class BaseProtocol extends SimpleProtocol {
registerIncoming(State.HANDSHAKE, 0x00, 0x00, new PacketRemapper() {
@Override
public void registerMap() {
// select right protocol
map(Type.VAR_INT); // 0 - Client Protocol Version
map(Type.STRING); // 1 - Server Address
map(Type.UNSIGNED_SHORT); // 2 - Server Port
map(Type.VAR_INT); // 3 - Next State
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int protVer = wrapper.get(Type.VAR_INT, 0);
int state = wrapper.get(Type.VAR_INT, 1);
try {
handleWithException(wrapper);
} catch (Exception e) {
// Only throw exceptions here when debug is enabled
// The handling has proven to be correct, but often receives invalid packets as the first packet of a connection
if (Via.getManager().isDebug()) {
throw e;
} else {
wrapper.cancel();
}
}
}
private void handleWithException(PacketWrapper wrapper) throws Exception {
int protVer = wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.STRING); // Server Address
wrapper.passthrough(Type.UNSIGNED_SHORT); // Server Port
int state = wrapper.passthrough(Type.VAR_INT);
ProtocolInfo info = wrapper.user().getProtocolInfo();
info.setProtocolVersion(protVer);