mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
converting mainconfig pt 3
This commit is contained in:
parent
4bb513c2d1
commit
c91255c474
@ -2,15 +2,18 @@ package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
||||
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles loading and cacheing configuration settings from a configurable compatible config file
|
||||
@ -370,4 +373,8 @@ public abstract class Config implements VersionedConfig, Unload {
|
||||
public boolean hasNode(String... path) {
|
||||
return (userRootNode.getNode(path) != null);
|
||||
}
|
||||
|
||||
public List<String> getStringValueList(String... path) throws ObjectMappingException {
|
||||
return userRootNode.getList(TypeToken.of(String.class));
|
||||
}
|
||||
}
|
||||
|
@ -80,32 +80,23 @@ public final class ConfigManager {
|
||||
|
||||
//TODO: Not sure about the order of MainConfig
|
||||
mainConfig = new MainConfig();
|
||||
unloadables.add(mainConfig);
|
||||
|
||||
treasureConfig = new TreasureConfig();
|
||||
unloadables.add(treasureConfig);
|
||||
|
||||
advancedConfig = new AdvancedConfig();
|
||||
unloadables.add(advancedConfig);
|
||||
|
||||
//TODO: Not sure about the order of experience config
|
||||
experienceConfig = new ExperienceConfig();
|
||||
unloadables.add(experienceConfig);
|
||||
|
||||
potionConfig = new PotionConfig();
|
||||
unloadables.add(potionConfig);
|
||||
|
||||
coreSkillsConfig = new CoreSkillsConfig();
|
||||
unloadables.add(coreSkillsConfig);
|
||||
|
||||
soundConfig = new SoundConfig();
|
||||
unloadables.add(soundConfig);
|
||||
|
||||
rankConfig = new RankConfig();
|
||||
unloadables.add(rankConfig);
|
||||
|
||||
itemWeightConfig = new ItemWeightConfig();
|
||||
unloadables.add(itemWeightConfig);
|
||||
|
||||
/*if (MainConfig.getInstance().getToolModsEnabled()) {
|
||||
new ToolConfigManager();
|
||||
@ -244,4 +235,8 @@ public final class ConfigManager {
|
||||
public ExperienceConfig getExperienceConfig() {
|
||||
return experienceConfig;
|
||||
}
|
||||
|
||||
public ItemWeightConfig getItemWeightConfig() {
|
||||
return itemWeightConfig;
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,10 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MainConfig extends ConfigValidated {
|
||||
|
||||
@ -248,7 +246,7 @@ public class MainConfig extends ConfigValidated {
|
||||
/* MySQL Settings */
|
||||
for (SQLDatabaseManager.PoolIdentifier identifier : SQLDatabaseManager.PoolIdentifier.values()) {
|
||||
if (getMySQLMaxConnections(identifier) <= 0) {
|
||||
reason.add(MY_SQL + "." + DATABASE + "." + MAX_CONNECTIONS + "." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
|
||||
reason.add(MY_SQL + "." + DATABASE, MAX_CONNECTIONS + "." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
|
||||
}
|
||||
if (getMySQLMaxPoolSize(identifier) <= 0) {
|
||||
reason.add(MY_SQL + "." + DATABASE + "." + MAX_POOL_SIZE + "." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
|
||||
@ -474,22 +472,6 @@ public class MainConfig extends ConfigValidated {
|
||||
return getIntValue(GENERAL, SAVE_INTERVAL);
|
||||
}
|
||||
|
||||
public boolean getStatsTrackingEnabled() {
|
||||
return getBooleanValue(GENERAL, STATS_TRACKING);
|
||||
}
|
||||
|
||||
public boolean getUpdateCheckEnabled() {
|
||||
return getBooleanValue(GENERAL, UPDATE_CHECK);
|
||||
}
|
||||
|
||||
public boolean getPreferBeta() {
|
||||
return getBooleanValue(GENERAL, PREFER_BETA);
|
||||
}
|
||||
|
||||
public boolean getVerboseLoggingEnabled() {
|
||||
return getBooleanValue(GENERAL, VERBOSE_LOGGING);
|
||||
}
|
||||
|
||||
public String getPartyChatPrefix() {
|
||||
return getStringValue(COMMANDS, PARTYCHAT, CHAT_PREFIX_FORMAT);
|
||||
}
|
||||
@ -738,18 +720,10 @@ public class MainConfig extends ConfigValidated {
|
||||
return getBooleanValue(HARDCORE, DEATH_STAT_LOSS, ENABLED, StringUtils.getCapitalized(primarySkillType.toString()));
|
||||
}
|
||||
|
||||
/*public void setHardcoreStatLossEnabled(PrimarySkillType primarySkillType, boolean enabled) {
|
||||
config.set(HARDCORE, DEATH_STAT_LOSS, ENABLED, StringUtils.getCapitalized(primarySkillType.toString()), enabled);
|
||||
}*/
|
||||
|
||||
public double getHardcoreDeathStatPenaltyPercentage() {
|
||||
return getDoubleValue(HARDCORE, DEATH_STAT_LOSS, PENALTY_PERCENTAGE);
|
||||
}
|
||||
|
||||
/*public void setHardcoreDeathStatPenaltyPercentage(double value) {
|
||||
config.set(HARDCORE, DEATH_STAT_LOSS, PENALTY_PERCENTAGE, value);
|
||||
}*/
|
||||
|
||||
public int getHardcoreDeathStatPenaltyLevelThreshold() {
|
||||
return getIntValue(HARDCORE, DEATH_STAT_LOSS, LEVEL_THRESHOLD);
|
||||
}
|
||||
@ -758,18 +732,10 @@ public class MainConfig extends ConfigValidated {
|
||||
return getBooleanValue(HARDCORE, VAMPIRISM, ENABLED, StringUtils.getCapitalized(primarySkillType.toString()));
|
||||
}
|
||||
|
||||
/*public void setHardcoreVampirismEnabled(PrimarySkillType primarySkillType, boolean enabled) {
|
||||
config.set(HARDCORE, VAMPIRISM, ENABLED, StringUtils.getCapitalized(primarySkillType.toString()), enabled);
|
||||
}*/
|
||||
|
||||
public double getHardcoreVampirismStatLeechPercentage() {
|
||||
return getDoubleValue(HARDCORE, VAMPIRISM, LEECH_PERCENTAGE);
|
||||
}
|
||||
|
||||
/*public void setHardcoreVampirismStatLeechPercentage(double value) {
|
||||
config.set(HARDCORE, VAMPIRISM, LEECH_PERCENTAGE, value);
|
||||
}*/
|
||||
|
||||
public int getHardcoreVampirismLevelThreshold() {
|
||||
return getIntValue(HARDCORE, VAMPIRISM, LEVEL_THRESHOLD);
|
||||
}
|
||||
@ -955,69 +921,46 @@ public class MainConfig extends ConfigValidated {
|
||||
}
|
||||
|
||||
public boolean getAbilityMessagesEnabled() {
|
||||
return getBooleanValue(ABILITIES + "." + MESSAGES);
|
||||
return getBooleanValue(ABILITIES, MESSAGES);
|
||||
}
|
||||
|
||||
public boolean getAbilitiesEnabled() {
|
||||
return getBooleanValue(ABILITIES + "." + ENABLED);
|
||||
return getBooleanValue(ABILITIES, ENABLED);
|
||||
}
|
||||
|
||||
public boolean getAbilitiesOnlyActivateWhenSneaking() {
|
||||
return getBooleanValue(ABILITIES + "." + ACTIVATION + "." + ONLY_ACTIVATE_WHEN_SNEAKING);
|
||||
return getBooleanValue(ABILITIES, ACTIVATION, ONLY_ACTIVATE_WHEN_SNEAKING);
|
||||
}
|
||||
|
||||
public boolean getAbilitiesGateEnabled() {
|
||||
return getBooleanValue(ABILITIES + "." + ACTIVATION + "." + LEVEL_GATE_ABILITIES);
|
||||
return getBooleanValue(ABILITIES, ACTIVATION, LEVEL_GATE_ABILITIES);
|
||||
}
|
||||
|
||||
public int getCooldown(SuperAbilityType ability) {
|
||||
return getIntValue(ABILITIES + "." + COOLDOWNS + ability.toString());
|
||||
return getIntValue(ABILITIES, COOLDOWNS + ability.toString());
|
||||
}
|
||||
|
||||
public int getMaxLength(SuperAbilityType ability) {
|
||||
return getIntValue(ABILITIES + "." + MAX_SECONDS + "." + ability.toString());
|
||||
return getIntValue(ABILITIES, MAX_SECONDS, ability.toString());
|
||||
}
|
||||
|
||||
/* Durability Settings */
|
||||
public int getAbilityToolDamage() {
|
||||
return getIntValue(ABILITIES + "." + TOOLS + "." + DURABILITY_LOSS);
|
||||
return getIntValue(ABILITIES, TOOLS, DURABILITY_LOSS);
|
||||
}
|
||||
|
||||
/* Thresholds */
|
||||
public int getTreeFellerThreshold() {
|
||||
return getIntValue(ABILITIES + "." + LIMITS + "." + TREE_FELLER_THRESHOLD);
|
||||
return getIntValue(ABILITIES, LIMITS, TREE_FELLER_THRESHOLD);
|
||||
}
|
||||
|
||||
/*
|
||||
* SKILL SETTINGS
|
||||
*/
|
||||
public boolean getDoubleDropsEnabled(PrimarySkillType skill, Material material) {
|
||||
return getBooleanValue(DOUBLE_DROPS + "." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_"));
|
||||
return getBooleanValue(DOUBLE_DROPS, StringUtils.getCapitalized(skill.toString()), StringUtils.getPrettyItemString(material).replace(" ", "_"));
|
||||
}
|
||||
|
||||
public boolean getDoubleDropsDisabled(PrimarySkillType skill) {
|
||||
String skillName = StringUtils.getCapitalized(skill.toString());
|
||||
ConfigurationSection section = config.getConfigurationSection(DOUBLE_DROPS + "." + skillName);
|
||||
if (section == null)
|
||||
return false;
|
||||
Set<String> keys = section.getKeys(false);
|
||||
boolean disabled = true;
|
||||
|
||||
for (String key : keys) {
|
||||
if (getBooleanValue(DOUBLE_DROPS + "." + skillName + "." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/* Axes */
|
||||
/*public int getAxesGate() {
|
||||
return getIntValue(SKILLS + "." + AXES + "." + ABILITY_ACTIVATION + "_Level_Gate", 10);
|
||||
}*/
|
||||
|
||||
/* Acrobatics */
|
||||
public boolean getDodgeLightningDisabled() {
|
||||
return getBooleanValue(SKILLS, ACROBATICS, PREVENT + DODGE + LIGHTNING);
|
||||
|
@ -1,21 +1,5 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
/*
|
||||
public class CustomToolConfig extends Config {
|
||||
//TODO: Disabled until modded servers come back
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.gmail.nossr50.config.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.MainConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -13,7 +13,6 @@ public class ItemWeightConfig extends Config {
|
||||
public static final String DEFAULT = "Default";
|
||||
public static final String PARTY_SHAREABLES = "Party_Shareables";
|
||||
public static final String MISC_ITEMS = "Misc_Items";
|
||||
private static ItemWeightConfig instance;
|
||||
|
||||
public ItemWeightConfig() {
|
||||
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "itemweights.yml");
|
||||
@ -29,7 +28,12 @@ public class ItemWeightConfig extends Config {
|
||||
*/
|
||||
@Deprecated
|
||||
public static ItemWeightConfig getInstance() {
|
||||
return mcMMO.getConfigManager().getIte();
|
||||
return mcMMO.getConfigManager().getItemWeightConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,6 +65,7 @@ public class ItemWeightConfig extends Config {
|
||||
public HashSet<Material> getMiscItems() {
|
||||
HashSet<Material> miscItems = new HashSet<Material>();
|
||||
|
||||
try {
|
||||
for (String item : getStringValueList(PARTY_SHAREABLES, MISC_ITEMS)) {
|
||||
Material material = Material.getMaterial(item.toUpperCase());
|
||||
|
||||
@ -68,10 +73,9 @@ public class ItemWeightConfig extends Config {
|
||||
miscItems.add(material);
|
||||
}
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return miscItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
|
@ -150,9 +150,9 @@ public enum PrimarySkillType {
|
||||
return MainConfig.getInstance().getPVEEnabled(this);
|
||||
}
|
||||
|
||||
public boolean getDoubleDropsDisabled() {
|
||||
/*public boolean getDoubleDropsDisabled() {
|
||||
return MainConfig.getInstance().getDoubleDropsDisabled(this);
|
||||
}
|
||||
}*/
|
||||
|
||||
public boolean getHardcoreStatLossEnabled() {
|
||||
return MainConfig.getInstance().getHardcoreStatLossEnabled(this);
|
||||
|
@ -4,7 +4,6 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
@ -2,12 +2,10 @@ package com.gmail.nossr50.skills.woodcutting;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
|
||||
import com.gmail.nossr50.util.*;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public final class MaterialUtils {
|
||||
|
Loading…
Reference in New Issue
Block a user