Unable to receive begin encryption packets
ShadowOfHeaven-Me opened this issue ยท 7 comments
- This issue is not solved in a development build
Describe the bug
The packet listener is not firing the packet event to with encryption begin packets as it's only to listen packets. However when I tried Client Position packets it worked just fine.
To Reproduce
Steps to reproduce the behavior:
I use this code:
PacketType[] toListenTo = new PacketType[]{PacketType.Login.Client.ENCRYPTION_BEGIN, PacketType.Login.Server.ENCRYPTION_BEGIN};
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Main.instance, toListenTo) {
@Override
public void onPacketReceiving(PacketEvent event) {//from client (In)
Bukkit.broadcastMessage("encrypitoooon");
}
@Override
public void onPacketSending(PacketEvent event) {//from server (Out)
Bukkit.broadcastMessage("czteryyy");
}
});
Expected behavior
At least one of the messages should be send.
Version Info
https://pastebin.com/r3gYApzg
or
https://paste.md-5.net/xidogepuho.pl
It seems like your listener is registered for the PLAYING
phase although the event is sent during LOGIN
.
Please try the following:
AdapterParameters params = PacketAdapter.params(Main.instance, PacketType.Login.Client.ENCRYPTION_BEGIN).gamePhase(GamePhase.BOTH).listenerPriority(ListenerPriority.NORMAL);
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(params) {
// Code body goes here
});
PacketAdapter.AdapterParameteters params = PacketAdapter.params(Main.instance, PacketType.Login.Client.ENCRYPTION_BEGIN).gamePhase(GamePhase.BOTH).listenerPriority(ListenerPriority.NORMAL);
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(params) {
@Override
public void onPacketReceiving(PacketEvent event) {//from client (In)
Bukkit.broadcastMessage("encrypitoooon");
}
@Override
public void onPacketSending(PacketEvent event) {//from server (Out)
Bukkit.broadcastMessage("czteryyy");
}
});
/\ This is the code I'm using. It still doesn't work
Well, the listener still seems to be registered for gamephase=PLAYING
. To be honest, I have no clue why this is the case. I will try to debug this in the next few days.
This is the protocol dump: https://paste.md-5.net/wigisitavo.pl
But doesn't the dump file have gamePhase as "Both"? The issue then probably isn't the var setting, but maybe the way "Both" is handled?