Solved PlayerChatTabCompleteEvent never firing

Discussion in 'Plugin Development' started by nathanthesnooper, Mar 13, 2018.

Thread Status:
Not open for further replies.
  1. Code:
    @EventHandler
    public void playerChatTabCompleteEvent (PlayerChatTabCompleteEvent event) {
    
        System.out.println("x");
    
    }
    And yes, the events are registered, and other events in the same class are working

    No errors on startup/runtime/compiling

    Edit:

    Solution was ProtocolLib:

    Code:
    ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter (this, PacketType.Play.Client.TAB_COMPLETE) {
    
        @Override
        public void onPacketReceiving (PacketEvent event) {
        
            List<String> completions = new ArrayList<String>();
        
            completions.add("/msg"); //Do whatever
        
            event.setCancelled(true);
        
            PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.TAB_COMPLETE);
        
            Collections.sort(completions);
            packet.getStringArrays().write(0, completions.toArray(new String[0]));
        
            try {
                ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet);
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        
        }
    
    });
     
    Last edited: Mar 13, 2018
  2. Offline

    Zombie_Striker

    @nathanthesnooper
    Are you testing this by checing if they are using the command tab, or are you testing using regular chat tab?
     
  3. @Zombie_Striker I see what you mean now, is there a command tab event?
     
  4. Offline

    Zombie_Striker

    @nathanthesnooper
    Sort of; not an event.

    onTab is a method that is used to listen for tabs for commands that your plugin creates.
     
  5. @Zombie_Striker
    I found a solution by using protocollib, I edited my answer. Thanks though!
     
Thread Status:
Not open for further replies.

Share This Page