Solved ProtocolLib Sending TAB_COMPLETE Packet

Discussion in 'Spigot Plugin Development' started by thoe, Jun 27, 2021.

  1. I'm trying to send a player a PacketType.Play.Server.TAB_COMPLETE packet whenever a player tries to tab complete a command (and cancel the one spigot sends). My code is attached, and I honestly don't have a clue what I should be putting in the PacketContainer. I found this: https://wiki.vg/Protocol#Tab-Complete_.28clientbound.29, but I honestly don't know where to start. Any help would be much appreciated!

    Code (Text):
    public void onPacketReceiving(PacketEvent event) {
            PacketType packetType = event.getPacketType();
            if (packetType.equals(PacketType.Play.Client.TAB_COMPLETE)) {
                tabCompletions = new ArrayList<>();
                tabCompletions.add("test");
                tabCompletions.add("test2");

                ArrayList<String> arrayList = new ArrayList<>(tabCompletions);
                PacketContainer packetContainer1 = new PacketContainer(PacketType.Play.Server.TAB_COMPLETE, arrayList);
                try {
                    ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packetContainer1);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    The error right now:
    Code (Text):
    05:00:59 WARN]: [ Server IO #1] [ProtocolLib] [ChannelInjector] Unable to send packet [test, test2] to clownzio
    java.lang.IllegalArgumentException: argument type mismatch
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
            at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
            at com.comphenix.protocol.injector.netty.ChannelInjector.invokeSendPacket(ChannelInjector.java:746) ~[?:?]
            at com.comphenix.protocol.injector.netty.ChannelInjector.sendServerPacket(ChannelInjector.java:731) ~[?:?]
            at com.comphenix.protocol.injector.netty.ProtocolInjector$4.sendServerPacket(ProtocolInjector.java:399) ~[?:?]
            at com.comphenix.protocol.injector.PacketFilterManager.sendServerPacket(PacketFilterManager.java:733) ~[?:?]
            at com.comphenix.protocol.injector.PacketFilterManager.sendServerPacket(PacketFilterManager.java:687) ~[?:?]
            at ac.echo.core.tabcomplete.PlayClientTabComplete.onPacketReceiving(PlayClientTabComplete.java:100) ~[?:?]
            at com.comphenix.protocol.injector.SortedPacketListenerList.invokeReceivingListener(SortedPacketListenerList.java:114) ~[?:?]
            at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketRecieving(SortedPacketListenerList.java:67) ~[?:?]
            at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:537) ~[?:?]
            at com.comphenix.protocol.injector.PacketFilterManager.invokePacketRecieving(PacketFilterManager.java:509) ~[?:?]
            at com.comphenix.protocol.injector.netty.ProtocolInjector.packetReceived(ProtocolInjector.java:348) ~[?:?]
            at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketReceiving(ProtocolInjector.java:313) ~[?:?]
            at com.comphenix.protocol.injector.netty.ChannelInjector.decode(ChannelInjector.java:594) ~[?:?]
            at io.netty.handler.codec.ByteToMessageDecoder.callDecode(SourceFile:249) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.handler.codec.ByteToMessageDecoder.channelRead(SourceFile:149) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(SourceFile:333) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(SourceFile:319) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at com.comphenix.protocol.injector.netty.ChannelInjector$2.channelRead(ChannelInjector.java:290) ~[?:?]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(SourceFile:333) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(SourceFile:319) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.handler.codec.ByteToMessageDecoder.channelRead(SourceFile:163) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(SourceFile:333) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(SourceFile:319) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at protocolsupport.protocol.core.timeout.SimpleReadTimeoutHandler.channelRead(SimpleReadTimeoutHandler.java:40) ~[?:?]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(SourceFile:333) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(SourceFile:319) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.DefaultChannelPipeline.fireChannelRead(SourceFile:787) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.epollInReady(SourceFile:722) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.epoll.EpollEventLoop.processReady(SourceFile:326) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.channel.epoll.EpollEventLoop.run(SourceFile:264) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SourceFile:116) ~[ispigot.jar:git-iSpigot-PaperEdition]
            at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]
     
  2. Why do you want to use ProtocolLib to do tab complater?
     
  3. 1.8 doesn't have any spigot or bukkit method for it
     
  4. Of course it has
    • org.bukkit.event.player.PlayerChatTabCompleteEvent
     
  5. That's for chat, doesn't work with command tab completion... unless I was just doing something wrong when I was testing
     
  6. Oh. Well, that sucks. How about using a custom TabCompleter instead?
     
  7. Tried that aswell, thats for tab completing arguments for a CommandExecutor, doesn't really work for what I'm trying to do.
    I have figured out a solution though, it's using BungeeCord's TabCompleteEvent with a Bungeecord Plugin
     
    • Like Like x 1