Skip to content

Commit

Permalink
Command Switch for Tab Complete (#2425)
Browse files Browse the repository at this point in the history
* Add command switch to TabCompleteScriptEvent

* Meta docs

* Attempting different way

* Better way working

* Change to runGenericSwitchCheck
  • Loading branch information
daniel committed Jan 9, 2023
1 parent 9026b29 commit ada4300
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -21,6 +21,8 @@ public class TabCompleteScriptEvent extends BukkitScriptEvent implements Listene
//
// @Group Server
//
// @Switch command:<command_name> to only process the event if the command matches the input name.
//
// @Cancellable true
//
// @Triggers when a player or the console is sent a list of available tab completions.
Expand All @@ -41,10 +43,19 @@ public class TabCompleteScriptEvent extends BukkitScriptEvent implements Listene

public TabCompleteScriptEvent() {
registerCouldMatcher("tab complete");
registerSwitches("command");
}

public TabCompleteEvent event;

@Override
public boolean matches(ScriptPath path) {
if (!runGenericSwitchCheck(path, "command", getCommand())) {
return false;
}
return super.matches(path);
}

public String getCommand() {
String[] args = event.getBuffer().trim().split(" ");
String cmd = args.length > 0 ? args[0] : "";
Expand Down

0 comments on commit ada4300

Please sign in to comment.