LoadProperties.java 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /*
  2. This file is part of mcMMO.
  3. mcMMO is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. mcMMO is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. package com.gmail.nossr50.config;
  15. import com.gmail.nossr50.mcMMO;
  16. import java.io.File;
  17. import java.io.IOException;
  18. import java.util.ArrayList;
  19. import java.util.HashMap;
  20. import java.util.Iterator;
  21. import java.util.List;
  22. import java.util.Map;
  23. import java.util.Set;
  24. import org.bukkit.Material;
  25. import org.bukkit.configuration.ConfigurationSection;
  26. import org.bukkit.configuration.file.FileConfiguration;
  27. import org.bukkit.inventory.ItemStack;
  28. import com.gmail.nossr50.datatypes.HUDType;
  29. import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
  30. import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
  31. import com.gmail.nossr50.datatypes.treasure.Treasure;
  32. public class LoadProperties {
  33. public static Boolean enableOnlyActivateWhenSneaking,
  34. enableAbilityMessages, enableAbilities, showDisplayName, showFaces,
  35. xplockEnable, xpbar, xpicon, partybar, xprateEnable, spoutEnabled,
  36. donateMessage, chimaeraWingEnable, xpGainsMobSpawners, myspawnEnable,
  37. mccEnable, mcmmoEnable, partyEnable, inviteEnable, acceptEnable,
  38. whoisEnable, statsEnable, addxpEnable, ptpEnable, mmoeditEnable,
  39. clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable,
  40. mcrefreshEnable, aEnable, pEnable, enableMotd, enableMySpawn,
  41. enableCobbleToMossy, useMySQL, toolsLoseDurabilityFromAbilities,
  42. pvpxp, miningrequirespickaxe, excavationRequiresShovel,
  43. woodcuttingrequiresaxe, anvilmessages, mayDowngradeEnchants,
  44. mayLoseEnchants, fishingDrops, leatherArmor, ironArmor, goldArmor,
  45. diamondArmor, woodenTools, stoneTools, ironTools, goldTools,
  46. diamondTools, enderPearl, blazeRod, records, glowstoneDust,
  47. fishingDiamonds, aDisplayNames, pDisplayNames, enableSmoothToMossy,
  48. enableDirtToGrass, statsTracking, eventCallback, herbalismHungerBonus;
  49. public static String MySQLtablePrefix, MySQLuserName,
  50. MySQLserverName, MySQLdbName, MySQLdbPass, nWood, nStone,
  51. nIron, nGold, nDiamond, locale, nString, nLeather;
  52. public static int mtameWolf, mshearing, mfishing, xpbar_x, xpbar_y, xpicon_x, xpicon_y,
  53. chimaeraId, msandstone, mbase, mpine, mbirch, mspruce, mmelon,
  54. mcactus, mmushroom, mflower, msugar, mpumpkin, mwheat, mgold,
  55. mdiamond, miron, mredstone, mlapis, mobsidian, mnetherrack,
  56. mglowstone, mcoal, mstone, MySQLport, xpGainMultiplier,
  57. superBreakerCooldown, greenTerraCooldown, gigaDrillBreakerCooldown,
  58. treeFellerCooldown, berserkCooldown, serratedStrikeCooldown,
  59. skullSplitterCooldown, abilityDurabilityLoss,
  60. feathersConsumedByChimaeraWing, bonesConsumedByCOTW,
  61. repairdiamondlevel, rWood, rStone, rIron, rGold, rDiamond, rString,
  62. rLeather, downgradeRank1, downgradeRank2, downgradeRank3,
  63. downgradeRank4, keepEnchantsRank1, keepEnchantsRank2,
  64. keepEnchantsRank3, keepEnchantsRank4, fishingDropChanceTier1,
  65. fishingDropChanceTier2, fishingDropChanceTier3,
  66. fishingDropChanceTier4, fishingDropChanceTier5, mnetherwart,
  67. mvines, mlilypad, mendstone, mmossstone,
  68. levelCapAcrobatics, levelCapArchery, levelCapAxes, levelCapExcavation,
  69. levelCapFishing, levelCapHerbalism, levelCapMining, levelCapRepair,
  70. levelCapSwords, levelCapTaming, levelCapUnarmed, levelCapWoodcutting,
  71. anvilID, saveInterval, fishingTier1, fishingTier2, fishingTier3, fishingTier4;
  72. public static double xpbackground_r, xpbackground_g, xpbackground_b,
  73. xpborder_r, xpborder_g, xpborder_b, fishing_r, fishing_g,
  74. fishing_b, acrobatics_r, acrobatics_g, acrobatics_b, archery_r,
  75. archery_g, archery_b, axes_r, axes_g, axes_b, excavation_r,
  76. excavation_g, excavation_b, herbalism_r, herbalism_g, herbalism_b,
  77. mining_r, mining_g, mining_b, repair_r, repair_g, repair_b,
  78. swords_r, swords_g, swords_b, taming_r, taming_g, taming_b,
  79. unarmed_r, unarmed_g, unarmed_b, woodcutting_r, woodcutting_g,
  80. woodcutting_b, pvpxprewardmodifier, tamingxpmodifier,
  81. miningxpmodifier, repairxpmodifier, woodcuttingxpmodifier,
  82. sorceryxpmodifier, unarmedxpmodifier, herbalismxpmodifier,
  83. excavationxpmodifier, archeryxpmodifier, swordsxpmodifier,
  84. axesxpmodifier, acrobaticsxpmodifier;
  85. public static List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
  86. public static List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
  87. public static List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
  88. public static List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
  89. public static List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
  90. public static List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
  91. public static List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
  92. public static List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
  93. public static List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
  94. public static List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
  95. public static List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
  96. public static HUDType defaulthud;
  97. protected static File configFile;
  98. protected static File dataFolder;
  99. protected final mcMMO plugin;
  100. protected static FileConfiguration config;
  101. public LoadProperties(mcMMO plugin) {
  102. this.plugin = plugin;
  103. dataFolder = plugin.getDataFolder();
  104. configFile = new File(dataFolder, File.separator + "config.yml");
  105. config = plugin.getConfig();
  106. }
  107. public void load() {
  108. // If not exist, copy from the jar
  109. if (!configFile.exists()) {
  110. dataFolder.mkdir();
  111. plugin.saveDefaultConfig();
  112. }
  113. addDefaults();
  114. loadKeys();
  115. }
  116. private Boolean readBoolean(String root, Boolean def) {
  117. Boolean result = config.getBoolean(root, def);
  118. return result;
  119. }
  120. private Double readDouble(String root, Double def) {
  121. Double result = config.getDouble(root, def);
  122. return result;
  123. }
  124. private Integer readInteger(String root, Integer def) {
  125. Integer result = config.getInt(root, def);
  126. return result;
  127. }
  128. public static String readString(String root, String def) {
  129. String result = config.getString(root, def);
  130. return result;
  131. }
  132. private static void saveConfig() {
  133. try {
  134. config.save(configFile);
  135. } catch (IOException e) {
  136. e.printStackTrace();
  137. }
  138. }
  139. private void addDefaults() {
  140. // Load from included config.yml
  141. config.options().copyDefaults(true);
  142. saveConfig();
  143. }
  144. private void loadKeys() {
  145. plugin.getLogger().info("Loading Config File...");
  146. // Setup default HUD
  147. String temp = readString("Spout.HUD.Default", "STANDARD");
  148. for (HUDType x : HUDType.values()) {
  149. if (x.toString().equalsIgnoreCase(temp)) {
  150. defaulthud = x;
  151. }
  152. }
  153. enableAbilityMessages = readBoolean("Abilities.Messages", true);
  154. enableAbilities = readBoolean("Abilities.Enabled", true);
  155. donateMessage = readBoolean("Commands.mcmmo.Donate_Message", true);
  156. xpGainsMobSpawners = readBoolean("Experience.Gains.Mobspawners.Enabled", false);
  157. bonesConsumedByCOTW = readInteger("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10);
  158. xpbar = readBoolean("Spout.XP.Bar.Enabled", true);
  159. // web_url = readString("Spout.Images.URL_DIR",
  160. // "http://mcmmo.rycochet.net/mcmmo/");
  161. xpicon = readBoolean("Spout.XP.Icon.Enabled", true);
  162. xpbar_x = readInteger("Spout.XP.Bar.X_POS", 95);
  163. xpbar_y = readInteger("Spout.XP.Bar.Y_POS", 6);
  164. xpicon_x = readInteger("Spout.XP.Icon.X_POS", 78);
  165. xpicon_y = readInteger("Spout.XP.Icon.Y_POS", 2);
  166. showFaces = readBoolean("Spout.Party.HUD.Show_Faces", true);
  167. showDisplayName = readBoolean("Spout.Party.HUD.Show_Display_Name", false);
  168. partybar = readBoolean("Spout.Party.HUD.Enabled", true);
  169. acrobatics_r = readDouble("Spout.HUD.Retro.Colors.Acrobatics.RED", 0.3);
  170. acrobatics_g = readDouble("Spout.HUD.Retro.Colors.Acrobatics.GREEN", 0.3);
  171. acrobatics_b = readDouble("Spout.HUD.Retro.Colors.Acrobatics.BLUE", 0.75);
  172. archery_r = readDouble("Spout.HUD.Retro.Colors.Archery.RED", 0.3);
  173. archery_g = readDouble("Spout.HUD.Retro.Colors.Archery.GREEN", 0.3);
  174. archery_b = readDouble("Spout.HUD.Retro.Colors.Archery.BLUE", 0.75);
  175. axes_r = readDouble("Spout.HUD.Retro.Colors.Axes.RED", 0.3);
  176. axes_g = readDouble("Spout.HUD.Retro.Colors.Axes.GREEN", 0.3);
  177. axes_b = readDouble("Spout.HUD.Retro.Colors.Axes.BLUE", 0.75);
  178. excavation_r = readDouble("Spout.HUD.Retro.Colors.Excavation.RED", 0.3);
  179. excavation_g = readDouble("Spout.HUD.Retro.Colors.Excavation.GREEN", 0.3);
  180. excavation_b = readDouble("Spout.HUD.Retro.Colors.Excavation.BLUE", 0.75);
  181. herbalism_r = readDouble("Spout.HUD.Retro.Colors.Herbalism.RED", 0.3);
  182. herbalism_g = readDouble("Spout.HUD.Retro.Colors.Herbalism.GREEN", 0.3);
  183. herbalism_b = readDouble("Spout.HUD.Retro.Colors.Herbalism.BLUE", 0.75);
  184. mining_r = readDouble("Spout.HUD.Retro.Colors.Mining.RED", 0.3);
  185. mining_g = readDouble("Spout.HUD.Retro.Colors.Mining.GREEN", 0.3);
  186. mining_b = readDouble("Spout.HUD.Retro.Colors.Mining.BLUE", 0.75);
  187. repair_r = readDouble("Spout.HUD.Retro.Colors.Repair.RED", 0.3);
  188. repair_g = readDouble("Spout.HUD.Retro.Colors.Repair.GREEN", 0.3);
  189. repair_b = readDouble("Spout.HUD.Retro.Colors.Repair.BLUE", 0.75);
  190. swords_r = readDouble("Spout.HUD.Retro.Colors.Swords.RED", 0.3);
  191. swords_g = readDouble("Spout.HUD.Retro.Colors.Swords.GREEN", 0.3);
  192. swords_b = readDouble("Spout.HUD.Retro.Colors.Swords.BLUE", 0.75);
  193. taming_r = readDouble("Spout.HUD.Retro.Colors.Taming.RED", 0.3);
  194. taming_g = readDouble("Spout.HUD.Retro.Colors.Taming.GREEN", 0.3);
  195. taming_b = readDouble("Spout.HUD.Retro.Colors.Taming.BLUE", 0.75);
  196. unarmed_r = readDouble("Spout.HUD.Retro.Colors.Unarmed.RED", 0.3);
  197. unarmed_g = readDouble("Spout.HUD.Retro.Colors.Unarmed.GREEN", 0.3);
  198. unarmed_b = readDouble("Spout.HUD.Retro.Colors.Unarmed.BLUE", 0.75);
  199. woodcutting_r = readDouble("Spout.HUD.Retro.Colors.Woodcutting.RED", 0.3);
  200. woodcutting_g = readDouble("Spout.HUD.Retro.Colors.Woodcutting.GREEN", 0.3);
  201. woodcutting_b = readDouble("Spout.HUD.Retro.Colors.Woodcutting.BLUE", 0.75);
  202. fishing_r = readDouble("Spout.HUD.Retro.Colors.Fishing.RED", 0.3);
  203. fishing_g = readDouble("Spout.HUD.Retro.Colors.Fishing.GREEN", 0.3);
  204. fishing_b = readDouble("Spout.HUD.Retro.Colors.Fishing.BLUE", 0.75);
  205. xpborder_r = readDouble("Spout.HUD.Retro.Colors.Border.RED", 0.0);
  206. xpborder_g = readDouble("Spout.HUD.Retro.Colors.Border.GREEN", 0.0);
  207. xpborder_b = readDouble("Spout.HUD.Retro.Colors.Border.BLUE", 0.0);
  208. xpbackground_r = readDouble("Spout.HUD.Retro.Colors.Background.RED", 0.75);
  209. xpbackground_g = readDouble("Spout.HUD.Retro.Colors.Background.GREEN", 0.75);
  210. xpbackground_b = readDouble("Spout.HUD.Retro.Colors.Background.BLUE", 0.75);
  211. mbase = readInteger("Experience.Excavation.Base", 40);
  212. msugar = readInteger("Experience.Herbalism.Sugar_Cane", 30);
  213. mwheat = readInteger("Experience.Herbalism.Wheat", 50);
  214. mcactus = readInteger("Experience.Herbalism.Cactus", 30);
  215. mpumpkin = readInteger("Experience.Herbalism.Pumpkin", 20);
  216. mflower = readInteger("Experience.Herbalism.Flowers", 100);
  217. mmushroom = readInteger("Experience.Herbalism.Mushrooms", 150);
  218. mmelon = readInteger("Experience.Herbalism.Melon", 20);
  219. mnetherwart = readInteger("Experience.Herbalism.Nether_Wart", 50);
  220. mlilypad = readInteger("Experience.Herbalism.Lily_Pads", 100);
  221. mvines = readInteger("Experience.Herbalism.Vines", 10);
  222. herbalismHungerBonus = readBoolean("Skills.Herbalism.Hunger_Bonus", true);
  223. mpine = readInteger("Experience.Woodcutting.Pine", 70);
  224. mbirch = readInteger("Experience.Woodcutting.Birch", 80);
  225. mspruce = readInteger("Experience.Woodcutting.Spruce", 90);
  226. mgold = readInteger("Experience.Mining.Gold", 250);
  227. mdiamond = readInteger("Experience.Mining.Diamond", 750);
  228. miron = readInteger("Experience.Mining.Iron", 250);
  229. mredstone = readInteger("Experience.Mining.Redstone", 150);
  230. mlapis = readInteger("Experience.Mining.Lapis", 400);
  231. mobsidian = readInteger("Experience.Mining.Obsidian", 150);
  232. mnetherrack = readInteger("Experience.Mining.Netherrack", 30);
  233. mglowstone = readInteger("Experience.Mining.Glowstone", 30);
  234. mcoal = readInteger("Experience.Mining.Coal", 100);
  235. mstone = readInteger("Experience.Mining.Stone", 30);
  236. msandstone = readInteger("Experience.Mining.Sandstone", 30);
  237. mendstone = readInteger("Experience.Mining.End_Stone", 150);
  238. mmossstone = readInteger("Experience.Mining.Moss_Stone", 30);
  239. mshearing = readInteger("Experience.Taming.Shearing", 250);
  240. mtameWolf = readInteger("Experience.Taming.Animal_Taming.Wolf", 250);
  241. mfishing = readInteger("Experience.Fishing.Base", 800);
  242. enableOnlyActivateWhenSneaking = readBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false);
  243. greenTerraCooldown = readInteger("Abilities.Cooldowns.Green_Terra", 240);
  244. superBreakerCooldown = readInteger("Abilities.Cooldowns.Super_Breaker", 240);
  245. gigaDrillBreakerCooldown = readInteger("Abilities.Cooldowns.Giga_Drill_Breaker", 240);
  246. treeFellerCooldown = readInteger("Abilities.Cooldowns.Tree_Feller", 240);
  247. berserkCooldown = readInteger("Abilities.Cooldowns.Berserk", 240);
  248. serratedStrikeCooldown = readInteger("Abilities.Cooldowns.Serrated_Strikes", 240);
  249. skullSplitterCooldown = readInteger("Abilities.Cooldowns.Skull_Splitter", 240);
  250. MySQLserverName = readString("MySQL.Server.Address", "localhost");
  251. if (readString("MySQL.Database.User.Password", null) != null)
  252. MySQLdbPass = readString("MySQL.Database.User.Password", null);
  253. else
  254. MySQLdbPass = "";
  255. MySQLdbName = readString("MySQL.Database.Name", "DatabaseName");
  256. MySQLuserName = readString("MySQL.Database.User.Name", "UserName");
  257. MySQLtablePrefix = readString("MySQL.Database.TablePrefix", "mcmmo_");
  258. MySQLport = readInteger("MySQL.Server.Port", 3306);
  259. useMySQL = readBoolean("MySQL.Enabled", false);
  260. locale = readString("General.Locale", "en_us");
  261. enableMotd = readBoolean("General.MOTD.Enabled", true);
  262. enableMySpawn = readBoolean("General.MySpawn.Enabled", true);
  263. saveInterval = readInteger("General.Save_Interval", 10);
  264. statsTracking = readBoolean("General.Stats_Tracking", true);
  265. eventCallback = readBoolean("General.Event_Callback", true);
  266. enableCobbleToMossy = readBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true);
  267. enableSmoothToMossy = readBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true);
  268. enableDirtToGrass = readBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true);
  269. xpGainMultiplier = readInteger("Experience.Gains.Multiplier.Global", 1);
  270. toolsLoseDurabilityFromAbilities = readBoolean("Abilities.Tools.Durability_Loss_Enabled", true);
  271. abilityDurabilityLoss = readInteger("Abilities.Tools.Durability_Loss", 2);
  272. feathersConsumedByChimaeraWing = readInteger("Items.Chimaera_Wing.Feather_Cost", 10);
  273. chimaeraId = readInteger("Items.Chimaera_Wing.Item_ID", 288);
  274. chimaeraWingEnable = readBoolean("Items.Chimaera_Wing.Enabled", true);
  275. pvpxp = readBoolean("Experience.PVP.Rewards", true);
  276. pvpxprewardmodifier = readDouble("Experience.Gains.Multiplier.PVP", 1.0);
  277. miningrequirespickaxe = readBoolean("Skills.Mining.Requires_Pickaxe", true);
  278. excavationRequiresShovel = readBoolean("Skills.Excavation.Requires_Shovel", true);
  279. woodcuttingrequiresaxe = readBoolean("Skills.Woodcutting.Requires_Axe", true);
  280. repairdiamondlevel = readInteger("Skills.Repair.Diamond.Level_Required", 50);
  281. sorceryxpmodifier = readDouble("Experience.Formula.Multiplier.Sorcery", 1.0);
  282. tamingxpmodifier = readDouble("Experience.Formula.Multiplier.Taming", 1.0);
  283. miningxpmodifier = readDouble("Experience.Formula.Multiplier.Mining", 1.0);
  284. repairxpmodifier = readDouble("Experience.Formula.Multiplier.Repair", 1.0);
  285. woodcuttingxpmodifier = readDouble("Experience.Formula.Multiplier.Woodcutting", 1.0);
  286. unarmedxpmodifier = readDouble("Experience.Formula.Multiplier.Unarmed", 1.0);
  287. herbalismxpmodifier = readDouble("Experience.Formula.Multiplier.Herbalism", 1.0);
  288. excavationxpmodifier = readDouble("Experience.Formula.Multiplier.Excavation", 1.0);
  289. archeryxpmodifier = readDouble("Experience.Formula.Multiplier.Archery", 1.0);
  290. swordsxpmodifier = readDouble("Experience.Formula.Multiplier.Swords", 1.0);
  291. axesxpmodifier = readDouble("Experience.Formula.Multiplier.Axes", 1.0);
  292. acrobaticsxpmodifier = readDouble("Experience.Formula.Multiplier.Acrobatics", 1.0);
  293. anvilmessages = readBoolean("Skills.Repair.Anvil_Messages", true);
  294. anvilID = readInteger("Skills.Repair.Anvil_ID", 42);
  295. rGold = readInteger("Skills.Repair.Gold.ID", 266);
  296. nGold = readString("Skills.Repair.Gold.Name", "Gold Bars");
  297. rStone = readInteger("Skills.Repair.Stone.ID", 4);
  298. nStone = readString("Skills.Repair.Stone.Name", "Cobblestone");
  299. rWood = readInteger("Skills.Repair.Wood.ID", 5);
  300. nWood = readString("Skills.Repair.Wood.Name", "Wood Planks");
  301. rDiamond = readInteger("Skills.Repair.Diamond.ID", 264);
  302. nDiamond = readString("Skills.Repair.Diamond.Name", "Diamond");
  303. rIron = readInteger("Skills.Repair.Iron.ID", 265);
  304. nIron = readString("Skills.Repair.Iron.Name", "Iron Bars");
  305. rString = readInteger("Skills.Repair.String.ID", 287);
  306. nString = readString("Skills.Repair.String.Name", "String");
  307. rLeather = readInteger("Skills.Repair.Leather.ID", 334);
  308. nLeather = readString("Skills.Repair.Leather.Name", "Leather");
  309. levelCapAcrobatics = readInteger("Skills.Acrobatics.Level_Cap", 0);
  310. levelCapArchery = readInteger("Skills.Archery.Level_Cap", 0);
  311. levelCapAxes = readInteger("Skills.Axes.Level_Cap", 0);
  312. levelCapExcavation = readInteger("Skills.Excavation.Level_Cap", 0);
  313. levelCapFishing = readInteger("Skills.Fishing.Level_Cap", 0);
  314. levelCapHerbalism = readInteger("Skills.Herbalism.Level_Cap", 0);
  315. levelCapMining = readInteger("Skills.Mining.Level_Cap", 0);
  316. levelCapRepair = readInteger("Skills.Repair.Level_Cap", 0);
  317. levelCapSwords = readInteger("Skills.Swords.Level_Cap", 0);
  318. levelCapTaming = readInteger("Skills.Taming.Level_Cap", 0);
  319. levelCapUnarmed = readInteger("Skills.Unarmed.Level_Cap", 0);
  320. levelCapWoodcutting = readInteger("Skills.Woodcutting.Level_Cap", 0);
  321. mayDowngradeEnchants = readBoolean("Arcane_Forging.Downgrades.Enabled", true);
  322. downgradeRank1 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_1", 75);
  323. downgradeRank2 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_2", 50);
  324. downgradeRank3 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_3", 25);
  325. downgradeRank4 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_4", 15);
  326. mayLoseEnchants = readBoolean("Arcane_Forging.May_Lose_Enchants.Enabled", true);
  327. keepEnchantsRank1 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10);
  328. keepEnchantsRank2 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20);
  329. keepEnchantsRank3 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30);
  330. keepEnchantsRank4 = readInteger("Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40);
  331. fishingDrops = readBoolean("Fishing.Drops.Item_Drops_Enabled", true);
  332. fishingTier1 = readInteger("Fishing.Drop_Level.Tier1", 200);
  333. fishingTier2 = readInteger("Fishing.Drop_Level.Tier1", 400);
  334. fishingTier3 = readInteger("Fishing.Drop_Level.Tier1", 600);
  335. fishingTier4 = readInteger("Fishing.Drop_Level.Tier1", 800);
  336. fishingDropChanceTier1 = readInteger("Fishing.Drops.Drop_Chance.Tier_1", 20);
  337. fishingDropChanceTier2 = readInteger("Fishing.Drops.Drop_Chance.Tier_2", 25);
  338. fishingDropChanceTier3 = readInteger("Fishing.Drops.Drop_Chance.Tier_3", 30);
  339. fishingDropChanceTier4 = readInteger("Fishing.Drops.Drop_Chance.Tier_4", 35);
  340. fishingDropChanceTier5 = readInteger("Fishing.Drops.Drop_Chance.Tier_5", 40);
  341. leatherArmor = readBoolean("Fishing.Drops.Leather_Armor", true);
  342. ironArmor = readBoolean("Fishing.Drops.Iron_Armor", true);
  343. goldArmor = readBoolean("Fishing.Drops.Gold_Armor", true);
  344. diamondArmor = readBoolean("Fishing.Drops.Diamond_Armor", true);
  345. woodenTools = readBoolean("Fishing.Drops.Wooden_Tools", true);
  346. stoneTools = readBoolean("Fishing.Drops.Stone_Tools", true);
  347. ironTools = readBoolean("Fishing.Drops.Iron_Tools", true);
  348. goldTools = readBoolean("Fishing.Drops.Gold_Tools", true);
  349. diamondTools = readBoolean("Fishing.Drops.Diamond_Tools", true);
  350. enderPearl = readBoolean("Fishing.Drops.Ender_Pearl", true);
  351. blazeRod = readBoolean("Fishing.Drops.Blaze_Rod", true);
  352. records = readBoolean("Fishing.Drops.Records", true);
  353. glowstoneDust = readBoolean("Fishing.Drops.Glowstone_Dust", true);
  354. fishingDiamonds = readBoolean("Fishing.Drops.Diamonds", true);
  355. xplockEnable = readBoolean("Commands.xplock.Enabled", true);
  356. xprateEnable = readBoolean("Commands.xprate.Enabled", true);
  357. mctopEnable = readBoolean("Commands.mctop.Enabled", true);
  358. addxpEnable = readBoolean("Commands.addxp.Enabled", true);
  359. mcabilityEnable = readBoolean("Commands.mcability.Enabled", true);
  360. mcrefreshEnable = readBoolean("Commands.mcrefresh.Enabled", true);
  361. mcmmoEnable = readBoolean("Commands.mcmmo.Enabled", true);
  362. mccEnable = readBoolean("Commands.mcc.Enabled", true);
  363. mcgodEnable = readBoolean("Commands.mcgod.Enabled", true);
  364. statsEnable = readBoolean("Commands.stats.Enabled", true);
  365. mmoeditEnable = readBoolean("Commands.mmoedit.Enabled", true);
  366. ptpEnable = readBoolean("Commands.ptp.Enabled", true);
  367. partyEnable = readBoolean("Commands.party.Enabled", true);
  368. myspawnEnable = readBoolean("Commands.myspawn.Enabled", true);
  369. whoisEnable = readBoolean("Commands.whois.Enabled", true);
  370. inviteEnable = readBoolean("Commands.invite.Enabled", true);
  371. acceptEnable = readBoolean("Commands.accept.Enabled", true);
  372. clearmyspawnEnable = readBoolean("Commands.clearmyspawn.Enabled", true);
  373. aEnable = readBoolean("Commands.a.Enabled", true);
  374. pEnable = readBoolean("Commands.p.Enabled", true);
  375. aDisplayNames = readBoolean("Commands.a.Display_Names", true);
  376. pDisplayNames = readBoolean("Commands.p.Display_Names", true);
  377. // Load treasures
  378. Map<String, Treasure> treasures = new HashMap<String, Treasure>();
  379. ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
  380. Set<String> treasureConfigSet = treasureSection.getKeys(false);
  381. Iterator<String> iterator = treasureConfigSet.iterator();
  382. while(iterator.hasNext())
  383. {
  384. String treasureName = iterator.next();
  385. // Validate all the things!
  386. List<String> reason = new ArrayList<String>();
  387. if(!config.contains("Treasures." + treasureName + ".ID")) reason.add("Missing ID");
  388. if(!config.contains("Treasures." + treasureName + ".Amount")) reason.add("Missing Amount");
  389. if(!config.contains("Treasures." + treasureName + ".Data")) reason.add("Missing Data");
  390. int id = config.getInt("Treasures." + treasureName + ".ID");
  391. int amount = config.getInt("Treasures." + treasureName + ".Amount");
  392. int data = config.getInt("Treasures." + treasureName + ".Data");
  393. if(Material.getMaterial(id) == null) reason.add("Invlid id: " + id);
  394. if(amount < 1) reason.add("Invalid amount: " + amount);
  395. if(data > 127 || data < -128) reason.add("Invalid data: " + data);
  396. if(!config.contains("Treasures." + treasureName + ".XP")) reason.add("Missing XP");
  397. if(!config.contains("Treasures." + treasureName + ".Drop_Chance")) reason.add("Missing Drop_Chance");
  398. if(!config.contains("Treasures." + treasureName + ".Drop_Level")) reason.add("Missing Drop_Level");
  399. int xp = config.getInt("Treasures." + treasureName + ".XP");
  400. Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
  401. int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
  402. if(xp < 0) reason.add("Invalid xp: " + xp);
  403. if(dropChance < 0) reason.add("Invalid Drop_Chance: " + dropChance);
  404. if(dropLevel < 0) reason.add("Invalid Drop_Level: " + dropLevel);
  405. ItemStack item = new ItemStack(id, amount, (byte) 0, (byte) data);
  406. if(readBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
  407. if(config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1)
  408. reason.add("Fishing drops cannot also be excavation drops");
  409. if(!config.contains("Treasures." + treasureName + ".Max_Levels")) reason.add("Missing Max_Levels");
  410. int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Levels");
  411. if(maxLevel < 0) reason.add("Invalid Max_Levels: " + maxLevel);
  412. if(noErrorsInTreasure(reason)) {
  413. FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
  414. treasures.put(treasureName, fTreasure);
  415. }
  416. } else {
  417. ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
  418. if(readBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false))
  419. eTreasure.setDropsFromDirt();
  420. if(readBoolean("Treasures." + treasureName + ".Drops_From.Grass", false))
  421. eTreasure.setDropsFromGrass();
  422. if(readBoolean("Treasures." + treasureName + ".Drops_From.Sand", false))
  423. eTreasure.setDropsFromSand();
  424. if(readBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false))
  425. eTreasure.setDropsFromGravel();
  426. if(readBoolean("Treasures." + treasureName + ".Drops_From.Clay", false))
  427. eTreasure.setDropsFromClay();
  428. if(readBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false))
  429. eTreasure.setDropsFromMycel();
  430. if(readBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false))
  431. eTreasure.setDropsFromSoulSand();
  432. if(readBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
  433. reason.add("Excavation drops cannot also be fishing drops");
  434. }
  435. if(noErrorsInTreasure(reason)) {
  436. treasures.put(treasureName, eTreasure);
  437. }
  438. }
  439. }
  440. List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
  441. List<String> fishingTreasures = config.getStringList("Excavation.Treasure");
  442. Iterator<String> treasureIterator = treasures.keySet().iterator();
  443. while(treasureIterator.hasNext()) {
  444. String treasureKey = treasureIterator.next();
  445. Treasure treasure = treasures.get(treasureKey);
  446. if(treasure instanceof FishingTreasure) {
  447. if(!fishingTreasures.contains(treasureKey)) continue;
  448. FishingTreasure fTreasure = (FishingTreasure) treasure;
  449. int dropLevel = fTreasure.getDropLevel();
  450. int maxLevel = fTreasure.getMaxLevel();
  451. if(dropLevel <= fishingTier1 && maxLevel >= fishingTier1)
  452. fishingRewardsTier1.add(fTreasure);
  453. if(dropLevel <= fishingTier2 && maxLevel >= fishingTier2)
  454. fishingRewardsTier2.add(fTreasure);
  455. if(dropLevel <= fishingTier3 && maxLevel >= fishingTier3)
  456. fishingRewardsTier3.add(fTreasure);
  457. if(dropLevel <= fishingTier4 && maxLevel >= fishingTier4)
  458. fishingRewardsTier4.add(fTreasure);
  459. } else if(treasure instanceof ExcavationTreasure) {
  460. if(!excavationTreasures.contains(treasureKey)) continue;
  461. ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
  462. if(eTreasure.getDropsFromDirt())
  463. excavationFromDirt.add(eTreasure);
  464. if(eTreasure.getDropsFromGrass())
  465. excavationFromGrass.add(eTreasure);
  466. if(eTreasure.getDropsFromSand())
  467. excavationFromSand.add(eTreasure);
  468. if(eTreasure.getDropsFromGravel())
  469. excavationFromGravel.add(eTreasure);
  470. if(eTreasure.getDropsFromClay())
  471. excavationFromClay.add(eTreasure);
  472. if(eTreasure.getDropsFromMycel())
  473. excavationFromMycel.add(eTreasure);
  474. if(eTreasure.getDropsFromSoulSand())
  475. excavationFromSoulSand.add(eTreasure);
  476. }
  477. }
  478. }
  479. private boolean noErrorsInTreasure(List<String> issues) {
  480. if(issues.isEmpty()) return true;
  481. for(String issue : issues) {
  482. plugin.getLogger().warning(issue);
  483. }
  484. return false;
  485. }
  486. }