Async packet in 1.19
Fireflyest opened this issue ยท 2 comments
Make sure you're doing the following
- You're using the latest build for your server version
- This isn't an issue caused by another plugin
- You've checked for duplicate issues
- You didn't use
/reload
Describe the question
version5.0.0 in 1.19.2 unable to send asynchronous package.
API method(s) used
protocolManager.sendServerPacket(player, packet);
event.isAsync();
Expected behavior
I send a packet in another thread, but when I use event.isAsync();
method in event listener. It return false.
Code
...
new BukkitRunnable(){
@Override
public void run() {
Player player = Bukkit.getPlayerExact(playerName);
if (player == null) return;
try {
protocolManager.sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}.runTaskAsynchronously(CraftGUI.getPlugin());
...
Additional context
ProtocolLib 5.0.0-SNAPSHOT-b588 server version 1.19.2 This problem not appear in 1.18.2
Thats correct. ProtocolLib internally uses the send methods provided by the minecraft server. This will queue the packet and process them on the main thread. That's not our fault, and we cannot change that as some packets need some extra logic (for example post packet sending) which is only available when we use these methods.