Custom Tab Complete List

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

  1. How do I change what It says when I type /[tab]. It shows a list of random commands. How would I make it so It will show the options that I want it to show? Ex. When a player does it I want to show "/help, /tell". (I'm looking for a code solution or an open-source plugin that accomplishes this task)

    I already used something like this... (Doesn't let me change what appears. However, it lets me cancel the event)
    Code (Text):
          this.protocolManager = ProtocolLibrary.getProtocolManager();
            this.protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, new PacketType[] { PacketType.Play.Client.TAB_COMPLETE })
            {
              public void onPacketReceiving(PacketEvent event)
              {
                if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
                  try
                  {
    ...
    Can anyone help?
     
  2. The way tab complete works is, that the client sends a packat with the neccessary information, example what the user is currently typing in the chat, and then the server figures out what the user wants to tab complete ("/help" and "/tell" in your example) and sends a list of all tab complete options back to the player via a new and different packet.
    It looks like you want to influence every tab complete and not just add tab complete for your own commands so your solution with ProtocolLib is good but because there are these two different packets, you need to cancel the received packet, create the tab complete suggestions and then send them back in the tab complete packet for the client to receive.

    To achieve this, you could use the practical PacketWrapper classes for ProtocolLib, the WrapperPlayServerTabComplete class being right here.
    Create a new instance of the wrapper class, set the tab complete suggestions with "setMatches" and then send the packet container obtained from the wrapper to the player.
     
  3. There is an Event for it (PlayerChatTabCompleteEvent). I think you can use that.
     
    • Agree Agree x 1