Config.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. package com.gmail.nossr50.config;
  2. import java.util.Set;
  3. import org.bukkit.Material;
  4. import org.bukkit.configuration.ConfigurationSection;
  5. import org.bukkit.entity.EntityType;
  6. import com.gmail.nossr50.datatypes.skills.AbilityType;
  7. import com.gmail.nossr50.datatypes.skills.SkillType;
  8. import com.gmail.nossr50.util.StringUtils;
  9. public class Config extends AutoUpdateConfigLoader {
  10. private static Config instance;
  11. private Config() {
  12. super("config.yml");
  13. }
  14. public static Config getInstance() {
  15. if (instance == null) {
  16. instance = new Config();
  17. }
  18. return instance;
  19. }
  20. @Override
  21. protected void loadKeys() {}
  22. /*
  23. * GENERAL SETTINGS
  24. */
  25. /* General Settings */
  26. public String getLocale() { return config.getString("General.Locale", "en_us"); }
  27. public boolean getMOTDEnabled() { return config.getBoolean("General.MOTD_Enabled", true); }
  28. public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
  29. public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
  30. public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
  31. public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
  32. public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
  33. public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
  34. public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
  35. public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
  36. public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
  37. public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
  38. public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
  39. /* Database Purging */
  40. public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
  41. public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
  42. /* mySQL */
  43. public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
  44. public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
  45. public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); }
  46. public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); }
  47. public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
  48. public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
  49. public String getMySQLUserPassword() {
  50. if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) {
  51. return getStringIncludingInts(config, "MySQL.Database.User_Password");
  52. }
  53. return "";
  54. }
  55. private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
  56. String str = cfg.getString(key);
  57. if (str == null) {
  58. str = String.valueOf(cfg.getInt(key));
  59. }
  60. if (str == "0") {
  61. str = "No value set for '" + key + "'";
  62. }
  63. return str;
  64. }
  65. /* Hardcore Mode */
  66. public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
  67. public void setHardcoreEnabled(boolean enabled) { config.set("Hardcore.Enabled", enabled); }
  68. public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75.0); }
  69. public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss_Penalty_Percentage", value); }
  70. public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5.0); }
  71. public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism_Stat_Leech_Percentage", value); }
  72. public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
  73. public void setHardcoreVampirismEnabled(boolean enabled) { config.set("Hardcore.Vampirism", enabled); }
  74. /* SMP Mods */
  75. public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
  76. public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
  77. public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
  78. public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
  79. /* Items */
  80. public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); }
  81. public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
  82. public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
  83. /* Particles */
  84. public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
  85. public boolean getAbilityDeactivationEffectEnabled() { return config.getBoolean("Particles.Ability_Deactivation", true); }
  86. public boolean getDodgeEffectEnabled() { return config.getBoolean("Particles.Dodge", true); }
  87. public boolean getBleedEffectEnabled() { return config.getBoolean("Particles.Bleed", true); }
  88. public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); }
  89. /* PARTY SETTINGS */
  90. public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
  91. public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
  92. public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
  93. public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1); }
  94. public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05); }
  95. public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5); }
  96. public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
  97. public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
  98. /* Party Teleport Settings */
  99. public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 30); }
  100. public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
  101. public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
  102. public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
  103. /*
  104. * ABILITY SETTINGS
  105. */
  106. /* General Settings */
  107. public boolean getAbilityMessagesEnabled() { return config.getBoolean("Abilities.Messages", true); }
  108. public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
  109. public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
  110. public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
  111. public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
  112. /* Durability Settings */
  113. public boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); }
  114. public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
  115. /* Thresholds */
  116. public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
  117. /*
  118. * SKILL SETTINGS
  119. */
  120. public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
  121. public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
  122. public boolean getDoubleDropsDisabled(SkillType skill) {
  123. String skillName = StringUtils.getCapitalized(skill.toString());
  124. ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
  125. Set<String> keys = section.getKeys(false);
  126. boolean disabled = true;
  127. for (String key : keys) {
  128. if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
  129. disabled = false;
  130. break;
  131. }
  132. }
  133. return disabled;
  134. }
  135. /* Acrobatics */
  136. public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
  137. /* Fishing */
  138. public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
  139. public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
  140. /* Mining */
  141. public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
  142. /* Repair */
  143. public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
  144. public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
  145. public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
  146. public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
  147. public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
  148. public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
  149. /* Unarmed */
  150. public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
  151. /* Taming */
  152. public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
  153. public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
  154. public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
  155. public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
  156. /* Woodcutting */
  157. public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
  158. public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
  159. public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
  160. public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
  161. public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
  162. public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
  163. public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
  164. public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
  165. public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
  166. public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
  167. public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
  168. /* AFK Leveling */
  169. public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
  170. public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
  171. /* Level Caps */
  172. public int getPowerLevelCap() {
  173. int cap = config.getInt("General.Power_Level_Cap", 0);
  174. return (cap <= 0) ? Integer.MAX_VALUE : cap;
  175. }
  176. public int getLevelCap(SkillType skill) {
  177. int cap = config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Level_Cap");
  178. return (cap <= 0) ? Integer.MAX_VALUE : cap;
  179. }
  180. /* PVP & PVE Settings */
  181. public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
  182. public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
  183. /*
  184. * XP SETTINGS
  185. */
  186. /* General Settings */
  187. public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
  188. public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
  189. public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
  190. public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
  191. /* Combat XP Multipliers */
  192. public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
  193. public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
  194. public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
  195. public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
  196. /* XP Formula Multiplier */
  197. public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
  198. public double getForumulaMultiplier(SkillType skill) { return config.getDouble("Experience.Formula.Multiplier." + StringUtils.getCapitalized(skill.toString())); }
  199. }