Setting Up Custom Tab-Completion

Discussion in 'Plugin Development' started by JoXeto, Dec 26, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    JoXeto

    Hi to all.
    I need help with a custom tab completion i need something like the count of this command for the user only put that args:
    [​IMG]
    Example:
    /home change [<original_name>] [<new_name>]
    Can you help me with this?

    This is my code for the onTabComplete:
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
    List<String> l = new ArrayList<String>(); if(command.getName().equalsIgnoreCase("home"))
    {
    l.clear();l.add("list");l.add("change");
    }
    return l;
    }


    Thanks a lot.

    upload_2018-12-27_15-27-34.png
     
    Last edited by a moderator: Dec 27, 2018
  2. Offline

    The_Spaceman

    getCommand("home").setTabCompleter(yourTabCompleter);

    when doing this you don't need to check from what command it is executed.
     
  3. Offline

    JoXeto

    But i need appears something like [<count>] of my second comment when i put /home change [<home_name>] [<new_name>]
    The getCommand("home").setTabCompleter(yourTabCompleter); only do new onTabComplete.
     
  4. Offline

    The_Spaceman

    now I get what you mean.. you want a argument as suggestion, but no that it is a valid value...
    check this out: https://bukkit.org/threads/tabcomplete-1-13.476192/
    I had the same problem...
     
  5. Offline

    JoXeto

    Please can you share the code to create the CommandAPI.register();
    This is create in onEnable(), onCommand() or onTabComplete()?

    This is my code:
    LinkedHashMap<String,Argument> arguments=new LinkedHashMap<>();arguments.put("arg1",new PlayerArgument());CommandAPI commandRegister=CommandAPI.getInstance();commandRegister.register("home",arguments,(sender,args) -> {
    System.out.println("works!");});


    Throws this error:
    [04:10:27 ERROR]: Error occurred while enabling Cosas_Plugin v1.0.0 (Is it up to date?)
    java.lang.NoClassDefFoundError: io/github/jorelali/commandapi/api/arguments/PlayerArgument
    at pw.pollo.hub.Hub.onEnable(Hub.java:43) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:254) ~[spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:339) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugin(CraftServer.java:434) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugins(CraftServer.java:348) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at net.minecraft.server.v1_13_R2.MinecraftServer.l(MinecraftServer.java:584) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:546) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:424) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at net.minecraft.server.v1_13_R2.DedicatedServer.init(DedicatedServer.java:294) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:702) [spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
    Caused by: java.lang.ClassNotFoundException: io.github.jorelali.commandapi.api.arguments.PlayerArgument
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_171]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:154) ~[spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:100) ~[spigot-1.13.2.jar:git-Spigot-573cdf2-dff66df]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_171]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_171]
    ... 12 more

    Thanks a lot. :)
     
  6. Offline

    unrealdesign

    Your error says there is no class found for the PlayerArgument class. Did you put the required plugins/extensions in your server plugin directory?
     
  7. Offline

    The_Spaceman

    I never used this, because I just created an Command hander for bukkit, and it was not possible to use this...
    my Command hander has a full support for sub-commands and tab completion with sub-command support. and it uses collections for the tabList and there for it was not possible :(
     
Thread Status:
Not open for further replies.

Share This Page