Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +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:
Ursprung
3ba2191829
Commit
b99b79f44a
@ -88,7 +88,7 @@ public class TagRewriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send new tags if present
|
// Send new tags if present
|
||||||
if (newTags != null) {
|
if (newTags != null && !newTags.isEmpty()) {
|
||||||
for (TagData tag : newTags) {
|
for (TagData tag : newTags) {
|
||||||
wrapper.write(Type.STRING, tag.identifier);
|
wrapper.write(Type.STRING, tag.identifier);
|
||||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, tag.entries);
|
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, tag.entries);
|
||||||
|
@ -27,16 +27,27 @@ public class BaseProtocol extends SimpleProtocol {
|
|||||||
registerIncoming(State.HANDSHAKE, 0x00, 0x00, new PacketRemapper() {
|
registerIncoming(State.HANDSHAKE, 0x00, 0x00, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
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() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int protVer = wrapper.get(Type.VAR_INT, 0);
|
try {
|
||||||
int state = wrapper.get(Type.VAR_INT, 1);
|
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();
|
ProtocolInfo info = wrapper.user().getProtocolInfo();
|
||||||
info.setProtocolVersion(protVer);
|
info.setProtocolVersion(protVer);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren