LoadProperties.java 28 KB

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