Merge commands with their tab completers

This commit is contained in:
Daniil Z committed 2021-03-01 00:07:57 +03:00
1 parent 8b4c0bb6e4
commit cc065c8dde
37 files changed
+470 -512

No files matched your search

@@ -0,0 +1,33 @@
package me.william278.huskhomes2.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
public abstract class CommandBase implements CommandExecutor {
/**
* Register base for bukkit command
* @param command Command for registration
*/
public PluginCommand register(PluginCommand command) {
Objects.requireNonNull(command);
command.setExecutor(this);
if (this instanceof TabCompleter) {
command.setTabCompleter((TabCompleter) this);
}
return command;
}
public static class EmptyTab implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
return Collections.emptyList();
}
}
}