Add permission check for `/esreload`
This commit is contained in:
parent
d82c3ccb35
commit
aab01fc2b9
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue