diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index 9893144..32449be 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -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 permissionCheck = (player) -> true; private Consumer 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 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); + } + }