Disable /<plugin name>:<command>

Discussion in 'Spigot Plugin Development' started by LazerShadow, Nov 17, 2015.

  1. Is there an easy way to disable this?
     
  2. Cldfire

    Cldfire Retired Moderator
    Retired

    • Useful Useful x 1
  3. That's why I usually code command syntax to /<..> args
     
  4. If you're willing to use ProtocolLib, it's easy enough. If they've already typed the colon, that's great, you can stop the incoming tab completion packet (PacketType.Play.Client.TAB_COMPLETE) by cancelling the event.
    Filtering outgoing tab completions including a colon is slightly more work, but it's similar. Listen for outgoing tab completion packets (PacketType.Play.Server.TAB_COMPLETE) and remove any matches. You can't get the String being completed unless you store it when the client's tab completion packet comes in, so for simplicity's sake I just assume that anything starting with a forward slash is a command completion attempt.

    If you're using Java 8, this is my filter:
    Code (Java):
    // completions is the array of tab completion strings.
    String[] filtered = Arrays.stream(completions).filter(completion ->
                    completion.length() < 2 || completion.indexOf('/') != 0 || completion.indexOf(':') != -1)
            .toArray(size -> new String[size]));
     
  5. WPM

    WPM

    A lot of people use protocollib for anti tab completion. By using the TAB_COMPLETE packet type.

    Edit: sniped by @Jikoo
     
    • Like Like x 1
    • Like Like x 1
  6. WPM

    WPM

    • Agree Agree x 1
  7. My bad.
    As others said, you can use ProtocolLib, which, if you code it well, it won't block tabbing for usernames.
     
  8. That's a naive view. They can check for GitHub or decompile the jar to see how the auther went on accomplishing it, as long as the author doesn't say you can't.

    --Edit--
    Clicked on it and what did I see?
    Giant GitHub logo lol. Seems like it uses ProtocolLib just from reading the description. And they used a TAB_COMPLETE event(as others said above). Looks really easy to accomplish.
     
  9. WPM

    WPM

    A lot of plugins do not allow you to decompile code and by looking at the source code, you will probably just end up copying and pasting. THIS IS JUST MY OPION :)
     
    • Friendly Friendly x 1
  10. Yeah, the decompile police have harsh punishments *cringes*.

    Just don't turn down someone's post when the information the provided was actually useful instead of making them look stupid.

    And a lot of times in when finding out how other people do things you benefit from it because you have to read the code and find where it is, sharpening your reading skill. And if it's in a different version and doesn't work, you gotta use your brain and make it work ultimately learning. #OptimisticViews

    Sorry this is getting off topic :( CNTRL+X
     
    • Like Like x 1
  11. Have you tried using PlayerCommandPreprocessEvent?
     
  12. WPM

    WPM

    What does that have to do with tab completions? :p

    EDIT: For a second I thought OP was trying to disable tab completions because of the comments above me. Sorry :p
     
  13. I actually remember that there is a way without ProtocolLib to cancel tab completers