From dfe2d0a58546da53ba3b7c9e5f2f307482549bbf Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Fri, 27 Jan 2012 10:51:08 -0500 Subject: [PATCH 1/3] Made Arcane Forging more configurable - options for keeping enchants & downgrading enchants --- .../gmail/nossr50/config/LoadProperties.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/LoadProperties.java b/src/main/java/com/gmail/nossr50/config/LoadProperties.java index 77fbf995f..dd161c9e5 100644 --- a/src/main/java/com/gmail/nossr50/config/LoadProperties.java +++ b/src/main/java/com/gmail/nossr50/config/LoadProperties.java @@ -28,7 +28,7 @@ public class LoadProperties whoisEnable, statsEnable, addxpEnable, ptpEnable, mmoeditEnable, clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable, mcrefreshEnable, enableMotd, enableMySpawn, enableRegen, enableCobbleToMossy, useMySQL, cocoabeans, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, excavationRequiresShovel, woodcuttingrequiresaxe, eggs, apples, cake, music, diamond, glowstone, - slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages; + slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages, downgradesEnabled, keepEnchantsEnabled; public static String xplock, MySQLtablePrefix, MySQLuserName, MySQLserverName, MySQLdbName, MySQLdbPass, mctop, addxp, xprate, mcability, mcmmo, mcc, mcrefresh, mcgod, stats, mmoedit, ptp, party, myspawn, whois, invite, accept, clearmyspawn, nWood, @@ -40,7 +40,8 @@ public class LoadProperties msugar, mpumpkin, mwheat, mgold, mdiamond, miron, mredstone, mlapis, mobsidian, mnetherrack, mglowstone, mcoal, mstone, MySQLport, xpGainMultiplier, superBreakerCooldown, greenTerraCooldown, gigaDrillBreakerCooldown, treeFellerCooldown, berserkCooldown, serratedStrikeCooldown, skullSplitterCooldown, abilityDurabilityLoss, - feathersConsumedByChimaeraWing, bonesConsumedByCOTW, repairdiamondlevel, rWood, rStone, rIron, rGold, rDiamond, rString, rLeather; + feathersConsumedByChimaeraWing, bonesConsumedByCOTW, repairdiamondlevel, rWood, rStone, rIron, rGold, rDiamond, rString, rLeather, + downgradeRank1, downgradeRank2, downgradeRank3, downgradeRank4, keepEnchantsRank1, keepEnchantsRank2, keepEnchantsRank3, keepEnchantsRank4; public static double xpbackground_r, xpbackground_g, xpbackground_b, xpborder_r, xpborder_g, xpborder_b, fishing_r, fishing_g, fishing_b, acrobatics_r, acrobatics_g, acrobatics_b, archery_r, archery_g, archery_b, axes_r, axes_g, axes_b, excavation_r, excavation_g, excavation_b, herbalism_r, herbalism_g, herbalism_b, mining_r, mining_g, mining_b, @@ -221,7 +222,7 @@ public class LoadProperties write("Experience.Mining.Diamond", 750); write("Experience.Mining.Iron", 250); write("Experience.Mining.Redstone", 150); - write("Experience.Mining.lapis", 400); + write("Experience.Mining.Lapis", 400); write("Experience.Mining.Obsidian", 150); write("Experience.Mining.Netherrack", 30); write("Experience.Mining.Glowstone", 30); @@ -352,6 +353,16 @@ public class LoadProperties write("Skills.Woodcutting.Requires_Axe", true); write("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); + write("Arcane_Forging.Downgrades.Enabled", true); + write("Arcane_Forging.Downgrades.Chance.Rank_1", 75); + write("Arcane_Forging.Downgrades.Chance.Rank_2", 50); + write("Arcane_Forging.Downgrades.Chance.Rank_3", 25); + write("Arcane_Forging.Downgrades.Chance.Rank_4", 15); + write("Arcane_Forging.Keep_Enchants.Enabled", true); + write("Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); + write("Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); + write("Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); + write("Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); loadkeys(); } private void loadkeys() @@ -550,6 +561,17 @@ public class LoadProperties rLeather = readInteger("Skills.Repair.Leather.ID", 334); nLeather = readString("Skills.Repair.String.Name", "Leather"); + downgradesEnabled = readBoolean("Arcane_Forging.Downgrades.Enabled", true); + downgradeRank1 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_1", 75); + downgradeRank2 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_2", 50); + downgradeRank3 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_3", 25); + downgradeRank4 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_4", 15); + keepEnchantsEnabled = readBoolean("Arcane_Forging.Keep_Enchants.Enabled", true); + keepEnchantsRank1 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); + keepEnchantsRank2 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); + keepEnchantsRank3 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); + keepEnchantsRank4 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); + cocoabeans = readBoolean("Excavation.Drops.Cocoa_Beans", true); mushrooms = readBoolean("Excavation.Drops.Mushrooms", true); glowstone = readBoolean("Excavation.Drops.Glowstone", true); From 486fb5635d658aa5b9ab0a3ec326b58782972037 Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Fri, 27 Jan 2012 11:55:06 -0500 Subject: [PATCH 2/3] Better variable names for Arcane Forging config --- .../java/com/gmail/nossr50/config/LoadProperties.java | 8 ++++---- 1 file changed, 4 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 dd161c9e5..2fd6b1a43 100644 --- a/src/main/java/com/gmail/nossr50/config/LoadProperties.java +++ b/src/main/java/com/gmail/nossr50/config/LoadProperties.java @@ -28,7 +28,7 @@ public class LoadProperties whoisEnable, statsEnable, addxpEnable, ptpEnable, mmoeditEnable, clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable, mcrefreshEnable, enableMotd, enableMySpawn, enableRegen, enableCobbleToMossy, useMySQL, cocoabeans, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, excavationRequiresShovel, woodcuttingrequiresaxe, eggs, apples, cake, music, diamond, glowstone, - slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages, downgradesEnabled, keepEnchantsEnabled; + slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages, mayDowngradeEnchants, mayLoseEnchants; public static String xplock, MySQLtablePrefix, MySQLuserName, MySQLserverName, MySQLdbName, MySQLdbPass, mctop, addxp, xprate, mcability, mcmmo, mcc, mcrefresh, mcgod, stats, mmoedit, ptp, party, myspawn, whois, invite, accept, clearmyspawn, nWood, @@ -358,7 +358,7 @@ public class LoadProperties write("Arcane_Forging.Downgrades.Chance.Rank_2", 50); write("Arcane_Forging.Downgrades.Chance.Rank_3", 25); write("Arcane_Forging.Downgrades.Chance.Rank_4", 15); - write("Arcane_Forging.Keep_Enchants.Enabled", true); + write("Arcane_Forging.May_Lose_Enchants.Enabled", true); write("Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); write("Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); write("Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); @@ -561,12 +561,12 @@ public class LoadProperties rLeather = readInteger("Skills.Repair.Leather.ID", 334); nLeather = readString("Skills.Repair.String.Name", "Leather"); - downgradesEnabled = readBoolean("Arcane_Forging.Downgrades.Enabled", true); + mayDowngradeEnchants = readBoolean("Arcane_Forging.Downgrades.Enabled", true); downgradeRank1 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_1", 75); downgradeRank2 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_2", 50); downgradeRank3 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_3", 25); downgradeRank4 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_4", 15); - keepEnchantsEnabled = readBoolean("Arcane_Forging.Keep_Enchants.Enabled", true); + mayLoseEnchants = readBoolean("Arcane_Forging.May_Lose_Enchants.Enabled", true); keepEnchantsRank1 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); keepEnchantsRank2 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); keepEnchantsRank3 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); From 7d19fe68d9d43296187433d868f14a68fbb25cdc Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Fri, 27 Jan 2012 12:26:35 -0500 Subject: [PATCH 3/3] Made Arcane Forging fully configurable. --- .../java/com/gmail/nossr50/skills/Repair.java | 67 +++++++++++-------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/Repair.java b/src/main/java/com/gmail/nossr50/skills/Repair.java index 5e5cb4e62..19fc55137 100644 --- a/src/main/java/com/gmail/nossr50/skills/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/Repair.java @@ -315,44 +315,53 @@ public class Repair { if(rank == 0) { - player.sendMessage(mcLocale.getString("Repair.LostEnchants")); - for(Enchantment x : enchants) + if(LoadProperties.mayLoseEnchants()) { - is.removeEnchantment(x); + player.sendMessage(mcLocale.getString("Repair.LostEnchants")); + for(Enchantment x : enchants) + { + is.removeEnchantment(x); + } } return; } boolean failure = false, downgrade = false; - for(Enchantment x : enchants) + if(LoadProperties.mayLoseEnchants()) { - //Remove enchant - is.removeEnchantment(x); - - if(x.canEnchantItem(is)) + for(Enchantment x : enchants) { - if(Math.random() * 100 <= getEnchantChance(rank)) + //Remove enchant + is.removeEnchantment(x); + + if(x.canEnchantItem(is)) { - if(enchantsLvl[pos] > 1) + if(Math.random() * 100 <= getEnchantChance(rank)) { - if(Math.random() * 100 <= getDowngradeChance(rank)) - { - is.addEnchantment(x, enchantsLvl[pos]-1); - downgrade = true; - } else + if(enchantsLvl[pos] > 1) { + if(LoadProperties.mayDowngradeEnchants()) + { + if(Math.random() * 100 <= getDowngradeChance(rank)) + { + is.addEnchantment(x, enchantsLvl[pos]-1); + downgrade = true; + } else + { + is.addEnchantment(x, enchantsLvl[pos]); + } + } + } + else { is.addEnchantment(x, enchantsLvl[pos]); } + } else { + failure = true; } - else { - is.addEnchantment(x, enchantsLvl[pos]); - } - } else { - failure = true; } + pos++; } - pos++; } if(failure == false && downgrade == false) @@ -369,13 +378,13 @@ public class Repair { switch(rank) { case 4: - return 40; + return LoadProperties.keepEnchantsRank4; case 3: - return 30; + return LoadProperties.keepEnchantsRank3; case 2: - return 20; + return LoadProperties.keepEnchantsRank2; case 1: - return 10; + return LoadProperties.keepEnchantsRank1; default: return 0; } @@ -385,13 +394,13 @@ public class Repair { switch(rank) { case 4: - return 15; + return LoadProperties.downgradeRank4; case 3: - return 25; + return LoadProperties.downgradeRank3; case 2: - return 50; + return LoadProperties.downgradeRank2; case 1: - return 75; + return LoadProperties.downgradeRank1; default: return 100; }