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 {
|
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;
|
||||||
|
|
|
@ -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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue