DynamicSettingsManager - Handles platform specific datasets

Converts datasets from the config into ready to use platform specific
ones
Currently only supports Bukkit, that will change later
Expect API breakages if you hook into this class
This commit is contained in:
nossr50
2019-05-13 00:53:29 -07:00
parent d614df65a7
commit 72fc3efa78
27 changed files with 177 additions and 312 deletions

View File

@@ -1,76 +0,0 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import java.util.HashMap;
import java.util.List;
/**
* Manages a collection of whitelisted materials for Double Drops
*/
public class BonusDropManager implements Unload {
private HashMap<Material, Boolean> bonusDropWhitelist;
public BonusDropManager() {
bonusDropWhitelist = new HashMap<>();
//Start by setting all Materials to false to avoid null checks
for (Material material : Material.values()) {
registerMaterial(material, false);
}
}
@Override
public void unload() {
bonusDropWhitelist.clear();
}
/**
* Adds materials to the bonus drop whitelist
*
* @param materials target material list
*/
public void addToWhitelistByMaterial(List<Material> materials) {
for (Material material : materials) {
registerMaterial(material, true);
}
}
/**
* Adds materials to the bonus drop whitelist
*
* @param materials target material list
*/
public void addToWhitelistByNameID(List<String> materials) {
for (String material : materials) {
Material m = Material.matchMaterial(material);
if (m == null) {
mcMMO.p.getLogger().severe("Error registering Bonus Drop -- Invalid Minecraft Name ID: " + material);
continue;
}
registerMaterial(m, true);
}
}
/**
* Adds a material to the bonus drop whitelist
*
* @param material target material
*/
private void registerMaterial(Material material, boolean isWhitelisted) {
bonusDropWhitelist.put(material, isWhitelisted);
}
/**
* Check if a material can provide bonus drops
*
* @param material target material
* @return true if the material can provide bonus drops
*/
public boolean isBonusDropWhitelisted(Material material) {
return bonusDropWhitelist.get(material);
}
}

View File

@@ -1,38 +0,0 @@
package com.gmail.nossr50.config;
/**
* This class is used to define settings for upgrading EXTREMELY OLD versions of mcMMO to newer versions
* It could probably be deleted
*/
public class ChunkConversionOptions {
private static final boolean chunkletsEnabled = true;
private static final int conversionRate = 1;
private static final boolean useEnchantmentBuffs = true;
private static final int uuidConvertAmount = 5;
private static final int mojangRateLimit = 50000;
private static final long mojangLimitPeriod = 600000;
public static boolean getChunkletsEnabled() {
return chunkletsEnabled;
}
public static int getConversionRate() {
return conversionRate;
}
public static boolean useEnchantmentBuffs() {
return useEnchantmentBuffs;
}
public static int getUUIDConvertAmount() {
return uuidConvertAmount;
}
public static int getMojangRateLimit() {
return mojangRateLimit;
}
public static long getMojangLimitPeriod() {
return mojangLimitPeriod;
}
}

View File

@@ -1,49 +0,0 @@
package com.gmail.nossr50.config;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
/**
* Represents a config file that registers keys after its initialized
*/
public abstract class ConfigCollection<T> extends Config implements Registers, GenericCollectionContainer {
//The collection held by this class
protected Collection<T> genericCollection;
/**
* @param pathToParentFolder Path to the "parent" folder on disk
* @param relativePath Path to the config relative to the "parent" folder, this should mirror internal structure of resource files
* @param mergeNewKeys if true, the users config will add keys found in the internal file that are missing from the users file during load
* @param copyDefaults if true, the users config file when it is first made will be a copy of an internal resource file of the same name and path
* @param removeOldKeys if true, the users config file will have keys not found in the internal default resource file of the same name and path removed
*/
public ConfigCollection(String fileName, File pathToParentFolder, String relativePath, boolean generateDefaults, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
super(fileName, pathToParentFolder, relativePath, generateDefaults, mergeNewKeys, copyDefaults, removeOldKeys);
//init
initCollection();
//DO NOT CALL THIS HERE
//register();
}
/**
* Initializes the generic collection held by this class
*/
private void initCollection() {
if (genericCollection == null)
genericCollection = new ArrayList<>();
}
@Override
public Collection<T> getLoadedCollection() {
return this.genericCollection;
}
@Override
public void unload() {
genericCollection.clear();
}
}

