Fixed reload command

This commit is contained in:
ohAlee 2023-01-03 18:00:56 +01:00
parent 432c7ef72c
commit 0ee06ade16

View File

@ -22,16 +22,16 @@ public class ChatCommand implements TabExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player player)) { if (args.length == 1 && sender.hasPermission("minecraftgpt.command.reload") && args[0].equalsIgnoreCase("reload")) {
sender.sendMessage(ChatColor.RED + "Only players can use this command!");
return true;
}
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
plugin.reloadConfig(); plugin.reloadConfig();
sender.sendMessage(ChatColor.GREEN + "Config reloaded!"); sender.sendMessage(ChatColor.GREEN + "Config reloaded!");
return true; return true;
} }
if (!(sender instanceof Player player)) {
sender.sendMessage(ChatColor.RED + "Only players can use this command!");
return true;
}
Type type = Type.SINGLE; Type type = Type.SINGLE;
if (args.length >= 1) { 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("&", "§")); player.sendMessage(plugin.getConfig().getString("command.no-permission").replace("&", "§"));
return true; return true;
} }