PluginChannels has duplicated listeners
Every time I join a server, the plugin channel listeners get loaded and start to receive plugin channels. When I leave and join a server again (without shutting down the game), they get loaded again without the old ones being removed.
I made a test mod to see.
@Override
public void onJoinGame(INetHandler netHandler, SPacketJoinGame joinGamePacket, ServerData serverData, RealmsServer realmsServer) {
try {
Field f = PluginChannels.class.getDeclaredField("pluginChannels");
f.setAccessible(true);
System.out.println(f.get(LiteLoader.getClientPluginChannels()));
} catch (Exception e) {
e.printStackTrace();
}
}
That map (pluginChannels
) increases in size every time
After further investigation, the cause may be that PostLoginListener is never fired.
-
Ok, I found the cause. The
Packets.packets
array does not contain all of the packets (C00Handshake). This is causing an off-by-one error. Quick fix would be to add them, but I think it would be better to add the packets to a list as well as a map would be a better option. Instead of building the array manually, you can do it from a list.private static List<Packets> packetList = new ArrayList<>(); // ... public static Packets... public static final Packets[] packets = Packets.packetList.toArray(new Packets[0]); private Packet(...) { ... Packets.packetList.add(this); }
-
A diff of my fix: https://gist.github.com/killjoy1221/eb03414c78b049ea679d6a41ab0abe2e
-
Status changed to closed by commit 647e49fd
-
mentioned in commit 647e49fd
-
mentioned in commit f87a0b45
-
mentioned in commit 267d4cea