View File

@@ -47,13 +47,9 @@ import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
import com.gmail.nossr50.util.experience.ExperienceMapManager;
import com.google.common.collect.Maps;
import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializerCollection;
@@ -67,32 +63,15 @@ import java.util.HashMap;
/**
* The Config Manager handles initializing, loading, and unloading registers for all configs that mcMMO uses
* This makes sure that mcMMO properly loads and unloads its values on reload
* <p>
* Config Manager also holds all of our MultiConfigContainers
* Settings in configs are sometimes not platform-ready, you can find platform ready implementations in the {@link com.gmail.nossr50.core.DynamicSettingsManager DynamicSettingsManager}
*/
public final class ConfigManager {
/* UNLOAD REGISTER */
private SkillPropertiesManager skillPropertiesManager;
private ArrayList<Unload> unloadables;
/* COLLECTION MANAGERS */
/* File array - Used for backups */
private ArrayList<File> userFiles;
private RepairableManager repairableManager;
private SalvageableManager salvageableManager;
/* CUSTOM SERIALIZERS */
private BonusDropManager bonusDropManager;
/* MOD MANAGERS */
//TODO: Add these back when modded servers become a thing again
/* MISC MANAGERS */
/* Custom Serialization */
private TypeSerializerCollection customSerializers;
private ExperienceMapManager experienceMapManager;
// private PotionManager potionManager;
/* CONFIG INSTANCES */
@@ -134,7 +113,6 @@ public final class ConfigManager {
private ConfigSmelting configSmelting;
private ConfigSalvage configSalvage;
private HashMap<PrimarySkillType, SerializedConfigLoader<?>> skillConfigLoaders;
//Data
@@ -160,7 +138,6 @@ public final class ConfigManager {
private ArrayList<String> configErrors; //Collect errors to whine about to server admins
public ConfigManager() {
unloadables = new ArrayList<>();
userFiles = new ArrayList<>();
}
@@ -174,24 +151,12 @@ public final class ConfigManager {
//Serialized Data
initSerializedDataFiles();
//Skill Property Registers
skillPropertiesManager = new SkillPropertiesManager();
skillPropertiesManager.fillRegisters();
//Assign Maps
partyItemWeights = Maps.newHashMap(configParty.getConfig().getPartyItemShare().getItemShareMap()); //Item Share Weights
partyFeatureUnlocks = Maps.newHashMap(configParty.getConfig().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression
//YAML Configs
initYAMLConfigs();
/*
* Managers
*/
// Register Managers
initMiscManagers();
initCollectionManagers();
}
private void initYAMLConfigs() {
@@ -323,79 +288,6 @@ public final class ConfigManager {
skillConfigLoaders.put(primarySkillType, SkillConfigFactory.initSkillConfig(primarySkillType, clazz));
}
/**
* Misc managers
*/
private void initMiscManagers() {
experienceMapManager = new ExperienceMapManager();
//Set the global XP val
experienceMapManager.setGlobalXpMult(getConfigExperience().getGlobalXPMultiplier());
experienceMapManager.buildBlockXPMaps(); //Block XP value maps
experienceMapManager.fillCombatXPMultiplierMap(getConfigExperience().getCombatExperienceMap());
// potionManager = new PotionManager();
}
/**
* Initializes any managers related to config collections
*/
private void initCollectionManagers() {
// Handles registration of repairables
repairableManager = new RepairableManager(getRepairables());
unloadables.add(repairableManager);
// Handles registration of salvageables
salvageableManager = new SalvageableManager(getSalvageables());
unloadables.add(salvageableManager);
// Handles registration of bonus drops
bonusDropManager = new BonusDropManager();
unloadables.add(bonusDropManager);
//Register Bonus Drops
registerBonusDrops();
}
/**
* Get all loaded repairables (loaded from all repairable configs)
*
* @return the currently loaded repairables
*/
public ArrayList<Repairable> getRepairables() {
return getConfigRepair().getConfigRepairablesList();
}
/**
* Get all loaded salvageables (loaded from all salvageable configs)
*
* @return the currently loaded salvageables
*/
public ArrayList<Salvageable> getSalvageables() {
return getConfigSalvage().getConfigSalvageablesList();
}
/**
* Unloads all config options (prepares for reload)
*/
public void unloadAllConfigsAndRegisters() {
//Unload
for (Unload unloadable : unloadables) {
unloadable.unload();
}
//Clear
unloadables.clear();
userFiles.clear();
}
/**
* Registers an unloadable
* Unloadables call unload() on plugin disable to cleanup registries
*/
public void registerUnloadable(Unload unload) {
if (!unloadables.contains(unload))
unloadables.add(unload);
}
/**
* Registers an unloadable
* Unloadables call unload() on plugin disable to cleanup registries
@@ -405,15 +297,6 @@ public final class ConfigManager {
userFiles.add(userFile);
}
/**
* Registers bonus drops from several skill configs
*/
public void registerBonusDrops() {
bonusDropManager.addToWhitelistByNameID(getConfigMining().getBonusDrops());
// bonusDropManager.addToWhitelistByNameID(configHerbalism.getBonusDrops());
// bonusDropManager.addToWhitelistByNameID(configWoodcutting.getBonusDrops());
}
public void validateConfigs() {
}
@@ -424,7 +307,6 @@ public final class ConfigManager {
*/
public void reloadConfigs() {
mcMMO.p.getLogger().info("Reloading config values...");
unloadAllConfigsAndRegisters(); //Unload Everything
loadConfigs(); //Load everything again
}
@@ -441,14 +323,6 @@ public final class ConfigManager {
return userFiles;
}
public RepairableManager getRepairableManager() {
return repairableManager;
}
public SalvageableManager getSalvageableManager() {
return salvageableManager;
}
public MainConfig getMainConfig() {
return mainConfig;
}
@@ -489,10 +363,6 @@ public final class ConfigManager {
return experienceConfig;
}
public ExperienceMapManager getExperienceMapManager() {
return experienceMapManager;
}
public ConfigDatabase getConfigDatabase() {
return configDatabase.getConfig();
}
@@ -637,10 +507,6 @@ public final class ConfigManager {
return configSalvage;
}
public BonusDropManager getBonusDropManager() {
return bonusDropManager;
}
/**
* Checks if this plugin is using retro mode
* Retro mode is a 0-1000 skill system
@@ -652,23 +518,7 @@ public final class ConfigManager {
return getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled();
}
public boolean isBonusDropsEnabled(Material material) {
return getBonusDropManager().isBonusDropWhitelisted(material);
}
public double getSkillMaxBonusLevel(SubSkillType subSkillType) {
return skillPropertiesManager.getMaxBonusLevel(subSkillType);
}
public double getSkillMaxChance(SubSkillType subSkillType) {
return skillPropertiesManager.getMaxChance(subSkillType);
}
public ConfigExperience getConfigExperience() {
return configExperience.getConfig();
}
public SkillPropertiesManager getSkillPropertiesManager() {
return skillPropertiesManager;
}
}

View File

@@ -1,17 +0,0 @@
package com.gmail.nossr50.config;
import java.util.Collection;
/**
* Represents a class that contains a generic collection
*
* @param <T>
*/
public interface GenericCollectionContainer<T> {
/**
* Grab the collection held by this class
*
* @return the collection held by this class
*/
Collection<T> getLoadedCollection();
}

View File

@@ -1,11 +0,0 @@
package com.gmail.nossr50.config;
/**
* A class that is expected to register one thing into another thing
*/
public interface Registers extends Unload {
/**
* Register stuff
*/
void register();
}

View File

@@ -1,11 +0,0 @@
package com.gmail.nossr50.config;
/**
* A class that registers keys
*/
public interface RegistersKeys {
/**
* Loads up keys
*/
void loadKeys();
}

View File

@@ -1,50 +0,0 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.config.hocon.skills.ConfigSubSkillScalingRNG;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import java.util.HashMap;
/**
* Hacky way to do this until I rewrite the skill system fully
*/
public class SkillPropertiesManager {
private HashMap<SubSkillType, Double> maxChanceMap;
private HashMap<SubSkillType, Double> maxBonusLevelMap;
private HashMap<SubSkillType, Double> maxBonusPercentage;
public SkillPropertiesManager() {
maxChanceMap = new HashMap<>();
maxBonusLevelMap = new HashMap<>();
maxBonusPercentage = new HashMap<>();
}
public void registerRNG(SubSkillType subSkillType, ConfigSubSkillScalingRNG config) {
maxChanceMap.put(subSkillType, config.getMaxChance());
maxBonusLevelMap.put(subSkillType, config.getMaxBonusLevel());
}
public double getMaxChance(SubSkillType subSkillType) {
return maxChanceMap.get(subSkillType);
}
public double getMaxBonusLevel(SubSkillType subSkillType) {
return maxBonusLevelMap.get(subSkillType);
}
public void fillRegisters() {
fillRNGRegisters();
}
private void fillRNGRegisters() {
//Acrobatics
registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getDodge().getRNGSettings());
registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getRoll().getRNGSettings());
//Repair
registerRNG(SubSkillType.REPAIR_SUPER_REPAIR, mcMMO.getConfigManager().getConfigRepair().getSuperRepair().getSuperRepair());
}
}

View File

@@ -1,31 +0,0 @@
//package com.gmail.nossr50.config.mods;
//
//public class ArmorConfigManager {
// //TODO: Commented out until modded servers appear again
// /*public ArmorConfigManager() {
// Pattern middlePattern = Pattern.compile("armor\\.(?:.+)\\.yml");
// Pattern startPattern = Pattern.compile("(?:.+)\\.armor\\.yml");
// //File dataFolder = new File(McmmoCore.getModDataFolderPath());
// File dataFolder = new File(mcMMO.p.getModDirectory());
// File vanilla = new File(dataFolder, "armor.default.yml");
// ModManager modManager = mcMMO.getModManager();
//
// if (!vanilla.exists()) {
// mcMMO.p.saveResource(vanilla.getParentFile().getName() + File.separator + "armor.default.yml", false);
// }
//
// for (String fileName : dataFolder.list()) {
// if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
// continue;
// }
//
// File file = new File(dataFolder, fileName);
//
// if (file.isDirectory()) {
// continue;
// }
//
// modManager.registerCustomArmor(new CustomArmorConfig(fileName));
// }
// }*/
//}

View File

@@ -1,31 +0,0 @@
//package com.gmail.nossr50.config.mods;
//
//public class BlockConfigManager {
// //TODO: Commented out until modded servers appear again
// /*public BlockConfigManager() {
// Pattern middlePattern = Pattern.compile("blocks\\.(?:.+)\\.yml");
// Pattern startPattern = Pattern.compile("(?:.+)\\.blocks\\.yml");
// //File dataFolder = new File(McmmoCore.getModDataFolderPath());
// File dataFolder = new File(mcMMO.getModDirectory());
// File vanilla = new File(dataFolder, "blocks.default.yml");
// ModManager modManager = mcMMO.getModManager();
//
// if (!vanilla.exists()) {
// mcMMO.p.saveResource(vanilla.getParentFile().getName() + File.separator + "blocks.default.yml", false);
// }
//
// for (String fileName : dataFolder.list()) {
// if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
// continue;
// }
//
// File file = new File(dataFolder, fileName);
//
// if (file.isDirectory()) {
// continue;
// }
//
// modManager.registerCustomBlocks(new CustomBlockConfig(fileName));
// }
// }*/
//}

View File

@@ -1,111 +0,0 @@
//package com.gmail.nossr50.config.mods;
//
//import com.gmail.nossr50.config.ConfigCollection;
//import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.skills.repair.repairables.Repairable;
//import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
//import com.gmail.nossr50.util.skills.SkillUtils;
//import org.bukkit.Material;
//import org.bukkit.configuration.ConfigurationSection;
//import org.bukkit.inventory.ItemStack;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Set;
//
//public class CustomArmorConfig extends ConfigCollection {
// public List<Material> customBoots = new ArrayList<Material>();
// public List<Material> customChestplates = new ArrayList<Material>();
// public List<Material> customHelmets = new ArrayList<Material>();
// public List<Material> customLeggings = new ArrayList<Material>();
// public List<Repairable> repairables = new ArrayList<Repairable>();
// private boolean needsUpdate = false;
//
// protected CustomArmorConfig(String fileName) {
// //super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false);
// super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false); register();
// }
//
// /**
// * The version of this config
// *
// * @return
// */
// @Override
// public double getConfigVersion() {
// return 1;
// }
//
// @Override
// public void register() {
// loadArmor("Boots", customBoots);
// loadArmor("Chestplates", customChestplates);
// loadArmor("Helmets", customHelmets);
// loadArmor("Leggings", customLeggings);
//
// if (needsUpdate) {
// needsUpdate = false;
// backup();
// }
// }
//
// private void loadArmor(String armorType, List<Material> materialList) {
// if (needsUpdate) {
// return;
// }
//
// ConfigurationSection armorSection = config.getConfigurationSection(armorType);
//
// if (armorSection == null) {
// return;
// }
//
// Set<String> armorConfigSet = armorSection.getKeys(false);
//
// for (String armorName : armorConfigSet) {
// if (config.contains(armorType + "." + armorName + "." + ".ID")) {
// needsUpdate = true;
// return;
// }
//
// Material armorMaterial = Material.matchMaterial(armorName);
//
// if (armorMaterial == null) {
// plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + armorName);
// continue;
// }
//
// boolean repairable = getBooleanValue(armorType + "." + armorName + ".Repairable");
// Material repairMaterial = Material.matchMaterial(getStringValue(armorType + "." + armorName + ".Repair_Material", ""));
//
// if (repairable && (repairMaterial == null)) {
// plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + armorName);
// repairable = false;
// }
//
// if (repairable) {
// byte repairData = (byte) getIntValue(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
// int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
//
// if (repairQuantity == 0) {
// repairQuantity = getIntValue(armorType + "." + armorName + ".Repair_Material_Quantity", 2);
// }
//
// String repairItemName = getStringValue(armorType + "." + armorName + ".Repair_Material_Pretty_Name");
// int repairMinimumLevel = getIntValue(armorType + "." + armorName + ".Repair_MinimumLevel", 0);
// double repairXpMultiplier = getDoubleValue(armorType + "." + armorName + ".Repair_XpMultiplier", 1);
//
// short durability = armorMaterial.getMaxDurability();
//
// if (durability == 0) {
// durability = (short) getIntValue(armorType + "." + armorName + ".Durability", 70);
// }
//
// repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ConfigItemCategory.ARMOR, ItemMaterialCategory.OTHER, repairXpMultiplier));
// }
//
// materialList.add(armorMaterial);
// }
// }
//}

View File

@@ -1,99 +0,0 @@
//package com.gmail.nossr50.config.mods;
//
//import com.gmail.nossr50.config.ConfigCollection;
//import com.gmail.nossr50.datatypes.mods.CustomBlock;
//import com.gmail.nossr50.mcMMO;
//import org.bukkit.Material;
//import org.bukkit.configuration.ConfigurationSection;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Set;
//
//public class CustomBlockConfig extends ConfigCollection {
// public List<Material> customExcavationBlocks = new ArrayList<>();
// public List<Material> customHerbalismBlocks = new ArrayList<>();
// public List<Material> customMiningBlocks = new ArrayList<>();
// public List<Material> customOres = new ArrayList<>();
// public List<Material> customLogs = new ArrayList<>();
// public List<Material> customLeaves = new ArrayList<>();
// public List<Material> customAbilityBlocks = new ArrayList<>();
// public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
// private boolean needsUpdate = false;
//
// protected CustomBlockConfig(String fileName) {
// //super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false);
// super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false);
// register();
// }
//
// @Override
// protected void register() {
// loadBlocks("Excavation", customExcavationBlocks);
// loadBlocks("Herbalism", customHerbalismBlocks);
// loadBlocks("Mining", customMiningBlocks);
// loadBlocks("Woodcutting", null);
// loadBlocks("Ability_Blocks", customAbilityBlocks);
//
// if (needsUpdate) {
// needsUpdate = false;
// backup();
// }
// }
//
// private void loadBlocks(String skillType, List<Material> blockList) {
// if (needsUpdate) {
// return;
// }
//
// ConfigurationSection skillSection = config.getConfigurationSection(skillType);
//
// if (skillSection == null) {
// return;
// }
//
// Set<String> skillConfigSet = skillSection.getKeys(false);
//
// for (String blockName : skillConfigSet) {
// if (config.contains(skillType + "." + blockName + ".Drop_Item")) {
// needsUpdate = true;
// return;
// }
//
// String[] blockInfo = blockName.split("[|]");
//
// Material blockMaterial = Material.matchMaterial(blockInfo[0]);
//
// if (blockMaterial == null) {
// plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
// continue;
// }
//
// if (blockList != null) {
// blockList.add(blockMaterial);
// }
//
// if (skillType.equals("Ability_Blocks")) {
// continue;
// }
//
// int xp = getIntValue(skillType + "." + blockName + ".XP_Gain");
// int smeltingXp = 0;
//
// if (skillType.equals("Mining") && getBooleanValue(skillType + "." + blockName + ".Is_Ore")) {
// customOres.add(blockMaterial);
// smeltingXp = getIntValue(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
// } else if (skillType.equals("Woodcutting")) {
// if (getBooleanValue(skillType + "." + blockName + ".Is_Log")) {
// customLogs.add(blockMaterial);
// } else {
// customLeaves.add(blockMaterial);
// xp = 0; // Leaves don't grant XP
// }
// }
//
// customBlockMap.put(blockMaterial, new CustomBlock(xp, getBooleanValue(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
// }
// }
//}

View File

@@ -1,63 +0,0 @@
//
//package com.gmail.nossr50.config.mods;
//
//import com.gmail.nossr50.config.Config;
//import com.gmail.nossr50.datatypes.mods.CustomEntity;
//import com.gmail.nossr50.mcMMO;
//import org.apache.commons.lang.ClassUtils;
//import org.bukkit.Material;
//import org.bukkit.inventory.ItemStack;
//
//import java.util.HashMap;
//
//public class CustomEntityConfig extends Config {
// public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
// public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
//
// protected CustomEntityConfig(String fileName) {
// //super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false);
// super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false);
// }
//
// @Override
// protected void loadKeys() {
// if (config.getConfigurationSection("Hostile") != null) {
// backup();
// return;
// }
//
// for (String entityName : config.getKeys(false)) {
// Class<?> clazz = null;
// String className = getStringValue(entityName + ".Class", "");
//
// try {
// clazz = ClassUtils.getClass(className);
// } catch (ClassNotFoundException e) {
// plugin.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
// plugin.getLogger().warning("This custom entity may not function properly.");
// }
//
// String entityTypeName = entityName.replace("_", ".");
// double xpMultiplier = getDoubleValue(entityName + ".XP_Multiplier", 1.0D);
//
// boolean canBeTamed = getBooleanValue(entityName + ".Tameable");
// int tamingXp = getIntValue(entityName + ".Taming_XP");
//
// boolean canBeSummoned = getBooleanValue(entityName + ".CanBeSummoned");
// Material callOfTheWildMaterial = Material.matchMaterial(getStringValue(entityName + ".COTW_Material", ""));
// byte callOfTheWildData = (byte) getIntValue(entityName + ".COTW_Material_Data");
// int callOfTheWildAmount = getIntValue(entityName + ".COTW_Material_Amount");
//
// if (canBeSummoned && (callOfTheWildMaterial == null || callOfTheWildAmount == 0)) {
// plugin.getLogger().warning("Incomplete Call of the Wild information. This entity will not be able to be summoned by Call of the Wild.");
// canBeSummoned = false;
// }
//
// CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new ItemStack(callOfTheWildMaterial) : null), callOfTheWildAmount);
//
// customEntityTypeMap.put(entityTypeName, entity);
// customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
// }
// }
//}
//*/

View File

@@ -1,102 +0,0 @@
package com.gmail.nossr50.config.mods;
/*
public class CustomToolConfig extends Config {
//TODO: Disabled until modded servers come back
public List<Material> customAxes = new ArrayList<Material>();
public List<Material> customBows = new ArrayList<Material>();
public List<Material> customHoes = new ArrayList<Material>();
public List<Material> customPickaxes = new ArrayList<Material>();
public List<Material> customShovels = new ArrayList<Material>();
public List<Material> customSwords = new ArrayList<Material>();
public HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
public List<Repairable> repairables = new ArrayList<Repairable>();
private boolean needsUpdate = false;
protected CustomToolConfig(String fileName) {
//super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false);
super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false);
loadKeys();
}
@Override
protected void loadKeys() {
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadTool(String toolType, List<Material> materialList) {
if (needsUpdate) {
return;
}
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
if (toolSection == null) {
return;
}
Set<String> toolConfigSet = toolSection.getKeys(false);
for (String toolName : toolConfigSet) {
if (config.contains(toolType + "." + toolName + "." + ".ID")) {
needsUpdate = true;
return;
}
Material toolMaterial = Material.matchMaterial(toolName);
if (toolMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + toolName);
continue;
}
boolean repairable = getBooleanValue(toolType + "." + toolName + ".Repairable");
Material repairMaterial = Material.matchMaterial(getStringValue(toolType + "." + toolName + ".Repair_Material", ""));
if (repairable && (repairMaterial == null)) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + toolName);
repairable = false;
}
if (repairable) {
byte repairData = (byte) getIntValue(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
if (repairQuantity == 0) {
repairQuantity = getIntValue(toolType + "." + toolName + ".Repair_Material_Quantity", 2);
}
String repairItemName = getStringValue(toolType + "." + toolName + ".Repair_Material_Pretty_Name");
int repairMinimumLevel = getIntValue(toolType + "." + toolName + ".Repair_MinimumLevel", 0);
double repairXpMultiplier = getDoubleValue(toolType + "." + toolName + ".Repair_XpMultiplier", 1);
short durability = toolMaterial.getMaxDurability();
if (durability == 0) {
durability = (short) getIntValue(toolType + "." + toolName + ".Durability", 60);
}
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.TOOL, ItemMaterialCategory.OTHER, repairXpMultiplier));
}
double multiplier = getDoubleValue(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = getBooleanValue(toolType + "." + toolName + ".Ability_Enabled", true);
int tier = getIntValue(toolType + "." + toolName + ".Tier", 1);
CustomTool tool = new CustomTool(tier, abilityEnabled, multiplier);
materialList.add(toolMaterial);
customToolMap.put(toolMaterial, tool);
}
}
}*/

View File

@@ -1,35 +0,0 @@
/*
package com.gmail.nossr50.config.mods;
public class EntityConfigManager {
//TODO: Commented out until modded servers appear again
*/
/*public EntityConfigManager(mcMMO plugin) {
Pattern middlePattern = Pattern.compile("entities\\.(?:.+)\\.yml");
Pattern startPattern = Pattern.compile("(?:.+)\\.entities\\.yml");
File dataFolder = new File(mcMMO.getModDirectory());
File vanilla = new File(dataFolder, "entities.default.yml");
ModManager modManager = mcMMO.getModManager();
if (!vanilla.exists()) {
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "entities.default.yml", false);
}
for (String fileName : dataFolder.list()) {
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
continue;
}
File file = new File(dataFolder, fileName);
if (file.isDirectory()) {
continue;
}
modManager.registerCustomEntities(new CustomEntityConfig(fileName));
}
}*//*
}
*/

View File

@@ -1,35 +0,0 @@
/*
package com.gmail.nossr50.config.mods;
public class ToolConfigManager {
//TODO: Commented out until modded servers appear again
*/
/*public ToolConfigManager(mcMMO plugin) {
Pattern middlePattern = Pattern.compile("tools\\.(?:.+)\\.yml");
Pattern startPattern = Pattern.compile("(?:.+)\\.tools\\.yml");
File dataFolder = new File(mcMMO.getModDirectory());
File vanilla = new File(dataFolder, "tools.default.yml");
ModManager modManager = mcMMO.getModManager();
if (!vanilla.exists()) {
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "tools.default.yml", false);
}
for (String fileName : dataFolder.list()) {
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
continue;
}
File file = new File(dataFolder, fileName);
if (file.isDirectory()) {
continue;
}
modManager.registerCustomTools(new CustomToolConfig(fileName));
}
}*//*
}
*/

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.config.treasure;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.config.Registers;
import com.gmail.nossr50.config.UnsafeValueValidation;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.mcMMO;

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.config.treasure;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.config.Registers;
import com.gmail.nossr50.config.UnsafeValueValidation;
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.config.treasure;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.config.Registers;
import com.gmail.nossr50.config.UnsafeValueValidation;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.mcMMO;