SteamWar/SpigotCore
Archiviert
13
0

Add SWCommand.registerCommand

Dieser Commit ist enthalten in:
jojo 2020-12-27 17:31:14 +01:00
Ursprung 2b7edeec0c
Commit 10934058cc

Datei anzeigen

@ -22,8 +22,11 @@
package de.steamwar.command;
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.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.Arrays;
@ -31,7 +34,7 @@ import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;
public class SWCommand {
public class SWCommand implements CommandExecutor, TabCompleter {
private Predicate<Player> permissionCheck = (player) -> true;
private Consumer<Player> permissionMessage = (player) -> {};
@ -65,6 +68,7 @@ public class SWCommand {
return helpExecutor.execute(sender, command, label, args);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
return false;
@ -85,6 +89,7 @@ public class SWCommand {
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
return new ArrayList<>();
@ -108,4 +113,9 @@ public class SWCommand {
return strings;
}
public void registerCommand(JavaPlugin plugin, String command) {
plugin.getCommand(command).setExecutor(this);
plugin.getCommand(command).setTabCompleter(this);
}
}