Solved Allow player name tab to preprocess commands.

Discussion in 'Spigot Plugin Development' started by Mr.Midnight, Jun 21, 2016.

  1. I made a Command manager based off of the event PlayerPreProccessCommand which doesn't seem to support tab. How can I go about fixing this?
     
  2. Pretty sure you can use PlayerChatTabCompleteEvent to add tab completion, did you try adding it with that event? Spigot does not automatically add tab support except for real commands, pretty sure you can add arguments to the tab completion using the event which would allow them to be used in tab completion.
     
    • Winner Winner x 1
    • Optimistic Optimistic x 1
  3. Oo sounds like I have some work for tomorrow, thanks for the tip :3
     
  4. MiniDigger

    Supporter

    why...... :confused:
     
    • Agree Agree x 2
  5. PlayerChatTabCompleteEvent does NOT work with commands or text beginning with a /! (Tested in 1.10 and 1.8)

    Override>
    If overriding commands you need to somehow disable the default auto complete for that command either by:
    #1: Somehow unregister the default command
    #2: If unregistering it is impossible then we can create a packet wrapper and only let that 'encased' packet through.

    Normal>
    If your just normally adding new commands instead of overriding go ahead and intercept the PacketPlayInTabComplete packet.
    That packet will be sent anytime a player presses tab so I suggest checking if the cursor string begins with a slash.
     
  6. We recently added a TabCompleteEvent that handles both chat and command tab completes.
     
  7. /ver says I'm 2 version behind maybe I'm wrong. . .

    Maybe I shouldn't try to help when im very tired. . . XD
    I seem to be wrong 99.9999% of the time. :confused:

    Thanks for the correction.
     
  8. No, you're right about PlayerChatTabCompleteEvent. It only handles chat tab completes (anything not starting with /). Theres a new event, though, simply named TabCompleteEvent which handles both chat and commands. ^_^
     
  9. I also have a 99.9999% chance to not understand things, but how?

    Does the event ONLY execute when a command is auto completed?
     
  10. MiniDigger

    Supporter

    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerChatTabCompleteEvent.html
    public class PlayerChatTabCompleteEvent
    extends PlayerEvent
    Called when a player attempts to tab-complete a chat message.

    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/server/TabCompleteEvent.html
    public class TabCompleteEvent
    extends Event
    implements Cancellable
    Called when a CommandSender of any description (ie: player or console) attempts to tab complete.
     
  11. Sorry either too tired or he edited the reply a little too late after I replied. I did not know of this and can now use it for plugins that shouldn't require a packet intercepting system.

    Thank you
     
  12. MiniDigger

    Supporter

    the event is fairly new, it was implemented on may 16. https://hub.spigotmc.org/stash/proj...mits/e217da5747089094acffd0b65b03eb095f465930
    and yeah, billy always edits his posts 5 times ;)
     
  13. Sadly, no. My PR added a PlayerCommandTabCompleteEvent that would tab complete only commands for only players (later named to CommandTabCompleteEvent). But @md_5 didn't like it and wanted it to work with console, too. So, I made a new PR that added CommandTabCompleteEvent that would tab complete only commands but for CommandSender (player, console, command block). Apparently he didn't like it either and decided to decline my PR and make his own.

    So now we're stuck with 2 events that fire for chat tab completes and only 1 of them for commands. Kinda weird, if you ask me. But meh. At least its in there now, I guess. :p
    Because its so new, @Lightspeed360 you need to consider your audience. It wont work for early 1.9 or any 1.8 servers or below. Only the latest 1.9.4 builds and 1.10. So, if you aim to support 1.8 you're still going to have to listen to that packet. ;)
    Happens when the mind is faster than the hands. ^_^
     
    • Like Like x 1
  14. Ah ok, you guys are probably gonna hate my guts. But how woulls I go about listening for a packet without ProtocolLib.
     
  15. I'ma just use a fork of protocol libs, thank you all :3
     
  16. MiniDigger

    Supporter

    there is no easy way. you could use protocollibs tinyprotocol tho, if that is updated to 1.10
     
  17. MiniDigger

    Supporter

    why a fork?
     
  18. Because gotta stay custom (cool emoji goes here)
     
    • Funny Funny x 1
  19. I usually do complicated stuff that's why it bothers me when I can't do a task and has to rely on a api.
     
  20. MiniDigger

    Supporter

    well then go the hard way: you need to inject a custom ChannelDuplexHandler into the players connection pipe (for every player, on join)
    then you can catch the packets and inject your own packets.
     
    • Agree Agree x 1
    • Informative Informative x 1
    • Optimistic Optimistic x 1