Tab autocomplete

ArchivesFeature requests → Tab autocomplete

CLOSED

Simple: when you autocomplete with tab, it puts staff before all other players.

I’m making this post, because it was really annoying, when I tried to tp to @Futsy I typed fu, pressed tab and pressed enter and it would always tp me to @FullyStealth.

I challenge all you devs to make this! * looks at @ViperLordX *

Edit: closed, as it is impossible.

That’s simple, but Pan wouldn’t put it on even if I made it. Ask a dev.
@ViperLordX Consider “asking a dev” done.
@FullyStealth haha. Fine. Maybe. If anyone else wants to do this, sure.
Afaik this is only possible in Java, but it should be quite simple to pull off nevertheless.

Actually, there’s probably an onTabComplete kind of event right? Then nvm about the java only thing!

Edit: Looks like it!

I wrote this little python snippet which should do the job:

def on_tab_complete(event):
    word = event.getLastToken()
    lst = event.getTabCompletions() #Java collection
    for name in lst:
        player = server.getPlayer(name)
        if player != None and player.hasPermission("utils.priority-tab-complete"):
            lst.clear()
            lst.add(name)
            break

Can i just ask two questions…

  1. What is the word variable for / where is it used?
  2. Doesn’t this only list staff?

Umm… Doesn’t minecraft automatically sort the list alpabetically?! Dunno if it’s possible to change the tab completion order… And won’t this crash when you try to tab complete a vanilla command that offers you some custom options like /give Pepich1851 minecraft: does? Because you’re then trying to make a player from a string that’s not a player name at all…?

Just kinda confused about that right now :P

Greetings

~Pepich~

Or then you can do this for commands you make (AFAIK)

#IDK what alias does, but this function should return a String or a stringlist to tab-complete
def tabHandler(alias, args):
    return "foo"

# I heard this works with @hook.command() too
# Whenever you tab it calls the above func
@CommandHandler("exe", onTabComplete=tabHandler)
def on_command(sender, cmd, label, args):
    pass

But in this case @Dico200 ’s idea is smarter but needs a bit of improvement. For example, as @Pepich1851 said, if you use the command /give @p tab here, it will not allow you to tab, since “minecraft:itemname” does not have “priority permission”. Also it will not allow you to tab for other players at all.

@psrcek the “word” variable is the last word being typed before tabbing. E.G. if I type /tpa FullyS tabs here, the word will be “FullyS”, but if I type /tpa tabs here, the word will be “”. It is not being used here

@Pepich1851 @Curs3d that’s why I’m nullchecking the player before I check if they have permission. If the tab completions contain item names, then server.getplayer(name) will likely return None. If it doesn’t, however, it shouldn’t alter the list. If the player has the permission, it will force it to select that completion in the end, however. So, let’s say you tabcomplete ’d' and it returns a huge list including minecraft:diamond (I don’t know if this would return diamond or minecraft:diamond, but let’s say it returns diamond), and someone has diamond in their name, it would make it complete to diamond, and not show a huge list of item names that start with d, but I think it would return the item with minecraft: in front of it, and since players dont have : in their names, this wont be completed to any player, so it shouldn’t matter. If it does however, we should be able to simply check if the entry in the list is the exact name of the player, which shouldn’t be terribly hard either.

Sorry for the long rant, I hope you understand what i’m trying to say.

I thought that Server.getPlayer threw an exeption when called with a nonexistant name or sth. But fine, might just return null.

As for the code… That will not perform well at all. You’ll just return the last player you scanned that has the permission node you’re testing for. You should instead create a cloned list and override the original list with it instead of clearing it in every cycle of the for loop when you find a matching player.

Anyways I just checked and it is (as already mentioned but not checked) impossible to change the order of the tab completion as you send over a randomly sorted list of strings and THE CLIENT SORTS THEM ALPHABETICALLY.

TL;DR: The idea was nice but it won’t work. It’s simply not possible to do with a plugin as sorting the list of tab is all done clientside. So we would need a mod or completely kick out normal users and only hand over staff for tab completion.

Please mark as closed as it’s not going to happen…

Greeting

~Pepich~