From 0ee06ade163973248c50d6f80091ffa4322ea41f Mon Sep 17 00:00:00 2001 From: ohAlee Date: Tue, 3 Jan 2023 18:00:56 +0100 Subject: [PATCH] Fixed reload command --- .../ohalee/minecraftgpt/command/ChatCommand.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/it/ohalee/minecraftgpt/command/ChatCommand.java b/src/main/java/it/ohalee/minecraftgpt/command/ChatCommand.java index d124bee..e57023f 100644 --- a/src/main/java/it/ohalee/minecraftgpt/command/ChatCommand.java +++ b/src/main/java/it/ohalee/minecraftgpt/command/ChatCommand.java @@ -22,16 +22,16 @@ public class ChatCommand implements TabExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (!(sender instanceof Player player)) { - sender.sendMessage(ChatColor.RED + "Only players can use this command!"); - return true; - } - - if (args.length == 1 && args[0].equalsIgnoreCase("reload")) { + if (args.length == 1 && sender.hasPermission("minecraftgpt.command.reload") && args[0].equalsIgnoreCase("reload")) { plugin.reloadConfig(); sender.sendMessage(ChatColor.GREEN + "Config reloaded!"); return true; } + + if (!(sender instanceof Player player)) { + sender.sendMessage(ChatColor.RED + "Only players can use this command!"); + return true; + } Type type = Type.SINGLE; if (args.length >= 1) { @@ -44,7 +44,7 @@ public class ChatCommand implements TabExecutor { } } - if (!player.hasPermission("minecraftgpt.command." + type)) { + if (!player.hasPermission("minecraftgpt.command." + type.name().toLowerCase())) { player.sendMessage(plugin.getConfig().getString("command.no-permission").replace("&", "ยง")); return true; }