3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00

Add onCommand and onTabComplete to the interface

Dieser Commit ist enthalten in:
Matsv 2016-09-24 20:12:12 +02:00
Ursprung b146257b1a
Commit 598863d43a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 97CEC2A2EA31350F
3 geänderte Dateien mit 23 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,7 @@
package us.myles.ViaVersion.api.command; package us.myles.ViaVersion.api.command;
import java.util.List;
public interface ViaVersionCommand { public interface ViaVersionCommand {
/** /**
* Register your own subcommand inside ViaVersion * Register your own subcommand inside ViaVersion
@ -24,4 +26,22 @@ public interface ViaVersionCommand {
* @return ViaSubCommand instance * @return ViaSubCommand instance
*/ */
ViaSubCommand getSubCommand(String name); ViaSubCommand getSubCommand(String name);
/**
* Executed when the Command sender executes the command
*
* @param sender Sender object
* @param args arguments provided
* @return was successful
*/
boolean onCommand(ViaCommandSender sender, String[] args);
/**
* Executed when the Command sender tab-completes
*
* @param sender Sender object
* @param args arguments provided
* @return was successful
*/
List<String> onTabComplete(ViaCommandSender sender, String[] args);
} }

Datei anzeigen

@ -41,6 +41,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
return commandMap.get(name.toLowerCase()); return commandMap.get(name.toLowerCase());
} }
@Override
public boolean onCommand(ViaCommandSender sender, String[] args) { public boolean onCommand(ViaCommandSender sender, String[] args) {
if (args.length == 0) { if (args.length == 0) {
showHelp(sender); showHelp(sender);
@ -66,6 +67,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
return result; return result;
} }
@Override
public List<String> onTabComplete(ViaCommandSender sender, String[] args) { public List<String> onTabComplete(ViaCommandSender sender, String[] args) {
Set<ViaSubCommand> allowed = calculateAllowedCommands(sender); Set<ViaSubCommand> allowed = calculateAllowedCommands(sender);
List<String> output = new ArrayList<>(); List<String> output = new ArrayList<>();

Datei anzeigen

@ -17,7 +17,7 @@
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<resources> <resources>
<resource> <resource>
<targetPath>.</targetPath>https://github.com/MylesIsCool/ViaVersion/blob/master/ISSUE_TEMPLATE.md <targetPath>.</targetPath>
<filtering>false</filtering> <filtering>false</filtering>
<directory>.</directory> <directory>.</directory>
<includes> <includes>