Separate permission for vault commands. Resolves #59.

Permission is playervaults.commands.use and defaults to true to keep current functionality.
This commit is contained in:
drtshock
2015-04-27 12:10:48 -05:00
parent f97ba1e694
commit e14958f2e2
2 changed files with 18 additions and 1 deletions
@@ -31,7 +31,7 @@ public class VaultCommand implements CommandExecutor {
switch (args.length) {
case 1:
if (VaultOperations.openOwnVault(player, args[0])) {
if (VaultOperations.openOwnVault(player, args[0], true)) {
PlayerVaults.getInstance().getInVault().put(sender.getName(), new VaultViewInfo(sender.getName(), Integer.parseInt(args[0])));
} else if (sender.hasPermission("playervaults.admin")) {
OfflinePlayer searchPlayer = Bukkit.getOfflinePlayer(args[0]);
@@ -141,6 +141,23 @@ public class VaultOperations {
return false;
}
/**
* Open a player's own vault. If player is using a command, they'll need the required permission.
*
* @param player The player to open to.
* @param arg The vault number to open.
* @param isCommand - if player is opening via a command or not.
*
* @return Whether or not the player was allowed to open it.
*/
public static boolean openOwnVault(Player player, String arg, boolean isCommand) {
if (isCommand && player.hasPermission("playervaults.commands.use")) {
return openOwnVault(player, arg);
}
player.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS.toString());
return false;
}
/**
* Open another player's vault.
*