Add permission check for `/esreload`

This commit is contained in:
SeanOMik 2020-07-08 12:50:33 -05:00
parent d82c3ccb35
commit aab01fc2b9
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
3 changed files with 14 additions and 1 deletions

View File

@ -20,6 +20,11 @@ import java.util.List;
public class ESReloadCommand implements CommandExecutor { public class ESReloadCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { 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(); ConfigFile.getConfig().reloadConfig();
PlayersFile.getConfig().reloadConfig(); PlayersFile.getConfig().reloadConfig();
@ -29,7 +34,7 @@ public class ESReloadCommand implements CommandExecutor {
sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Reloaded!"); sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Reloaded!");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Failed to Reload!"); sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Failed to Reload! (" + e.getMessage() + ")");
} }
return true; return true;

View File

@ -22,4 +22,8 @@ public class PermissionChecks {
public static boolean canCreateSystem(CommandSender sender) { public static boolean canCreateSystem(CommandSender sender) {
return sender.hasPermission("energeticstorage.system.create"); return sender.hasPermission("energeticstorage.system.create");
} }
public static boolean canReloadPlugin(CommandSender sender) {
return sender.hasPermission("energeticstorage.reload");
}
} }

View File

@ -17,11 +17,15 @@ permissions:
description: All Energetic Storage permissions. description: All Energetic Storage permissions.
default: op default: op
children: children:
energeticstorage.reload: true
energeticstorage.esgive: true energeticstorage.esgive: true
energeticstorage.esgive.others: true energeticstorage.esgive.others: true
energeticstorage.system.open.untrusted: true energeticstorage.system.open.untrusted: true
energeticstorage.system.create: true energeticstorage.system.create: true
energeticstorage.system.destroy.untrusted: true energeticstorage.system.destroy.untrusted: true
energeticstorage.reload:
description: Give permission to run `/esreload`.
default: op
energeticstorage.esgive: energeticstorage.esgive:
description: Give Energetic Storage items. description: Give Energetic Storage items.
default: op default: op