From 5e1c12d8ec62e121878f1c59a005a721deda2bf9 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 16 Feb 2019 16:09:48 -0800 Subject: [PATCH] new config pt 9 --- .../gmail/nossr50/commands/XprateCommand.java | 2 - .../commands/skills/SwordsCommand.java | 1 - .../com/gmail/nossr50/config/ChildConfig.java | 59 ++++++ .../nossr50/config/ConfigCollections.java | 19 ++ .../gmail/nossr50/config/RegistersKeys.java | 11 ++ .../collectionconfigs/MultiConfigManager.java | 119 ++++++++++++ .../collectionconfigs/SalvageConfig.java | 181 ------------------ .../datatypes/experience/SkillXpGain.java | 1 - .../skills/alchemy/AlchemyPotion.java | 3 +- .../skills/subskills/AbstractSubSkill.java | 3 +- .../database/FormulaConversionTask.java | 1 - .../runnables/skills/BleedTimerTask.java | 1 - .../gmail/nossr50/skills/alchemy/Alchemy.java | 1 - .../skills/alchemy/AlchemyManager.java | 4 +- .../skills/alchemy/AlchemyPotionBrewer.java | 9 +- .../gmail/nossr50/skills/archery/Archery.java | 2 - .../com/gmail/nossr50/skills/axes/Axes.java | 1 - .../gmail/nossr50/skills/mining/Mining.java | 1 - .../nossr50/skills/repair/ArcaneForging.java | 2 - .../gmail/nossr50/skills/swords/Swords.java | 2 - .../gmail/nossr50/skills/taming/Taming.java | 1 - .../skills/unarmed/UnarmedManager.java | 1 - .../util/experience/ExperienceBarManager.java | 1 - .../util/experience/ExperienceBarWrapper.java | 1 - .../util/player/NotificationManager.java | 1 - .../nossr50/util/random/RandomChanceUtil.java | 1 - .../nossr50/util/skills/CombatUtils.java | 1 - .../gmail/nossr50/util/skills/PerksUtils.java | 1 - .../gmail/nossr50/util/skills/RankUtils.java | 1 - .../nossr50/util/sounds/SoundManager.java | 13 +- 30 files changed, 221 insertions(+), 224 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/ChildConfig.java create mode 100644 src/main/java/com/gmail/nossr50/config/ConfigCollections.java create mode 100644 src/main/java/com/gmail/nossr50/config/RegistersKeys.java create mode 100644 src/main/java/com/gmail/nossr50/config/collectionconfigs/MultiConfigManager.java delete mode 100644 src/main/java/com/gmail/nossr50/config/collectionconfigs/SalvageConfig.java diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java index 93746e97a..d46712fdf 100644 --- a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.commands; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index 3b46b7b9a..ed905b0c3 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.skills; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.locale.LocaleLoader; diff --git a/src/main/java/com/gmail/nossr50/config/ChildConfig.java b/src/main/java/com/gmail/nossr50/config/ChildConfig.java new file mode 100644 index 000000000..0de422596 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/ChildConfig.java @@ -0,0 +1,59 @@ +package com.gmail.nossr50.config; + +import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.skills.child.FamilyTree; +import com.gmail.nossr50.util.StringUtils; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.util.EnumSet; + +public class ChildConfig extends ConfigCollections { + public ChildConfig() { + super("child.yml"); + } + + @Override + protected void loadKeys() { + config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResourceAsReader("child.yml"))); + + FamilyTree.clearRegistrations(); // when reloading, need to clear statics + + for (PrimarySkillType skill : PrimarySkillType.CHILD_SKILLS) { + plugin.debug("Finding parents of " + skill.name()); + + EnumSet parentSkills = EnumSet.noneOf(PrimarySkillType.class); + boolean useDefaults = false; // If we had an error we back out and use defaults + + for (String name : config.getStringList(StringUtils.getCapitalized(skill.name()))) { + try { + PrimarySkillType parentSkill = PrimarySkillType.valueOf(name.toUpperCase()); + FamilyTree.enforceNotChildSkill(parentSkill); + parentSkills.add(parentSkill); + } catch (IllegalArgumentException ex) { + plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!"); + useDefaults = true; + break; + } + } + + if (useDefaults) { + parentSkills.clear(); + for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) { + /* We do less checks in here because it's from inside our jar. + * If they're dedicated enough to have modified it, they can have the errors it may produce. + * Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration. + */ + parentSkills.add(PrimarySkillType.valueOf(name.toUpperCase())); + } + } + + // Register them + for (PrimarySkillType parentSkill : parentSkills) { + plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name()); + FamilyTree.registerParent(skill, parentSkill); + } + } + + FamilyTree.closeRegistration(); + } +} diff --git a/src/main/java/com/gmail/nossr50/config/ConfigCollections.java b/src/main/java/com/gmail/nossr50/config/ConfigCollections.java new file mode 100644 index 000000000..b6031a6d9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/ConfigCollections.java @@ -0,0 +1,19 @@ +package com.gmail.nossr50.config; + +import java.io.File; + +/** + * Represents a config file that registers keys after its initialized + */ +public abstract class ConfigCollections extends Config implements RegistersKeys, ConfigCollection { + + public ConfigCollections(String pathToParentFolder, String relativePath, boolean mergeNewKeys) { + super(pathToParentFolder, relativePath, mergeNewKeys); + loadKeys(); + } + + public ConfigCollections(File pathToParentFolder, String relativePath, boolean mergeNewKeys) { + super(pathToParentFolder, relativePath, mergeNewKeys); + loadKeys(); + } +} diff --git a/src/main/java/com/gmail/nossr50/config/RegistersKeys.java b/src/main/java/com/gmail/nossr50/config/RegistersKeys.java new file mode 100644 index 000000000..4ef2048e9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/RegistersKeys.java @@ -0,0 +1,11 @@ +package com.gmail.nossr50.config; + +/** + * A class that registers keys + */ +public interface RegistersKeys { + /** + * Loads up keys + */ + void loadKeys(); +} diff --git a/src/main/java/com/gmail/nossr50/config/collectionconfigs/MultiConfigManager.java b/src/main/java/com/gmail/nossr50/config/collectionconfigs/MultiConfigManager.java new file mode 100644 index 000000000..4790afb9a --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/collectionconfigs/MultiConfigManager.java @@ -0,0 +1,119 @@ +package com.gmail.nossr50.config.collectionconfigs; + +import com.gmail.nossr50.config.ConfigCollection; +import com.gmail.nossr50.config.ConfigCollections; +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.skills.repair.repairables.Repairable; +import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.regex.Pattern; + +/** + * Represents a collection of config files that serve a similar purpose + * For example, files named repair.*.yml are all loaded into memory, this lets admins keep their config files clean + * + * To be honest I'm not sure how many people make use of this system, but I'm keeping it since its been in mcMMO for like 6+ years + */ +public final class MultiConfigManager { + + public static final String DEFAULT_MULTICONFIG_FILENAME_SUFFIX = ".vanilla.yml"; + + //Configs + public com.gmail.nossr50.config.collectionconfigs.RepairConfig vanillaRepairConfig; //This is the main config file that mcMMO will copy out + public com.gmail.nossr50.config.collectionconfigs.SalvageConfig vanillaSalvageConfig; + + private static List repairables; + private static List salvageables; + + public MultiConfigManager(String fileNamePrefix) + { + //init Collections + repairables = new ArrayList<>(); + salvageables = new ArrayList<>(); + + //init vanilla configs + vanillaRepairConfig = new com.gmail.nossr50.config.collectionconfigs.RepairConfig(getVanillaConfigName("repair")); + vanillaSalvageConfig = new com.gmail.nossr50.config.collectionconfigs.SalvageConfig(getVanillaConfigName("salvage")); + + //add valid vanilla collections to main collection + repairables.addAll(vanillaRepairConfig.getLoadedCollection()); + salvageables.addAll(vanillaSalvageConfig.getLoadedCollection()); + + //add valid custom collections to main collection + loadCustomCollections("repair", repairables, com.gmail.nossr50.config.collectionconfigs.RepairConfig.class); + loadCustomCollections("salvage", salvageables, com.gmail.nossr50.config.collectionconfigs.SalvageConfig.class); + } + + /** + * mcMMO allows collection config files to be named things like repair.whatevernameyouwanthere.yml and so on, + * these files are treated in the same way as the vanilla file. They serve the purpose of organization + * @param configPrefix the prefix of the file name, for example "repair", "salvage", etc + * @param collection the collection that will be added to + */ + public void loadCustomCollections(String configPrefix, Collection collection, Class configClass) + { + String vanillaConfigFileName = getVanillaConfigName(configPrefix); + + //Find other files + Pattern pattern = Pattern.compile(configPrefix+"\\.(?:.+)\\.yml"); + //File dataFolder = McmmoCore.getDataFolderPath(); + File dataFolder = mcMMO.p.getDataFolder(); + + for (String fileName : dataFolder.list()) { + //Vanilla Config is already loaded + if(fileName.equalsIgnoreCase(vanillaConfigFileName)) + continue; + + //Find files that match the pattern + if (!pattern.matcher(fileName).matches()) { + continue; + } + + //Init file + File currentFile = new File(dataFolder, fileName); + + //Make sure its not a directory (needed?) + if(currentFile.isDirectory()) + continue; + + try { + //TODO: Valid? + ConfigCollections customConfig = (ConfigCollections) getConfigClass(configPrefix).getConstructor(String.class).newInstance(configPrefix); + collection.addAll(customConfig.getLoadedCollection()); + + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + } + } + + private String getVanillaConfigName(String configPrefix) + { + return configPrefix+DEFAULT_MULTICONFIG_FILENAME_SUFFIX; + } + + private Class getConfigClass(String configPrefix) + { + switch(configPrefix) { + case "repair": + return RepairConfig.class; + case "salvage": + return SalvageConfig.class; + default: + mcMMO.p.getLogger().severe("[DEBUG] Config Class is null!"); + return null; + } + } + +} diff --git a/src/main/java/com/gmail/nossr50/config/collectionconfigs/SalvageConfig.java b/src/main/java/com/gmail/nossr50/config/collectionconfigs/SalvageConfig.java deleted file mode 100644 index 97f429cea..000000000 --- a/src/main/java/com/gmail/nossr50/config/collectionconfigs/SalvageConfig.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.gmail.nossr50.config.collectionconfigs; - -import com.gmail.nossr50.config.ConfigCollection; -import com.gmail.nossr50.config.ConfigConstants; -import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; -import com.gmail.nossr50.datatypes.skills.ItemType; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; -import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory; -import com.gmail.nossr50.util.ItemUtils; -import com.gmail.nossr50.util.skills.SkillUtils; -import ninja.leaping.configurate.ConfigurationNode; -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; - -@ConfigSerializable -public class SalvageConfig extends ConfigCollection { - - public static final String SALVAGEABLES = "Salvageables"; - public static final String MATERIAL_TYPE = "ItemMaterialCategory"; - public static final String SALVAGE_MATERIAL = "SalvageMaterial"; - public static final String MAXIMUM_DURABILITY = "MaximumDurability"; - public static final String ITEM_TYPE = "ItemType"; - public static final String METADATA = "Metadata"; - public static final String MINIMUM_LEVEL = "MinimumLevel"; - public static final String XP_MULTIPLIER = "XpMultiplier"; - public static final String MAXIMUM_QUANTITY = "MaximumQuantity"; - - public SalvageConfig() { - //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false); - super("salvage", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_SKILLS_DIR, true, false, true, false); - register(); - } - - /** - * The version of this config - * - * @return - */ - @Override - public double getConfigVersion() { - return 1; - } - - @Override - public void register() { - //Grab the "keys" under the Repairables node - ArrayList salvageChildrenNodes = new ArrayList<>(getChildren(SALVAGEABLES)); - - for (ConfigurationNode salvageChildNode : salvageChildrenNodes) { - // Validate all the things! - List errorMessages = new ArrayList(); - - // ItemStack Material - String salvageChildNodeName = salvageChildNode.getString(); - Material itemMaterial = Material.matchMaterial(salvageChildNodeName); - - if (itemMaterial == null) { - errorMessages.add("Salvage Config: Invalid material - " + salvageChildNodeName); - continue; - } - - // Salvage Material Type - ItemMaterialCategory salvageItemMaterialCategory = ItemMaterialCategory.OTHER; - - String salvageMaterialTypeString; - - if(hasNode(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE)) - salvageMaterialTypeString = getStringValue(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE); - else - salvageMaterialTypeString = "OTHER"; - - if (!hasNode(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE)) { - ItemStack salvageItem = new ItemStack(itemMaterial); - - if (ItemUtils.isWoodTool(salvageItem)) { - salvageItemMaterialCategory = ItemMaterialCategory.WOOD; - } else if (ItemUtils.isStoneTool(salvageItem)) { - salvageItemMaterialCategory = ItemMaterialCategory.STONE; - } else if (ItemUtils.isStringTool(salvageItem)) { - salvageItemMaterialCategory = ItemMaterialCategory.STRING; - } else if (ItemUtils.isLeatherArmor(salvageItem)) { - salvageItemMaterialCategory = ItemMaterialCategory.LEATHER; - } else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) { - salvageItemMaterialCategory = ItemMaterialCategory.IRON; - } else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) { - salvageItemMaterialCategory = ItemMaterialCategory.GOLD; - } else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) { - salvageItemMaterialCategory = ItemMaterialCategory.DIAMOND; - } - } else { - try { - salvageItemMaterialCategory = ItemMaterialCategory.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase()); - } catch (IllegalArgumentException ex) { - errorMessages.add("Salvage Config: " + salvageChildNodeName + " has an invalid ItemMaterialCategory of " + salvageMaterialTypeString); - } - } - - // Salvage Material - String salvageMaterialName = getStringValue(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL); - Material salvageMaterial = (salvageMaterialName == null ? salvageItemMaterialCategory.getDefaultMaterial() : Material.matchMaterial(salvageMaterialName)); - - if (salvageMaterial == null) { - errorMessages.add(salvageChildNodeName + " has an invalid salvage material: " + salvageMaterialName); - continue; - } - - // Maximum Durability - short maximumDurability = itemMaterial.getMaxDurability(); - - // ItemStack Type - ItemType salvageItemType = ItemType.OTHER; - - String salvageItemTypeString; - - if(hasNode(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE)) - salvageItemTypeString = getStringValue(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE); - else - salvageItemTypeString = "OTHER"; - - if (!hasNode(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE)) { - ItemStack salvageItem = new ItemStack(itemMaterial); - - if (ItemUtils.isMinecraftTool(salvageItem)) { - salvageItemType = ItemType.TOOL; - } else if (ItemUtils.isArmor(salvageItem)) { - salvageItemType = ItemType.ARMOR; - } - } else { - try { - salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase()); - } catch (IllegalArgumentException ex) { - errorMessages.add("Salvage Config: " + salvageChildNodeName + " has an invalid " + ITEM_TYPE + " of " + salvageItemTypeString); - } - } - - byte salvageMetadata = -1; - - if(hasNode(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL, METADATA)) - salvageMetadata = (byte) getIntValue(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL, METADATA); - - int minimumLevel = getIntValue(SALVAGEABLES, salvageChildNodeName, MINIMUM_LEVEL); - double xpMultiplier = 1; - - if(hasNode(SALVAGEABLES, salvageChildNodeName, XP_MULTIPLIER)) - xpMultiplier = getDoubleValue(SALVAGEABLES, salvageChildNodeName, XP_MULTIPLIER); - - // Maximum Quantity - int maximumQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata); - - if(hasNode(SALVAGEABLES, salvageChildNodeName, MAXIMUM_QUANTITY)) - maximumQuantity = getIntValue(SALVAGEABLES, salvageChildNodeName, MAXIMUM_QUANTITY); - - - /* - * VALIDATE - */ - - if(minimumLevel < 0) - minimumLevel = 0; - - if(maximumQuantity < 0) - maximumQuantity = 1; - - if(xpMultiplier < 0) - xpMultiplier = 0; - - Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageItemMaterialCategory, xpMultiplier); - genericCollection.add(salvageable); - - for (String issue : errorMessages) { - mcMMO.p.getLogger().warning(issue); - } - } - } - -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java b/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java index a6d645f39..dae8f3d50 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java +++ b/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.experience; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import java.util.concurrent.Delayed; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java index 1f522679a..cea784b81 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.skills.alchemy; -import com.gmail.nossr50.config.skills.alchemy.PotionConfig; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -123,7 +122,7 @@ public class AlchemyPotion { if (!children.isEmpty()) { for (Entry child : children.entrySet()) { if (ingredient.isSimilar(child.getKey())) { - return PotionConfig.getInstance().getPotion(child.getValue()); + return PotionMainConfig.getInstance().getPotion(child.getValue()); } } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/AbstractSubSkill.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/AbstractSubSkill.java index 2e7c9a1f5..95f54c7c3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/AbstractSubSkill.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/AbstractSubSkill.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.skills.subskills; -import com.gmail.nossr50.config.CoreSkillsConfig; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Rank; @@ -42,7 +41,7 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S @Override @Deprecated public boolean isEnabled() { //TODO: This might be troublesome... - return CoreSkillsConfig.getInstance().isSkillEnabled(this); + return CoreSkillsMainConfig.getInstance().isSkillEnabled(this); } /** diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java index f818cebba..2496dc57d 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.runnables.database; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index 2290c241b..8192dde8c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.runnables.skills; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.MobHealthbarUtils; diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java index 478957de6..eea778443 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.alchemy; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.AlchemyBrewTask; diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java index 01c8e7665..c4ce49206 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.skills.alchemy; -import com.gmail.nossr50.config.experience.ExperienceConfig; -import com.gmail.nossr50.config.skills.alchemy.PotionConfig; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainSource; import com.gmail.nossr50.datatypes.player.McMMOPlayer; @@ -27,7 +25,7 @@ public class AlchemyManager extends SkillManager { } public List getIngredients() { - return PotionConfig.getInstance().getIngredients(getTier()); + return PotionMainConfig.getInstance().getIngredients(getTier()); } public String getIngredientList() { diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index 9d1f902ca..e9ac85e36 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.alchemy; -import com.gmail.nossr50.config.skills.alchemy.PotionConfig; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion; import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage; @@ -35,7 +34,7 @@ public final class AlchemyPotionBrewer { continue; } - if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) { + if (getChildPotion(PotionMainConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) { return true; } } @@ -93,7 +92,7 @@ public final class AlchemyPotionBrewer { } private static List getValidIngredients(Player player) { - return PotionConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); + return PotionMainConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); } public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) { @@ -113,11 +112,11 @@ public final class AlchemyPotionBrewer { for (int i = 0; i < 3; i++) { ItemStack item = inventory.getItem(i); - if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionConfig.getInstance().isValidPotion(item)) { + if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionMainConfig.getInstance().isValidPotion(item)) { continue; } - AlchemyPotion input = PotionConfig.getInstance().getPotion(item); + AlchemyPotion input = PotionMainConfig.getInstance().getPotion(item); AlchemyPotion output = input.getChild(ingredient); inputList.add(input); diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index 25e5d2ec5..7c778760e 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.skills.archery; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.RankUtils; diff --git a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java index 3d508e88a..7a687dd93 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.axes; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.skills.RankUtils; diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index a6e9ac5a5..2dc806063 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.mining; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.util.Misc; import org.bukkit.Material; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java b/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java index f7ea4fd70..efa31d992 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.skills.repair; -import com.gmail.nossr50.config.AdvancedConfig; - public class ArcaneForging { public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled(); diff --git a/src/main/java/com/gmail/nossr50/skills/swords/Swords.java b/src/main/java/com/gmail/nossr50/skills/swords/Swords.java index 4f806077f..e2e26c36f 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/Swords.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/Swords.java @@ -1,8 +1,6 @@ /* package com.gmail.nossr50.skills.swords; -import com.gmail.nossr50.config.AdvancedConfig; - public class Swords { public static int bleedMaxTicks = AdvancedConfig.getInstance().getRuptureMaxTicks(); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java index 1313c4c46..c87afa464 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.taming; -import com.gmail.nossr50.config.AdvancedConfig; import org.bukkit.EntityEffect; import org.bukkit.entity.*; diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index af30a24c6..57b3f8122 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.unarmed; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java index e21843c8a..655c2030b 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.experience; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask; diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java index 9fcad6fbb..94c9d4f01 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.experience; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.locale.LocaleLoader; diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index 3558bf5e7..46405089d 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.player; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; diff --git a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java index 6bb213c5e..5af6caefc 100644 --- a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java +++ b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.random; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 3ac1a8750..b45ffd19a 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.skills; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; diff --git a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java index 1247c8272..501aa7e69 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.skills; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.util.Permissions; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java index b5df535a0..50476d0e3 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.skills; -import com.gmail.nossr50.config.RankConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; diff --git a/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java b/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java index 73a4905e1..73a8d6147 100644 --- a/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java +++ b/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.sounds; -import com.gmail.nossr50.config.SoundConfig; import com.gmail.nossr50.util.Misc; import org.bukkit.Location; import org.bukkit.Sound; @@ -15,13 +14,13 @@ public class SoundManager { */ public static void sendSound(Player player, Location location, SoundType soundType) { - if(SoundConfig.getInstance().getIsEnabled(soundType)) + if(SoundMainConfig.getInstance().getIsEnabled(soundType)) player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType)); } public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) { - if(SoundConfig.getInstance().getIsEnabled(soundType)) + if(SoundMainConfig.getInstance().getIsEnabled(soundType)) player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType)); } @@ -29,13 +28,13 @@ public class SoundManager { { float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier)); - if(SoundConfig.getInstance().getIsEnabled(soundType)) + if(SoundMainConfig.getInstance().getIsEnabled(soundType)) player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch); } public static void worldSendSound(World world, Location location, SoundType soundType) { - if(SoundConfig.getInstance().getIsEnabled(soundType)) + if(SoundMainConfig.getInstance().getIsEnabled(soundType)) world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType)); } @@ -46,7 +45,7 @@ public class SoundManager { */ private static float getVolume(SoundType soundType) { - return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance().getMasterVolume(); + return SoundMainConfig.getInstance().getVolume(soundType) * SoundMainConfig.getInstance().getMasterVolume(); } private static float getPitch(SoundType soundType) @@ -56,7 +55,7 @@ public class SoundManager { else if (soundType == SoundType.POP) return getPopPitch(); else - return SoundConfig.getInstance().getPitch(soundType); + return SoundMainConfig.getInstance().getPitch(soundType); } private static Sound getSound(SoundType soundType)