LoadProperties.java 27 KB

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