Unhandled exception occured in onPacketSending(PacketEvent)
BiliBiliBaiyeCN opened this issue ยท 2 comments
I was developing one Minecraft plugin "CommandBlackList", for either my server and my friend's server. Aand I use protocolLib to send "TAB_COMPLETE" outgoing packet.
Here are the codes in the Main class of this plugin:
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, PacketType.Play.Server.TAB_COMPLETE) {
@Override
public void onPacketReceiving(PacketEvent e) {
boolean mode = this.getPlugin().getConfig().getBoolean("disable-tab-completion");
if (mode) {
List<String> NewCompletions = new ArrayList<>();
String TabMode = this.getPlugin().getConfig().getString("tab-completion-mode");
if (!e.getPlayer().hasPermission("scbl.operator") || e.getPlayer().isOp()) {
if (TabMode == "clear") {
NewCompletions.add(" ");
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cTab completion cleared by &bCommand&3BlackList&c!"));
} else if (TabMode == "custom") {
List<String> Paras = this.getPlugin().getConfig().getStringList("Advanced-Tab-Completion");
for (String a : Paras) {
NewCompletions.add(0, a);
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cAdded &6" + a + "&cinto Tab completion by &bCommand&3BlackList&c!"));
}
}
} else {
e.setCancelled(false);
}
PacketContainer packetContainer1 = new PacketContainer(PacketType.Play.Server.TAB_COMPLETE, NewCompletions);
// Send ServerPacket via manager
try {
getLogger().info("Trying to send a outgoing TAB_COMPLETE packet to " + e.getPlayer().getName());
manager.sendServerPacket(e.getPlayer(), packetContainer1);
getLogger().info("Sent outgoing TAB_COMPLETE packet to " + e.getPlayer().getName());
} catch (InvocationTargetException ex) {
getLogger().warning("Could not send a outgoing TAB_COMPLETE packet to" + e.getPlayer().getName());
throw new RuntimeException(ex);
}
} else {
getLogger().warning("One of Boat Team's CommandBlackList's recommended feature isn't enabled !");
}
}
});
When I pressed Tab key in game, there is no completion get changed, about 2 secs later, my console feedbacked me one error.
Here are the details:
[16:22:55] [Server thread/ERROR]: [CommandBlackList] Unhandled exception occured in onPacketSending(PacketEvent) for CommandBlackList
java.lang.IllegalStateException: Override onPacketSending to get notifcations of sent packets!
at com.comphenix.protocol.events.PacketAdapter.onPacketSending(PacketAdapter.java:170) ~[?:?]
at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) ~[?:?]
at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) ~[?:?]
at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:535) ~[?:?]
at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:516) ~[?:?]
at com.comphenix.protocol.injector.netty.ProtocolInjector.packetQueued(ProtocolInjector.java:346) ~[?:?]
at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketSending(ProtocolInjector.java:308) ~[?:?]
at com.comphenix.protocol.injector.netty.ChannelInjector.processSending(ChannelInjector.java:436) ~[?:?]
at com.comphenix.protocol.injector.netty.ChannelInjector.access$800(ChannelInjector.java:72) ~[?:?]
at com.comphenix.protocol.injector.netty.ChannelInjector$3.handleScheduled(ChannelInjector.java:376) ~[?:?]
at com.comphenix.protocol.injector.netty.ChannelInjector$3.onMessageScheduled(ChannelInjector.java:346) ~[?:?]
at com.comphenix.protocol.injector.netty.ChannelProxy$2.schedulingRunnable(ChannelProxy.java:127) ~[?:?]
at com.comphenix.protocol.injector.netty.EventLoopProxy.execute(EventLoopProxy.java:95) ~[?:?]
at net.minecraft.server.v1_16_R3.NetworkManager.b(NetworkManager.java:194) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.NetworkManager.sendPacket(NetworkManager.java:164) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.NetworkManager.sendPacket(NetworkManager.java:158) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnection.lambda$9(PlayerConnection.java:722) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at java.util.concurrent.CompletableFuture.uniAccept(Unknown Source) ~[?:1.8.0_351]
at java.util.concurrent.CompletableFuture.uniAcceptStage(Unknown Source) ~[?:1.8.0_351]
at java.util.concurrent.CompletableFuture.thenAccept(Unknown Source) ~[?:1.8.0_351]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:720) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PacketPlayInTabComplete.a(SourceFile:35) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PacketPlayInTabComplete.a(SourceFile:9) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:28) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(SourceFile:144) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(SourceFile:118) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1061) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1054) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeAll(SourceFile:103) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1037) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:970) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_351]
[16:22:56] [Server thread/ERROR]: Parameters:
net.minecraft.server.v1_16_R3.PacketPlayOutTabComplete@1c5f314a[
a=0
b=Suggestions{range=StringRange{start=10, end=10}, suggestions=[Suggestion{range=StringRange{start=10, end=10}, text='BiliBiliBaiye_CN', tooltip='null'}]}
]
I also tried "/procotol listeners", and it reports:
PacketAdapter[plugin=CommandBlackList, sending=ListeningWhitelist[priority=HIGHEST, packets=[TAB_COMPLETE[class=PacketPlayOutTabComplete, id=17]], gamephase=PLAYING, options=[]], receiving=EMPTY_WHITELIST
If there is any ways to solve it, please tell me ! Thanks !
Do i need to move
boolean mode = this.getPlugin().getConfig().getBoolean("disable-tab-completion");
List<String> NewCompletions = new ArrayList<>();
String TabMode = this.getPlugin().getConfig().getString("tab-completion-mode");
out of the
@Override
public void onPacketReceiving(PacketEvent e) {...}
?