mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
setup typed references to skill configs
This commit is contained in:
parent
42a7673ad7
commit
81d648f94d
@ -113,8 +113,6 @@ public final class ConfigManager {
|
||||
private SerializedConfigLoader<ConfigAdmin> configAdmin;
|
||||
private SerializedConfigLoader<ConfigMobs> configMobs;
|
||||
|
||||
private HashMap<PrimarySkillType, SerializedConfigLoader> skillConfigLoaders;
|
||||
|
||||
private SerializedConfigLoader<ConfigAcrobatics> configAcrobatics;
|
||||
private SerializedConfigLoader<ConfigAlchemy> configAlchemy;
|
||||
private SerializedConfigLoader<ConfigArchery> configArchery;
|
||||
@ -131,16 +129,20 @@ public final class ConfigManager {
|
||||
private SerializedConfigLoader<ConfigSmelting> configSmelting;
|
||||
private SerializedConfigLoader<ConfigSalvage> configSalvage;
|
||||
|
||||
private HashMap<PrimarySkillType, SerializedConfigLoader> skillConfigLoaders;
|
||||
|
||||
//Data
|
||||
private SerializedConfigLoader<ConfigPartyData> partyData;
|
||||
|
||||
//YAML CONFIGS
|
||||
private PotionConfig potionConfig;
|
||||
|
||||
private MainConfig mainConfig;
|
||||
private FishingTreasureConfig fishingTreasureConfig;
|
||||
private ExcavationTreasureConfig excavationTreasureConfig;
|
||||
private HerbalismTreasureConfig herbalismTreasureConfig;
|
||||
private ExperienceConfig experienceConfig;
|
||||
private AdvancedConfig advancedConfig;
|
||||
private PotionConfig potionConfig;
|
||||
private CoreSkillsConfig coreSkillsConfig;
|
||||
private SoundConfig soundConfig;
|
||||
private RankConfig rankConfig;
|
||||
@ -160,12 +162,111 @@ public final class ConfigManager {
|
||||
|
||||
public void loadConfigs()
|
||||
{
|
||||
// Load Config Files
|
||||
// I'm pretty these are supposed to be done in a specific order, so don't rearrange them willy nilly
|
||||
|
||||
//Register Custom Serializers
|
||||
mcMMO.p.getLogger().info("Registering custom type serializers with Configurate...");
|
||||
registerCustomTypeSerializers();
|
||||
|
||||
//Serialized Configs
|
||||
initSerializedConfigs();
|
||||
|
||||
//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
|
||||
|
||||
//Register Bonus Drops
|
||||
registerBonusDrops();
|
||||
|
||||
//YAML Configs
|
||||
initYAMLConfigs();
|
||||
|
||||
/*
|
||||
* Managers
|
||||
*/
|
||||
|
||||
// Register Managers
|
||||
initMiscManagers();
|
||||
initCollectionManagers();
|
||||
}
|
||||
|
||||
private void initYAMLConfigs() {
|
||||
potionConfig = new PotionConfig();
|
||||
}
|
||||
|
||||
private void initSerializedDataFiles() {
|
||||
partyData = new SerializedConfigLoader<>(ConfigPartyData.class, "partydata.conf", "PartyData", null);
|
||||
}
|
||||
|
||||
private void initSerializedConfigs() {
|
||||
configDatabase = new SerializedConfigLoader<>(ConfigDatabase.class, "database_settings.conf", "Database", null);
|
||||
configScoreboard = new SerializedConfigLoader<>(ConfigScoreboard.class, "scoreboard.conf", "Scoreboard", null);
|
||||
configLeveling = new SerializedConfigLoader<>(ConfigLeveling.class, "player_leveling.conf", "Player-Leveling", null);
|
||||
configWorldBlacklist = new SerializedConfigLoader<>(ConfigWorldBlacklist.class, "world_blacklist.conf", "World-Blacklist", null);
|
||||
configExploitPrevention = new SerializedConfigLoader<>(ConfigExploitPrevention.class, "anti_exploit.conf", "Anti-Exploit", null);
|
||||
configMOTD = new SerializedConfigLoader<>(ConfigMOTD.class, "message_of_the_day.conf", "MOTD", null);
|
||||
configHardcore = new SerializedConfigLoader<>(ConfigHardcore.class, "hardcore_mode.conf", "Hardcore-Mode", null);
|
||||
configMetrics = new SerializedConfigLoader<>(ConfigMetrics.class, "analytics_reporting.conf", "Analytic-Reporting", null);
|
||||
configAuthorAdvertisements = new SerializedConfigLoader<>(ConfigAuthorAdvertisements.class, "author_support_advertisements.conf", "mcMMO", null);
|
||||
configAutomatedBackups = new SerializedConfigLoader<>(ConfigAutomatedBackups.class, "automated_backups.conf", "Automated-Backups", null);
|
||||
configCommands = new SerializedConfigLoader<>(ConfigCommands.class, "commands.conf", "Commands", null);
|
||||
configItems = new SerializedConfigLoader<>(ConfigItems.class, "custom_items.conf", "Items", null);
|
||||
configLanguage = new SerializedConfigLoader<>(ConfigLanguage.class, "language.conf", "Language", null);
|
||||
configParticles = new SerializedConfigLoader<>(ConfigParticles.class, "particle_spawning.conf", "Particles", null);
|
||||
configParty = new SerializedConfigLoader<>(ConfigParty.class, "party.conf", "Party", null);
|
||||
configNotifications = new SerializedConfigLoader<>(ConfigNotifications.class, "alerts_and_notifications.conf", "Notifications", null);
|
||||
configSuperAbilities = new SerializedConfigLoader<>(ConfigSuperAbilities.class, "skill_super_abilities.conf", "Super-Abilities", null);
|
||||
configAdmin = new SerializedConfigLoader<>(ConfigAdmin.class, "admin.conf", "Admin", null);
|
||||
configMobs = new SerializedConfigLoader<>(ConfigMobs.class, "creatures.conf", "Creatures", null);
|
||||
|
||||
initSerializedSkillConfigs();
|
||||
}
|
||||
|
||||
@SuppressWarnings(value = "unchecked")
|
||||
private void initSerializedSkillConfigs() {
|
||||
//Init HashMap
|
||||
skillConfigLoaders = new HashMap<>();
|
||||
|
||||
//Init and register serialized skill configs
|
||||
registerSkillConfig(PrimarySkillType.ACROBATICS, ConfigAcrobatics.class);
|
||||
registerSkillConfig(PrimarySkillType.ALCHEMY, ConfigAlchemy.class);
|
||||
registerSkillConfig(PrimarySkillType.SALVAGE, ConfigSalvage.class);
|
||||
registerSkillConfig(PrimarySkillType.ARCHERY, ConfigArchery.class);
|
||||
registerSkillConfig(PrimarySkillType.AXES, ConfigAxes.class);
|
||||
registerSkillConfig(PrimarySkillType.EXCAVATION, ConfigExcavation.class);
|
||||
registerSkillConfig(PrimarySkillType.FISHING, ConfigFishing.class);
|
||||
registerSkillConfig(PrimarySkillType.HERBALISM, ConfigHerbalism.class);
|
||||
registerSkillConfig(PrimarySkillType.MINING, ConfigMining.class);
|
||||
registerSkillConfig(PrimarySkillType.REPAIR, ConfigRepair.class);
|
||||
registerSkillConfig(PrimarySkillType.SWORDS, ConfigSwords.class);
|
||||
registerSkillConfig(PrimarySkillType.TAMING, ConfigTaming.class);
|
||||
registerSkillConfig(PrimarySkillType.UNARMED, ConfigUnarmed.class);
|
||||
registerSkillConfig(PrimarySkillType.WOODCUTTING, ConfigWoodcutting.class);
|
||||
registerSkillConfig(PrimarySkillType.SMELTING, ConfigSmelting.class);
|
||||
|
||||
//Setup Typed refs
|
||||
configAcrobatics = (SerializedConfigLoader<ConfigAcrobatics>) skillConfigLoaders.get(PrimarySkillType.ACROBATICS).getConfig();
|
||||
configAlchemy = (SerializedConfigLoader<ConfigAlchemy>) skillConfigLoaders.get(PrimarySkillType.ALCHEMY).getConfig();
|
||||
configSalvage = (SerializedConfigLoader<ConfigSalvage>) skillConfigLoaders.get(PrimarySkillType.SALVAGE).getConfig();
|
||||
configArchery = (SerializedConfigLoader<ConfigArchery>) skillConfigLoaders.get(PrimarySkillType.ARCHERY).getConfig();
|
||||
configAxes = (SerializedConfigLoader<ConfigAxes>) skillConfigLoaders.get(PrimarySkillType.AXES).getConfig();
|
||||
configExcavation = (SerializedConfigLoader<ConfigExcavation>) skillConfigLoaders.get(PrimarySkillType.EXCAVATION).getConfig();
|
||||
configFishing = (SerializedConfigLoader<ConfigFishing>) skillConfigLoaders.get(PrimarySkillType.FISHING).getConfig();
|
||||
configHerbalism = (SerializedConfigLoader<ConfigHerbalism>) skillConfigLoaders.get(PrimarySkillType.HERBALISM).getConfig();
|
||||
configMining = (SerializedConfigLoader<ConfigMining>) skillConfigLoaders.get(PrimarySkillType.MINING).getConfig();
|
||||
configRepair = (SerializedConfigLoader<ConfigRepair>) skillConfigLoaders.get(PrimarySkillType.REPAIR).getConfig();
|
||||
configSwords = (SerializedConfigLoader<ConfigSwords>) skillConfigLoaders.get(PrimarySkillType.SWORDS).getConfig();
|
||||
configTaming = (SerializedConfigLoader<ConfigTaming>) skillConfigLoaders.get(PrimarySkillType.TAMING).getConfig();
|
||||
configUnarmed = (SerializedConfigLoader<ConfigUnarmed>) skillConfigLoaders.get(PrimarySkillType.UNARMED).getConfig();
|
||||
configWoodcutting = (SerializedConfigLoader<ConfigWoodcutting>) skillConfigLoaders.get(PrimarySkillType.WOODCUTTING).getConfig();
|
||||
configSmelting = (SerializedConfigLoader<ConfigSmelting>) skillConfigLoaders.get(PrimarySkillType.SMELTING).getConfig();
|
||||
}
|
||||
|
||||
private void registerCustomTypeSerializers() {
|
||||
/*
|
||||
TypeTokens are obtained in two ways
|
||||
|
||||
@ -199,88 +300,10 @@ public final class ConfigManager {
|
||||
DEFAULT_SERIALIZERS.registerType(TypeToken.of(Pattern.class), new PatternSerializer());
|
||||
*/
|
||||
|
||||
mcMMO.p.getLogger().info("Registering custom type serializers for Configurate...");
|
||||
TypeSerializers.getDefaultSerializers().registerType(new TypeToken<Material>() {}, new CustomEnumValueSerializer());
|
||||
TypeSerializers.getDefaultSerializers().registerType(new TypeToken<PartyFeature>() {}, new CustomEnumValueSerializer());
|
||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Repairable.class), new RepairableSerializer());
|
||||
|
||||
mcMMO.p.getLogger().info("Deserializing configs...");
|
||||
//TODO: Not sure about the order of MainConfig
|
||||
//Serialized Configs
|
||||
configDatabase = new SerializedConfigLoader<>(ConfigDatabase.class, "database_settings.conf", "Database", null);
|
||||
configScoreboard = new SerializedConfigLoader<>(ConfigScoreboard.class, "scoreboard.conf", "Scoreboard", null);
|
||||
configLeveling = new SerializedConfigLoader<>(ConfigLeveling.class, "player_leveling.conf", "Player-Leveling", null);
|
||||
configWorldBlacklist = new SerializedConfigLoader<>(ConfigWorldBlacklist.class, "world_blacklist.conf", "World-Blacklist", null);
|
||||
configExploitPrevention = new SerializedConfigLoader<>(ConfigExploitPrevention.class, "anti_exploit.conf", "Anti-Exploit", null);
|
||||
configMOTD = new SerializedConfigLoader<>(ConfigMOTD.class, "message_of_the_day.conf", "MOTD", null);
|
||||
configHardcore = new SerializedConfigLoader<>(ConfigHardcore.class, "hardcore_mode.conf", "Hardcore-Mode", null);
|
||||
configMetrics = new SerializedConfigLoader<>(ConfigMetrics.class, "analytics_reporting.conf", "Analytic-Reporting", null);
|
||||
configAuthorAdvertisements = new SerializedConfigLoader<>(ConfigAuthorAdvertisements.class, "author_support_advertisements.conf", "mcMMO", null);
|
||||
configAutomatedBackups = new SerializedConfigLoader<>(ConfigAutomatedBackups.class, "automated_backups.conf", "Automated-Backups", null);
|
||||
configCommands = new SerializedConfigLoader<>(ConfigCommands.class, "commands.conf", "Commands", null);
|
||||
configItems = new SerializedConfigLoader<>(ConfigItems.class, "custom_items.conf", "Items", null);
|
||||
configLanguage = new SerializedConfigLoader<>(ConfigLanguage.class, "language.conf", "Language", null);
|
||||
configParticles = new SerializedConfigLoader<>(ConfigParticles.class, "particle_spawning.conf", "Particles", null);
|
||||
configParty = new SerializedConfigLoader<>(ConfigParty.class, "party.conf", "Party", null);
|
||||
configNotifications = new SerializedConfigLoader<>(ConfigNotifications.class, "alerts_and_notifications.conf", "Notifications", null);
|
||||
configSuperAbilities = new SerializedConfigLoader<>(ConfigSuperAbilities.class, "skill_super_abilities.conf", "Super-Abilities", null);
|
||||
configAdmin = new SerializedConfigLoader<>(ConfigAdmin.class, "admin.conf", "Admin", null);
|
||||
configMobs = new SerializedConfigLoader<>(ConfigMobs.class, "creatures.conf", "Creatures", null);
|
||||
|
||||
registerSkillConfig(PrimarySkillType.ACROBATICS, ConfigAcrobatics.class);
|
||||
registerSkillConfig(PrimarySkillType.SALVAGE, ConfigSalvage.class);
|
||||
registerSkillConfig(PrimarySkillType.ARCHERY, ConfigArchery.class);
|
||||
registerSkillConfig(PrimarySkillType.AXES, ConfigAxes.class);
|
||||
registerSkillConfig(PrimarySkillType.EXCAVATION, ConfigExcavation.class);
|
||||
registerSkillConfig(PrimarySkillType.FISHING, ConfigFishing.class);
|
||||
registerSkillConfig(PrimarySkillType.HERBALISM, ConfigHerbalism.class);
|
||||
registerSkillConfig(PrimarySkillType.MINING, ConfigMining.class);
|
||||
registerSkillConfig(PrimarySkillType.REPAIR, ConfigRepair.class);
|
||||
registerSkillConfig(PrimarySkillType.SWORDS, ConfigSwords.class);
|
||||
registerSkillConfig(PrimarySkillType.TAMING, ConfigTaming.class);
|
||||
registerSkillConfig(PrimarySkillType.UNARMED, ConfigUnarmed.class);
|
||||
registerSkillConfig(PrimarySkillType.WOODCUTTING, ConfigWoodcutting.class);
|
||||
registerSkillConfig(PrimarySkillType.SMELTING, ConfigSmelting.class);
|
||||
|
||||
//Serialized Data
|
||||
partyData = new SerializedConfigLoader<>(ConfigPartyData.class, "partydata.conf", "PartyData", null);
|
||||
|
||||
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
|
||||
|
||||
//Register Bonus Drops
|
||||
registerBonusDrops();
|
||||
|
||||
//YAML Configs
|
||||
mainConfig = new MainConfig();
|
||||
|
||||
fishingTreasureConfig = new FishingTreasureConfig();
|
||||
excavationTreasureConfig = new ExcavationTreasureConfig();
|
||||
herbalismTreasureConfig = new HerbalismTreasureConfig();
|
||||
|
||||
advancedConfig = new AdvancedConfig();
|
||||
|
||||
//TODO: Not sure about the order of experience config
|
||||
experienceConfig = new ExperienceConfig();
|
||||
|
||||
potionConfig = new PotionConfig();
|
||||
|
||||
coreSkillsConfig = new CoreSkillsConfig();
|
||||
|
||||
soundConfig = new SoundConfig();
|
||||
|
||||
rankConfig = new RankConfig();
|
||||
|
||||
/*
|
||||
* Managers
|
||||
*/
|
||||
|
||||
// Register Managers
|
||||
initMiscManagers();
|
||||
initCollectionManagers();
|
||||
}
|
||||
|
||||
private void registerSkillConfig(PrimarySkillType primarySkillType, Class clazz)
|
||||
|
Loading…
Reference in New Issue
Block a user