Solved Get the argument the player is trying to tab-complete?

Discussion in 'Plugin Development' started by Cirno, Feb 20, 2014.

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

    Cirno

    I'm currently working with TabCompleter, and I (obviously) implemented the onTabComplete() method. However, the command I am using is multi-argument; and, obviously, I can't keep track of which argument the player is trying to tab-complete. Any workaround/solution to this?
     
  2. Offline

    DSH105 Retired Staff

    Assuming, I correctly understood what you said, you could use something along the lines of this:
    Code:java
    1.  
    2. String[] completions = new String[]{"command", "command1"};
    3. for (String s : completions) {
    4. if (s.toString().toLowerCase().startsWith(args[args.length - 1])) {
    5. // Do something creative with it (add it to the returned list)
    6. }
    7. }
    8.  

    That will auto-complete the last argument of the command with any of the provided completions. Hopefully that's what you were after :).
     
  3. Offline

    ferrybig

  4. Offline

    Cirno

    Thanks :)

    Possible I might use this in the future... Thanks, anyways :p
     
Thread Status:
Not open for further replies.

Share This Page