CustomToolConfig.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package com.gmail.nossr50.config.mods;
  2. /*
  3. public class CustomToolConfig extends Config {
  4. //TODO: Disabled until modded servers come back
  5. public List<Material> customAxes = new ArrayList<Material>();
  6. public List<Material> customBows = new ArrayList<Material>();
  7. public List<Material> customHoes = new ArrayList<Material>();
  8. public List<Material> customPickaxes = new ArrayList<Material>();
  9. public List<Material> customShovels = new ArrayList<Material>();
  10. public List<Material> customSwords = new ArrayList<Material>();
  11. public HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
  12. public List<Repairable> repairables = new ArrayList<Repairable>();
  13. private boolean needsUpdate = false;
  14. protected CustomToolConfig(String fileName) {
  15. //super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false);
  16. super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false);
  17. loadKeys();
  18. }
  19. @Override
  20. protected void loadKeys() {
  21. loadTool("Axes", customAxes);
  22. loadTool("Bows", customBows);
  23. loadTool("Hoes", customHoes);
  24. loadTool("Pickaxes", customPickaxes);
  25. loadTool("Shovels", customShovels);
  26. loadTool("Swords", customSwords);
  27. if (needsUpdate) {
  28. needsUpdate = false;
  29. backup();
  30. }
  31. }
  32. private void loadTool(String toolType, List<Material> materialList) {
  33. if (needsUpdate) {
  34. return;
  35. }
  36. ConfigurationSection toolSection = config.getConfigurationSection(toolType);
  37. if (toolSection == null) {
  38. return;
  39. }
  40. Set<String> toolConfigSet = toolSection.getKeys(false);
  41. for (String toolName : toolConfigSet) {
  42. if (config.contains(toolType + "." + toolName + "." + ".ID")) {
  43. needsUpdate = true;
  44. return;
  45. }
  46. Material toolMaterial = Material.matchMaterial(toolName);
  47. if (toolMaterial == null) {
  48. plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + toolName);
  49. continue;
  50. }
  51. boolean repairable = getBooleanValue(toolType + "." + toolName + ".Repairable");
  52. Material repairMaterial = Material.matchMaterial(getStringValue(toolType + "." + toolName + ".Repair_Material", ""));
  53. if (repairable && (repairMaterial == null)) {
  54. plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + toolName);
  55. repairable = false;
  56. }
  57. if (repairable) {
  58. byte repairData = (byte) getIntValue(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
  59. int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
  60. if (repairQuantity == 0) {
  61. repairQuantity = getIntValue(toolType + "." + toolName + ".Repair_Material_Quantity", 2);
  62. }
  63. String repairItemName = getStringValue(toolType + "." + toolName + ".Repair_Material_Pretty_Name");
  64. int repairMinimumLevel = getIntValue(toolType + "." + toolName + ".Repair_MinimumLevel", 0);
  65. double repairXpMultiplier = getDoubleValue(toolType + "." + toolName + ".Repair_XpMultiplier", 1);
  66. short durability = toolMaterial.getMaxDurability();
  67. if (durability == 0) {
  68. durability = (short) getIntValue(toolType + "." + toolName + ".Durability", 60);
  69. }
  70. repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, repairXpMultiplier));
  71. }
  72. double multiplier = getDoubleValue(toolType + "." + toolName + ".XP_Modifier", 1.0);
  73. boolean abilityEnabled = getBooleanValue(toolType + "." + toolName + ".Ability_Enabled", true);
  74. int tier = getIntValue(toolType + "." + toolName + ".Tier", 1);
  75. CustomTool tool = new CustomTool(tier, abilityEnabled, multiplier);
  76. materialList.add(toolMaterial);
  77. customToolMap.put(toolMaterial, tool);
  78. }
  79. }
  80. }*/