From 45fe8c182b1d648322671301fa2aea1eaa28029f Mon Sep 17 00:00:00 2001 From: NuclearW Date: Thu, 17 May 2012 09:29:27 -0400 Subject: [PATCH] Put new permissions to good use --- .../nossr50/skills/repair/RepairItemType.java | 25 ++++++++++++- .../skills/repair/RepairMaterialType.java | 35 ++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java index dd0f2227b..caf292c9e 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java @@ -1,7 +1,30 @@ package com.gmail.nossr50.skills.repair; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.util.Permissions; + public enum RepairItemType { ARMOR, TOOL, - OTHER + OTHER; + + /** + * Get the base permissions associated with this RepairItemType. + * + * @param player The player to check the permissions for + * @return true if the player has permissions, false otherwise + */ + public boolean getPermissions(Player player) { + switch (this) { + case ARMOR: + return Permissions.getInstance().armorRepair(player); + case TOOL: + return Permissions.getInstance().toolRepair(player); + case OTHER: + return Permissions.getInstance().otherRepair(player); + default: + return false; + } + } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java index 60b99f60f..010ad6ca3 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java @@ -1,5 +1,9 @@ package com.gmail.nossr50.skills.repair; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.util.Permissions; + public enum RepairMaterialType { STRING, LEATHER, @@ -8,5 +12,34 @@ public enum RepairMaterialType { IRON, GOLD, DIAMOND, - OTHER + OTHER; + + /** + * Get the base permissions associated with this RepairMaterialType. + * + * @param player The player to check the permissions for + * @return true if the player has permissions, false otherwise + */ + public boolean getPermissions(Player player) { + switch (this) { + case STRING: + return Permissions.getInstance().stringRepair(player); + case LEATHER: + return Permissions.getInstance().leatherRepair(player); + case WOOD: + return Permissions.getInstance().woodRepair(player); + case STONE: + return Permissions.getInstance().stoneRepair(player); + case IRON: + return Permissions.getInstance().ironRepair(player); + case GOLD: + return Permissions.getInstance().goldRepair(player); + case DIAMOND: + return Permissions.getInstance().diamondRepair(player); + case OTHER: + return Permissions.getInstance().otherMaterialRepair(player); + default: + return false; + } + } }