Added TabCompleter to base ApplianceCommand
This commit is contained in:
parent
160a17ea62
commit
463874a024
@ -75,6 +75,7 @@ public abstract class Appliance {
|
||||
PluginCommand command = plugin.getCommand(name);
|
||||
if(command != null) {
|
||||
command.setExecutor(executor);
|
||||
command.setTabCompleter(executor);
|
||||
} else {
|
||||
Bukkit.getLogger().warning("Command " + name + " is not specified in plugin.yml!");
|
||||
}
|
||||
|
@ -7,16 +7,18 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Utility class which enables command name definition over a constructor.
|
||||
*/
|
||||
public abstract class ApplianceCommand<T extends Appliance> implements ApplianceSupplier<T>, CommandExecutor {
|
||||
public abstract class ApplianceCommand<T extends Appliance> implements ApplianceSupplier<T>, TabCompleter, CommandExecutor {
|
||||
public String commandName;
|
||||
private final T appliance;
|
||||
protected Component errorMessage = Component.text("Error whilst executing command").color(NamedTextColor.RED);
|
||||
@ -43,6 +45,11 @@ public abstract class ApplianceCommand<T extends Appliance> implements Appliance
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args);
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user