Remove /[tab] without protocolib

Discussion in 'Spigot Plugin Development' started by iNoXs, Jun 11, 2016.

  1. Hi im searching a way to remove / (command) [tab]

    I found this event
    Code (Text):
          @EventHandler
          public void onPlayerClickTab(PlayerChatTabCompleteEvent e)
          {
              if(e.getChatMessage().equals("/ver")){
            e.getTabCompletions().clear();
    but dont work

    Thanks
     
    • Optimistic Optimistic x 1
  2. ChatTabCompleteEvent is for when you tab complete in chat not command. I believe there is another event for tab completing commands.
     
  3. Or can u help me with protocolib ?
     
  4. To remove /[tab], go to spigot.yml -> tab-complete, change it to -1
     
  5. I know but i want remove tab with specfic commands
     
    • Creative Creative x 1
  6. With protocollib you can easy change it with PacketType.Play.Server.TAB_COMPLETE.
    If you want to do it without protocollib, you need to use PacketPlayOutTabComplete.
     
    • Like Like x 1
  7. Yes but when i use protocoib i have an error
     
  8. Then post the error?
     
  9. Use the new API method TabCompleteEvent.
     
  10. Doesn't look like there is a method to get the command being tab-completed from it.
     
  11. The entire event was created for commands... Its based off of my own PR.
     
    • Like Like x 1
  12. Try #getBuffer, it might return everything (/something arg1 arg2) but you can easily parse it.
     
  13. You can catch the packet and cancel it
     
  14. I'm not home right now but I can post the code when I get home
     
  15. First line goes in your main class.

    Code (Text):
    ProtocolLibrary.getProtocolManager().addPacketListener(new TabCompletePacketListener());
    TabCompletePacketListener.java contents.
    Code (Text):

    @Override
    public void onPacketReceiving(PacketEvent e) {
        String command = event.getPacket().getStrings().read(0).trim();
        e.setCancelled(true);
    }
    EDIT: This is of course with ProtocolLib.
     
  16. Since my last post seems to have been overlooked....

    Code (Text):

    @EventHandler
    public void onTabComplete(TabCompleteEvent event) {
        String buffer = event.getBuffer();
        if (buffer.startsWith("/") && buffer.split(" ").length <= 1) {
            event.setCancelled(true);
        }
    }
     
    Now no one can tab complete by pressing / tab to see a listing of all commands, but can still tab complete actual command arguments.

    No packets at all. Welcome to 2016. ^_^
     
    • Winner Winner x 4
  17. TabCompleteEvent 1.9 api ?
     
  18. It was introduced late in the 1.9 cycle, yes.
     
  19. I wonder why it took them so long. :/

    Much love Spigot Team. <3
     
  20. :( *walks away unrecognized for his contributions, yet again*
     
    • Funny Funny x 1