diff --git a/src/main/java/net/seanomik/energeticstorage/commands/ESReloadCommand.java b/src/main/java/net/seanomik/energeticstorage/commands/ESReloadCommand.java index 3438c4a..22c631a 100644 --- a/src/main/java/net/seanomik/energeticstorage/commands/ESReloadCommand.java +++ b/src/main/java/net/seanomik/energeticstorage/commands/ESReloadCommand.java @@ -20,6 +20,11 @@ import java.util.List; public class ESReloadCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!PermissionChecks.canReloadPlugin(sender)) { + sender.sendMessage(Reference.PREFIX + ChatColor.RED + "You don't have permission for this command!"); + return true; + } + ConfigFile.getConfig().reloadConfig(); PlayersFile.getConfig().reloadConfig(); @@ -29,7 +34,7 @@ public class ESReloadCommand implements CommandExecutor { sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Reloaded!"); } catch (Exception e) { e.printStackTrace(); - sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Failed to Reload!"); + sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Failed to Reload! (" + e.getMessage() + ")"); } return true; diff --git a/src/main/java/net/seanomik/energeticstorage/utils/PermissionChecks.java b/src/main/java/net/seanomik/energeticstorage/utils/PermissionChecks.java index 0213397..4c1099c 100644 --- a/src/main/java/net/seanomik/energeticstorage/utils/PermissionChecks.java +++ b/src/main/java/net/seanomik/energeticstorage/utils/PermissionChecks.java @@ -22,4 +22,8 @@ public class PermissionChecks { public static boolean canCreateSystem(CommandSender sender) { return sender.hasPermission("energeticstorage.system.create"); } + + public static boolean canReloadPlugin(CommandSender sender) { + return sender.hasPermission("energeticstorage.reload"); + } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 89e8bf2..e006c6e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -17,11 +17,15 @@ permissions: description: All Energetic Storage permissions. default: op children: + energeticstorage.reload: true energeticstorage.esgive: true energeticstorage.esgive.others: true energeticstorage.system.open.untrusted: true energeticstorage.system.create: true energeticstorage.system.destroy.untrusted: true + energeticstorage.reload: + description: Give permission to run `/esreload`. + default: op energeticstorage.esgive: description: Give Energetic Storage items. default: op