This commit is contained in:
Roman Zhuravlev 2023-08-11 19:35:58 +05:00
parent 4599fd9e5a
commit 4c74e8fb12

View file

@ -0,0 +1,28 @@
package org.zhdev.varioutil.bukkit.command;
import org.bukkit.command.*;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public final class PreparedPluginCommand extends AbstractPluginCommand {
private final CommandExecutor executor;
private final TabCompleter completer;
public PreparedPluginCommand(@NotNull String name, Plugin plugin, CommandExecutor executor, TabCompleter completer) {
super(name, plugin);
this.executor = executor;
this.completer = completer;
}
@Override
protected boolean onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
return executor.onCommand(sender, this, label, args);
}
@Override
protected List<String> onTabComplete(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
return completer == null ? null : completer.onTabComplete(sender, this, label, args);
}
}