mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
Core skill config is now converted
This commit is contained in:
parent
39d10855d8
commit
c61c55031d
@ -95,9 +95,18 @@ public abstract class Config implements VersionedConfig {
|
||||
}
|
||||
|
||||
//Cleanup and backup registers
|
||||
// registerUnload();
|
||||
registerFileBackup();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Registers with the config managers unloader
|
||||
// * The unloader runs when the plugin gets disabled which cleans up registries to make reloading safe
|
||||
// */
|
||||
// private void registerUnload() {
|
||||
// mcMMO.getConfigManager().registerUnloadable(this);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Registers with the config managers file list
|
||||
* Used for backing up configs with our zip library
|
||||
@ -276,9 +285,9 @@ public abstract class Config implements VersionedConfig {
|
||||
*
|
||||
* @return the path to the defaults directory
|
||||
*/
|
||||
// private String getDefaultConfigCopyRelativePath() {
|
||||
// return getDefaultConfigFile().getPath();
|
||||
// }
|
||||
private String getDefaultConfigCopyRelativePath() {
|
||||
return getDefaultConfigFile().getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the File representation of the default config, which is stored on disk in a defaults folder
|
||||
@ -286,9 +295,9 @@ public abstract class Config implements VersionedConfig {
|
||||
*
|
||||
* @return the copy of the default config file, stored in the defaults directory
|
||||
*/
|
||||
// private File getDefaultConfigFile() {
|
||||
// return new File(ConfigConstants.getDefaultsFolder(), FILE_RELATIVE_PATH);
|
||||
// }
|
||||
private File getDefaultConfigFile() {
|
||||
return new File(ConfigConstants.getDefaultsFolder(), FILE_RELATIVE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the defaults directory
|
||||
|
@ -24,6 +24,7 @@ import com.gmail.nossr50.config.hocon.skills.acrobatics.ConfigAcrobatics;
|
||||
import com.gmail.nossr50.config.hocon.skills.alchemy.ConfigAlchemy;
|
||||
import com.gmail.nossr50.config.hocon.skills.archery.ConfigArchery;
|
||||
import com.gmail.nossr50.config.hocon.skills.axes.ConfigAxes;
|
||||
import com.gmail.nossr50.config.hocon.skills.coreskills.ConfigCoreSkills;
|
||||
import com.gmail.nossr50.config.hocon.skills.exampleconfigs.ConfigNameRegisterDefaults;
|
||||
import com.gmail.nossr50.config.hocon.skills.exampleconfigs.MinecraftMaterialWrapper;
|
||||
import com.gmail.nossr50.config.hocon.skills.excavation.ConfigExcavation;
|
||||
@ -93,6 +94,7 @@ public final class ConfigManager {
|
||||
private SerializedConfigLoader<ConfigAdmin> configAdmin;
|
||||
private SerializedConfigLoader<ConfigMobs> configMobs;
|
||||
private SerializedConfigLoader<ConfigExperience> configExperience;
|
||||
private SerializedConfigLoader<ConfigCoreSkills> configCoreSkills;
|
||||
private SerializedConfigLoader<ConfigNameRegisterDefaults> configDefaultExamples;
|
||||
|
||||
private ConfigAcrobatics configAcrobatics;
|
||||
@ -123,7 +125,6 @@ public final class ConfigManager {
|
||||
private ExcavationTreasureConfig excavationTreasureConfig;
|
||||
private HerbalismTreasureConfig herbalismTreasureConfig;
|
||||
private AdvancedConfig advancedConfig;
|
||||
private CoreSkillsConfig coreSkillsConfig;
|
||||
private SoundConfig soundConfig;
|
||||
private RankConfig rankConfig;
|
||||
|
||||
@ -177,6 +178,7 @@ public final class ConfigManager {
|
||||
configAdmin = new SerializedConfigLoader<>(ConfigAdmin.class, "admin.conf", "Admin", null);
|
||||
configMobs = new SerializedConfigLoader<>(ConfigMobs.class, "creatures.conf", "Creatures", null);
|
||||
configExperience = new SerializedConfigLoader<>(ConfigExperience.class, "experience.conf", "Experience", null);
|
||||
configCoreSkills = new SerializedConfigLoader<>(ConfigCoreSkills.class, "core_skills.conf", "Core-Skills", null);
|
||||
|
||||
configDefaultExamples = new SerializedConfigLoader<>(ConfigNameRegisterDefaults.class, "minecraft_item_block_name_examples.conf", "Minecraft", null);
|
||||
initSerializedSkillConfigs();
|
||||
@ -326,8 +328,8 @@ public final class ConfigManager {
|
||||
return advancedConfig;
|
||||
}
|
||||
|
||||
public CoreSkillsConfig getCoreSkillsConfig() {
|
||||
return coreSkillsConfig;
|
||||
public ConfigCoreSkills getConfigCoreSkills() {
|
||||
return configCoreSkills.getConfig();
|
||||
}
|
||||
|
||||
public SoundConfig getSoundConfig() {
|
||||
|
@ -1,66 +0,0 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class CoreSkillsConfig extends Config {
|
||||
public static final String ENABLED = "Enabled";
|
||||
//private static CoreSkillsConfig instance;
|
||||
|
||||
public CoreSkillsConfig() {
|
||||
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"coreskills.yml", true);
|
||||
super("coreskills", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This grabs an instance of the class from the Config Manager
|
||||
* This method is deprecated and will be removed in the future
|
||||
*
|
||||
* @return the instance of this config
|
||||
* @see mcMMO#getConfigManager()
|
||||
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static CoreSkillsConfig getInstance() {
|
||||
return mcMMO.getConfigManager().getCoreSkillsConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of this config
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public double getConfigVersion() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skill Settings
|
||||
*/
|
||||
|
||||
/**
|
||||
* Whether or not a skill is enabled
|
||||
* Defaults true
|
||||
*
|
||||
* @param abstractSubSkill SubSkill definition to check
|
||||
* @return true if subskill is enabled
|
||||
*/
|
||||
public boolean isSkillEnabled(AbstractSubSkill abstractSubSkill) {
|
||||
return getBooleanValue(StringUtils.getCapitalized(abstractSubSkill.getPrimarySkill().toString()), abstractSubSkill.getConfigKeyName(), ENABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this primary skill is enabled
|
||||
*
|
||||
* @param primarySkillType target primary skill
|
||||
* @return true if enabled
|
||||
*/
|
||||
public boolean isPrimarySkillEnabled(PrimarySkillType primarySkillType) {
|
||||
return getBooleanValue(StringUtils.getCapitalized(primarySkillType.toString()), ENABLED);
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
/**
|
||||
* Unloads values, sort of like a constructor
|
||||
*/
|
||||
public interface Unload {
|
||||
void unload();
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.config.hocon.skills.coreskills;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigCoreSkills {
|
||||
|
||||
@Setting(value = "Core Skills for Acrobatics" +
|
||||
"\nCore skills are ones built into mcMMO")
|
||||
private ConfigCoreSkillsAcrobatics configCoreSkillsAcrobatics = new ConfigCoreSkillsAcrobatics();
|
||||
|
||||
public boolean isRollEnabled() {
|
||||
return configCoreSkillsAcrobatics.isRollEnabled();
|
||||
}
|
||||
|
||||
public ConfigCoreSkillsAcrobatics getConfigCoreSkillsAcrobatics() {
|
||||
return configCoreSkillsAcrobatics;
|
||||
}
|
||||
|
||||
public boolean isAcrobaticsEnabled() {
|
||||
return getConfigCoreSkillsAcrobatics().isAcrobaticsEnabled();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.gmail.nossr50.config.hocon.skills.coreskills;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigCoreSkillsAcrobatics {
|
||||
|
||||
private static final boolean ROLL_DEFAULT = true;
|
||||
public static final boolean ACROBATICS_MASTER_DEFAULT = true;
|
||||
|
||||
@Setting(value = "Disable", comment = "Enable the primary skill Acrobatics")
|
||||
private boolean enableAcrobatics = ACROBATICS_MASTER_DEFAULT;
|
||||
|
||||
@Setting(value = "Roll", comment = "Enable or disable the Roll skill.")
|
||||
private boolean enableRoll = ROLL_DEFAULT;
|
||||
|
||||
public boolean isRollEnabled() {
|
||||
return enableRoll;
|
||||
}
|
||||
|
||||
public boolean isAcrobaticsEnabled() {
|
||||
return enableAcrobatics;
|
||||
}
|
||||
}
|
@ -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;
|
||||
@ -33,18 +32,6 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S
|
||||
return LocaleLoader.getString(getPrimaryKeyName() + ".SubSkill." + getConfigKeyName() + ".Description");
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this subskill is enabled
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isEnabled() {
|
||||
//TODO: This might be troublesome...
|
||||
return CoreSkillsConfig.getInstance().isSkillEnabled(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints detailed info about this subskill to the player
|
||||
*
|
||||
|
@ -72,13 +72,6 @@ public interface SubSkill extends Skill {
|
||||
*/
|
||||
void addStats(ComponentBuilder componentBuilder, Player player);
|
||||
|
||||
/**
|
||||
* Whether or not this subskill is enabled
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Prints detailed info about this subskill to the player
|
||||
*
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigManager;
|
||||
import com.gmail.nossr50.config.CoreSkillsConfig;
|
||||
import com.gmail.nossr50.config.MainConfig;
|
||||
import com.gmail.nossr50.config.hocon.database.ConfigSectionCleaning;
|
||||
import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL;
|
||||
@ -14,7 +13,6 @@ import com.gmail.nossr50.core.MaterialMapStore;
|
||||
import com.gmail.nossr50.core.MetadataConstants;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
|
||||
import com.gmail.nossr50.listeners.*;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@ -508,13 +506,14 @@ public class mcMMO extends JavaPlugin {
|
||||
* Acrobatics skills
|
||||
*/
|
||||
|
||||
if (CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS)) {
|
||||
if (mcMMO.getConfigManager().getConfigCoreSkills().isAcrobaticsEnabled()) {
|
||||
System.out.println("[mcMMO]" + " enabling Acrobatics Skills");
|
||||
|
||||
//TODO: Should do this differently
|
||||
Roll roll = new Roll();
|
||||
CoreSkillsConfig.getInstance().isSkillEnabled(roll);
|
||||
InteractionManager.registerSubSkill(new Roll());
|
||||
if(mcMMO.getConfigManager().getConfigCoreSkills().isRollEnabled())
|
||||
{
|
||||
InteractionManager.registerSubSkill(new Roll());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user