From 07c4e5d50cd76c0ac6d184de4c77368b645f93b4 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Tue, 10 May 2022 12:50:59 -0500 Subject: [PATCH] Update LuckCMD.java - Implemented PluginIdentifiableCommand - Changed the way the command is registered in the command map. --- .../java/io/github/simplex/luck/util/LuckCMD.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/simplex/luck/util/LuckCMD.java b/src/main/java/io/github/simplex/luck/util/LuckCMD.java index 8012ba3..1a9f21c 100644 --- a/src/main/java/io/github/simplex/luck/util/LuckCMD.java +++ b/src/main/java/io/github/simplex/luck/util/LuckCMD.java @@ -6,11 +6,9 @@ import io.github.simplex.luck.FeelingLucky; import io.github.simplex.luck.player.Luck; import io.github.simplex.luck.player.PlayerConfig; import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.command.TabCompleter; +import org.bukkit.command.*; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,14 +16,14 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -public class LuckCMD extends Command implements TabCompleter { +public class LuckCMD extends Command implements TabCompleter, PluginIdentifiableCommand { private final FeelingLucky plugin; public LuckCMD(FeelingLucky plugin) { super("luck", "FeelingLucky main command.", "/ [player] [amount]", List.of()); this.plugin = plugin; setPermission("luck.default"); - plugin.getServer().getCommandMap().register("luck", "FeelingLucky", this); + register(plugin.getServer().getCommandMap()); } @Override @@ -200,4 +198,9 @@ public class LuckCMD extends Command implements TabCompleter { return completions.stream().filter(n -> n.startsWith(args[0])).toList(); } + + @Override + public @NotNull FeelingLucky getPlugin() { + return plugin; + } }