SteamWar/BungeeCore
Archiviert
13
2

Better Forge failure debugging
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-02-05 17:57:55 +01:00
Ursprung ffa5dc8bc2
Commit f97f135efc

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.listeners.mods;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.bungeecore.sql.Mod;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.event.LoginEvent;
import net.md_5.bungee.api.event.ProxyPingEvent;
@ -103,15 +104,24 @@ public class Forge extends BasicListener {
//for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29
Utils.VarInt channelLength = Utils.readVarInt(data, 0);
int pos = channelLength.length;
assert new String(data, pos, channelLength.value).equals("fml:handshake");
if(!new String(data, pos, channelLength.value).equals("fml:handshake")) {
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x00)"));
return;
}
Utils.VarInt length = Utils.readVarInt(data, pos);
pos += length.length;
assert channelLength.length + channelLength.value + length.length + length.value == data.length;
if(channelLength.length + channelLength.value + length.length + length.value != data.length) {
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x01)"));
return;
}
Utils.VarInt packetId = Utils.readVarInt(data, pos);
pos += packetId.length;
assert packetId.value == 2;
if(packetId.value != 2) {
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x02)"));
return;
}
Utils.VarInt modCount = Utils.readVarInt(data, pos);
pos += modCount.length;