ConfigConstants.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package com.gmail.nossr50.config;
  2. import com.gmail.nossr50.mcMMO;
  3. import java.io.File;
  4. import java.util.ArrayList;
  5. /**
  6. * Constants relating to config folders and paths
  7. */
  8. public class ConfigConstants {
  9. public final static ArrayList<String> EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT;
  10. public final static String SKILL_SCALING_BENEFIT_EXPLANATION = "\nSub-Skills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " +
  11. "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of that sub-skill.";
  12. /* FOLDER NAMES */
  13. public static final String FOLDER_NAME_CONFIG = "config";
  14. public static final String FOLDER_NAME_SKILLS = "skills";
  15. public static final String FOLDER_NAME_EXPERIENCE = "Experience Settings";
  16. public static final String FOLDER_NAME_DEFAULTS = "defaults";
  17. /* RELATIVE PATHS */
  18. public final static String RELATIVE_PATH_CONFIG_DIR = File.separator + FOLDER_NAME_CONFIG + File.separator;
  19. public final static String RELATIVE_PATH_SKILLS_DIR = RELATIVE_PATH_CONFIG_DIR + FOLDER_NAME_SKILLS + File.separator;
  20. public final static String RELATIVE_PATH_XP_DIR = RELATIVE_PATH_CONFIG_DIR + FOLDER_NAME_EXPERIENCE + File.separator;
  21. private final static String[] EXAMPLE_BLACKLIST_WORLDS = {"Example_15434453", "Example_2324423", "Example_323423465"};
  22. /* Field Names & Comments */
  23. public static final String SUB_SKILL_NODE = "Sub-Skill";
  24. public final static String MAX_CHANCE_FIELD_NAME = "Max-Chance";
  25. public final static String STATIC_ACTIVATION_FIELD_NAME = "Activation-Chance";
  26. public final static String MAX_BONUS_LEVEL_FIELD_NAME = "Max-Bonus-Level";
  27. public final static String MAX_BONUS_PERCENTAGE_FIELD_NAME = "Max-Bonus-Percentage";
  28. public final static String MAX_CHANCE_FIELD_DESCRIPTION = "The maximum probability for this skill to succeed.";
  29. //Add the worlds to the list
  30. static {
  31. EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT = new ArrayList<>();
  32. EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[0]);
  33. EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[1]);
  34. EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[2]);
  35. }
  36. /**
  37. * Return the data folder for mcMMO
  38. *
  39. * @return the File for the data folder used by mcMMO
  40. */
  41. public static File getDataFolder() {
  42. return mcMMO.p.getDataFolder();
  43. }
  44. public static File getConfigFolder() {
  45. return new File(getDataFolder(), FOLDER_NAME_CONFIG);
  46. }
  47. public static File getDefaultsFolder() {
  48. return new File(getConfigFolder().getAbsolutePath(), FOLDER_NAME_DEFAULTS);
  49. }
  50. public static File getDefaultsConfigFolder() {
  51. return new File(getDefaultsFolder().getAbsolutePath(), FOLDER_NAME_CONFIG);
  52. }
  53. public static File getDefaultsSkillFolder() {
  54. return new File(getDefaultsConfigFolder().getAbsolutePath(), FOLDER_NAME_SKILLS);
  55. }
  56. public static File getDefaultsXPFolder() {
  57. return new File(getDefaultsConfigFolder().getAbsolutePath(), FOLDER_NAME_EXPERIENCE);
  58. }
  59. public static File getConfigSkillFolder() {
  60. return new File(getConfigFolder().getAbsolutePath(), FOLDER_NAME_SKILLS);
  61. }
  62. public static File getConfigXPFolder() {
  63. return new File(getConfigFolder().getAbsolutePath(), FOLDER_NAME_EXPERIENCE);
  64. }
  65. /**
  66. * Creates all directories used by mcMMO config files
  67. */
  68. public static void makeAllConfigDirectories() {
  69. /* CONFIG DIRECTORY */
  70. if (!getConfigFolder().exists())
  71. getConfigFolder().mkdirs();
  72. /* DEFAULT DIRECTORIES */
  73. if (!getDefaultsFolder().exists())
  74. getDefaultsFolder().mkdirs();
  75. if (!getDefaultsConfigFolder().exists())
  76. getDefaultsConfigFolder().mkdirs();
  77. if (!getDefaultsSkillFolder().exists())
  78. getDefaultsSkillFolder().mkdirs();
  79. if (!getDefaultsXPFolder().exists())
  80. getDefaultsXPFolder().mkdirs();
  81. /* CONFIG SUBDIRECTORIES */
  82. if (!getConfigSkillFolder().exists())
  83. getConfigSkillFolder().mkdirs();
  84. if (!getConfigXPFolder().exists())
  85. getConfigXPFolder().mkdirs();
  86. }
  87. }