Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by LazerShadow, Nov 17, 2015.
Is there an easy way to disable this?
Easy way? http://www.spigotmc.org/resources/bukkit-hidden-syntax-blocker.474/
Not the best way, but easy
I don't believe I went into enough detail. I want to disable being able to type /<plugin>: and pressing the tab button and sorting through the reregistered commands.
That's why I usually code command syntax to /<..> args
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:
// 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]));
A lot of people use protocollib for anti tab completion. By using the TAB_COMPLETE packet type.
Edit: sniped by @Jikoo
@Jikoo @WPM no PlayerChatTabCompleteEvent?
There is plugin for it http://dev.bukkit.org/bukkit-plugins/anti-tab/
Really? There is a reason he posted this in Spigot Plugin Development. He want to know how to code it, not download it.
As others said, you can use ProtocolLib, which, if you code it well, it won't block tabbing for usernames.
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.
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.
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
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
Have you tried using PlayerCommandPreprocessEvent?
What does that have to do with tab completions?
EDIT: For a second I thought OP was trying to disable tab completions because of the comments above me. Sorry
I actually remember that there is a way without ProtocolLib to cancel tab completers