.
This commit is contained in:
parent
682cff9a8b
commit
a2d1153ae8
17 changed files with 439 additions and 326 deletions
|
|
@ -18,12 +18,19 @@ public class TabCompleteListener implements Listener {
|
|||
@EventHandler(ignoreCancelled = true)
|
||||
public void onAsyncTabComplete(AsyncTabCompleteEvent ev) {
|
||||
if (!ev.isCommand()) return;
|
||||
|
||||
var args = ev.getBuffer().substring(1).split(" ");
|
||||
if (args.length == 0) return;
|
||||
|
||||
var label = args[0];
|
||||
{
|
||||
// commands can be called with a '<plugin name>:' prefix. strip it.
|
||||
int l = label.indexOf(':');
|
||||
if (l >= 0)
|
||||
label = label.substring(l+1);
|
||||
}
|
||||
var rootNode = commandAPI.getRegistered(label);
|
||||
if (rootNode == null) return;
|
||||
ev.setHandled(true);
|
||||
ev.setCompletions(commandHandler.getSuggestions(rootNode, ev.getSender(), Arrays.copyOfRange(args, 1, args.length)));
|
||||
ev.setCompletions(commandHandler.getSuggestions(rootNode, ev.getSender(), Arrays.copyOfRange(args, 1, args.length), ev.getBuffer().endsWith(" ")));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue