From c8b30b67148630ad2655646b35e81605eafc47af Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 3 Apr 2012 12:34:33 -0400 Subject: [PATCH] Added permissions nodes for repairing wood, bows, and leather. --- .../com/gmail/nossr50/config/LoadProperties.java | 3 ++- src/main/java/com/gmail/nossr50/mcPermissions.java | 12 ++++++++++++ src/main/java/com/gmail/nossr50/skills/Repair.java | 6 +++--- src/main/resources/config.yml | 1 + src/main/resources/plugin.yml | 9 +++++++++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/LoadProperties.java b/src/main/java/com/gmail/nossr50/config/LoadProperties.java index fdbff8e88..7ac9bc5d6 100644 --- a/src/main/java/com/gmail/nossr50/config/LoadProperties.java +++ b/src/main/java/com/gmail/nossr50/config/LoadProperties.java @@ -88,7 +88,7 @@ public class LoadProperties extends ConfigLoader{ public static Boolean anvilmessages; public static int rWood, rStone, rIron, rGold, rDiamond, rString, rLeather; public static int anvilID; - public static int repairStoneLevel, repairIronLevel, repairGoldLevel, repairdiamondlevel; + public static int repairStoneLevel, repairIronLevel, repairGoldLevel, repairdiamondlevel, repairBowLevel; /* Taming */ public static int mtameWolf, mtameOcelot; @@ -378,6 +378,7 @@ public class LoadProperties extends ConfigLoader{ repairIronLevel = config.getInt("Skills.Repair.Iron.Level_Required", 0); repairGoldLevel = config.getInt("Skills.Repair.Gold.Level_Required", 0); repairStoneLevel = config.getInt("Skills.Repair.Stone.Level_Required", 0); + repairBowLevel = config.getInt("Skills.Repair.String.Level_Required", 0); tamingxpmodifier = config.getDouble("Experience.Formula.Multiplier.Taming", 1.0); miningxpmodifier = config.getDouble("Experience.Formula.Multiplier.Mining", 1.0); diff --git a/src/main/java/com/gmail/nossr50/mcPermissions.java b/src/main/java/com/gmail/nossr50/mcPermissions.java index 560797752..c23a699f9 100644 --- a/src/main/java/com/gmail/nossr50/mcPermissions.java +++ b/src/main/java/com/gmail/nossr50/mcPermissions.java @@ -137,10 +137,18 @@ public class mcPermissions { return player.hasPermission("mcmmo.ability.repair.arcaneforging"); } + public boolean woodRepair(Player player) { + return player.hasPermission("mcmmo.ability.repair.woodrepair"); + } + public boolean stoneRepair(Player player) { return player.hasPermission("mcmmo.ability.repair.stonerepair"); } + public boolean leatherRepair(Player player) { + return player.hasPermission("mcmmo.ability.repair.leatherrepair"); + } + public boolean ironRepair(Player player) { return player.hasPermission("mcmmo.ability.repair.ironrepair"); } @@ -161,6 +169,10 @@ public class mcPermissions { return player.hasPermission("mcmmo.ability.repair.toolrepair"); } + public boolean bowRepair(Player player) { + return player.hasPermission("mcmmo.ability.repair.bowrepair"); + } + /* * MCMMO.ABILITY.UNARMED.* */ diff --git a/src/main/java/com/gmail/nossr50/skills/Repair.java b/src/main/java/com/gmail/nossr50/skills/Repair.java index 95b117d46..6e98b0d6f 100644 --- a/src/main/java/com/gmail/nossr50/skills/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/Repair.java @@ -59,7 +59,7 @@ public class Repair { repairItem(player, is, new ItemStack(LoadProperties.rGold)); xpHandler(player, PP, is, durabilityBefore, 4, true); } - else if (ItemChecks.isLeatherArmor(is) && inventory.contains(LoadProperties.rLeather)) { + else if (ItemChecks.isLeatherArmor(is) && inventory.contains(LoadProperties.rLeather) && mcPermissions.getInstance().leatherRepair(player)) { repairItem(player, is, new ItemStack(LoadProperties.rLeather)); xpHandler(player, PP, is, durabilityBefore, 1, true); } @@ -76,7 +76,7 @@ public class Repair { repairItem(player, is, new ItemStack(LoadProperties.rStone)); xpHandler(player, PP, is, durabilityBefore, 2, false); } - else if (ItemChecks.isWoodTool(is) && inventory.contains(LoadProperties.rWood)) { + else if (ItemChecks.isWoodTool(is) && inventory.contains(LoadProperties.rWood) && mcPermissions.getInstance().woodRepair(player)) { repairItem(player, is, new ItemStack(LoadProperties.rWood)); xpHandler(player, PP, is, durabilityBefore, 2, false); } @@ -92,7 +92,7 @@ public class Repair { repairItem(player, is, new ItemStack(LoadProperties.rGold)); xpHandler(player, PP, is, durabilityBefore, 8, true); } - else if (is.getType().equals(Material.BOW) && inventory.contains(LoadProperties.rString)){ + else if (is.getType().equals(Material.BOW) && inventory.contains(LoadProperties.rString) && skillLevel >= LoadProperties.repairBowLevel && mcPermissions.getInstance().bowRepair(player)){ repairItem(player, is, new ItemStack(LoadProperties.rString)); xpHandler(player, PP, is, durabilityBefore, 2, false); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6f2d3a9e7..3f36d9722 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -162,6 +162,7 @@ Skills: Leather: ID: 334 String: + Level_Required: 0 ID: 287 Stone: Level_Required: 0 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index e2584c6c0..898f9ee31 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -211,18 +211,25 @@ permissions: children: mcmmo.ability.repair.repairbonus: true mcmmo.ability.repair.arcaneforging: true + mcmmo.ability.repair.woodrepair: true mcmmo.ability.repair.stonerepair: true + mcmmo.ability.repair.leatherrepair: true mcmmo.ability.repair.ironrepair: true mcmmo.ability.repair.goldrepair: true mcmmo.ability.repair.diamondrepair: true mcmmo.ability.repair.armorrepair: true mcmmo.ability.repair.toolrepair: true + mcmmo.ability.repair.bowrepair: true mcmmo.ability.repair.repairbonus: description: Allows access to Super Repair bonus mcmmo.ability.repair.arcaneforging: description: Allows access to the Arcane Forging ability + mcmmo.ability.repair.woodrepair: + description: Allows ability to repair Wood tools mcmmo.ability.repair.stonerepair: description: Allows ability to repair Stone tools + mcmmo.ability.repair.leatherrepair: + description: Allows ability to repair Leather armor mcmmo.ability.repair.ironrepair: description: Allows ability to repair Iron tools & armor mcmmo.ability.repair.goldrepair: @@ -233,6 +240,8 @@ permissions: description: Allows ability to repair armor mcmmo.ability.repair.toolrepair: description: Allows ability to repair tools + mcmmo.ability.repair.bowrepair: + description: Allows ability to repair bows mcmmo.ability.unarmed.*: description: Allows access to all Unarmed abilities children: