Removing Static Abuse - WorldBlackList -> WorldBlackListManager

This commit is contained in:
nossr50
2019-07-03 22:31:59 -07:00
parent bd0a673838
commit 8b39224cbc
23 changed files with 1426 additions and 1380 deletions

View File

@@ -0,0 +1,209 @@
//package com.gmail.nossr50.config;
//
//import com.gmail.nossr50.mcMMO;
//import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
//
//import java.util.ArrayList;
//import java.util.List;
//
//@ConfigSerializable
//public class AdvancedConfig extends ConfigValidated {
//
// public static final String SKILLS = "Skills";
// public static final String GENERAL = "General";
// public static final String ABILITY = "Ability";
// public static final String LENGTH = "Length";
// public static final String INCREASE_LEVEL = "IncreaseLevel";
// public static final String ENCHANT_BUFF = "EnchantBuff";
// public static final String ACROBATICS = "Acrobatics";
// public static final String DODGE = "Dodge";
// public static final String CHANCE = "Chance";
// public static final String CHANCE_MAX = CHANCE + "Max";
// public static final String BONUS = "Bonus";
// public static final String MAX_BONUS_LEVEL = "Max" + BONUS + "Level";
// public static final String MODIFIER = "Modifier";
// public static final String DAMAGE_MODIFIER = "Damage" + MODIFIER;
// public static final String DAMAGE_THRESHOLD = "DamageThreshold";
// public static final String ALCHEMY = "Alchemy";
// public static final String CATALYSIS = "Catalysis";
// public static final String MIN_SPEED = "MinSpeed";
// public static final String MAX_SPEED = "MaxSpeed";
// public static final String ARCHERY = "Archery";
// public static final String SKILL_SHOT = "SkillShot";
// public static final String MULTIPLIER = "Multiplier";
// public static final String RANK_DAMAGE_MULTIPLIER = "RankDamage" + MULTIPLIER;
// public static final String BONUS_DAMAGE = BONUS + "Damage";
// public static final String FORCE_MULTIPLIER = "Force" + MULTIPLIER;
// public static final String AXES = "Axes";
// public static final String STANDARD = "Standard";
// public static final String RETRO_MODE = "RetroMode";
// public static final String CAP_LEVEL = "CapLevel";
// public static final String KNOCKBACK_MODIFIER = "Knockback" + MODIFIER;
// public static final String PVP_MODIFIER = "PVP_" + MODIFIER;
// public static final String PVE_MODIFIER = "PVE_" + MODIFIER;
// public static final String FISHING = "Fishing";
// public static final String MASTER_ANGLER = "MasterAngler";
// public static final String BOAT_MODIFIER = "Boat" + MODIFIER;
// public static final String BIOME_MODIFIER = "Biome" + MODIFIER;
// public static final String XP = "XP";
// public static final String VANILLA_XPMULTIPLIER = "Vanilla" + XP + MULTIPLIER;
// public static final String RANK = "Rank_";
// public static final String TAMING = "Taming";
// public static final String CALL_OF_THE_WILD = "CallOfTheWild";
// public static final String MIN_HORSE_JUMP_STRENGTH = "MinHorseJumpStrength";
// public static final String MAX_HORSE_JUMP_STRENGTH = "MaxHorseJumpStrength";
// public static final String SHOCK_PROOF = "ShockProof";
// public static final String UNARMED = "Unarmed";
// public static final String STARTING_LEVEL = "StartingLevel";
// public static final String AXE_MASTERY = "AxeMastery";
// public static final String CRITICAL_STRIKES = "CriticalStrikes";
// public static final String GREATER_IMPACT = "GreaterImpact";
// public static final String ARMOR_IMPACT = "ArmorImpact";
// public static final String SKULL_SPLITTER = "SkullSplitter";
// public static final String MAX_PERCENTAGE_DURABILITY_DAMAGE = "MaxPercentageDurabilityDamage";
// public static final String SHAKE = "Shake";
// public static final String MINING = "Mining";
// public static final String BLAST_MINING = "BlastMining";
// public static final String LEVELS = "Levels";
// public static final String BLAST_DAMAGE_DECREASE = "BlastDamageDecrease";
// public static final String ORE_BONUS = "Ore" + BONUS;
// public static final String DEBRIS_REDUCTION = "DebrisReduction";
// public static final String DROP_MULTIPLIER = "Drop" + MULTIPLIER;
// public static final String BLAST_RADIUS = "BlastRadius";
// public static final String REPAIR = "Repair";
// public static final String REPAIR_MASTERY = "RepairMastery";
// public static final String MAX_BONUS_PERCENTAGE = "Max" + BONUS + "Percentage";
// public static final String ARCANE_FORGING = "ArcaneForging";
// public static final String MAY_LOSE_ENCHANTS = "May_Lose_Enchants";
// public static final String KEEP_ENCHANTS = "Keep_Enchants_";
// public static final String DOWNGRADES = "Downgrades_";
// public static final String ENABLED = "Enabled";
// public static final String DOWNGRADES_ENABLED = DOWNGRADES + ENABLED;
// public static final String SALVAGE = "Salvage";
// public static final String ARCANE_SALVAGE = "ArcaneSalvage";
// public static final String ENCHANT_DOWNGRADE_ENABLED = "EnchantDowngrade" + ENABLED;
// public static final String ENCHANT_LOSS_ENABLED = "EnchantLoss" + ENABLED;
// public static final String EXTRACT_FULL_ENCHANT = "ExtractFullEnchant";
// public static final String EXTRACT_PARTIAL_ENCHANT = "ExtractPartialEnchant";
// public static final String SMELTING = "Smelting";
// public static final String FUEL_EFFICIENCY = "FuelEfficiency";
// public static final String SWORDS = "Swords";
// public static final String RUPTURE = "Rupture";
// public static final String DAMAGE_PLAYER = "DamagePlayer";
// public static final String DAMAGE_MOBS = "DamageMobs";
// public static final String MAX_TICKS = "MaxTicks";
// public static final String BASE_TICKS = "BaseTicks";
// public static final String COUNTER_ATTACK = "CounterAttack";
// public static final String SERRATED_STRIKES = "SerratedStrikes";
// public static final String TICKS = "Ticks";
// public static final String GORE = "Gore";
// public static final String FAST_FOOD = "FastFood";
// public static final String FAST_FOOD_SERVICE = FAST_FOOD + "Service";
// public static final String PUMMEL = "Pummel";
// public static final String THICK_FUR = "ThickFur";
// public static final String SHARPENED_CLAWS = "SharpenedClaws";
// public static final String DISARM = "Disarm";
// public static final String ANTI_THEFT = "AntiTheft";
// public static final String DAZE = "Daze";
// public static final String MAX_DAMAGE = "MaxDamage";
// public static final String ROLL = "Roll";
// public static final String GRACEFUL_ROLL = "Graceful" + ROLL;
// public static final String ARROW_DEFLECT = "ArrowDeflect";
// public static final String IRON_GRIP = "IronGrip";
// public static final String WOODCUTTING = "Woodcutting";
// public static final String HARVEST_LUMBER = "HarvestLumber";
// public static final String FEEDBACK = "Feedback";
// public static final String SKILL_COMMAND = "SkillCommand";
// public static final String BLANK_LINES_ABOVE_HEADER = "BlankLinesAboveHeader";
// public static final String ACTION_BAR_NOTIFICATIONS = "ActionBarNotifications";
// public static final String SEND_COPY_OF_MESSAGE_TO_CHAT = "SendCopyOfMessageToChat";
// public static final String EVENTS = "Events";
// public static final String SEND_TITLES = "SendTitles";
// //private static AdvancedConfig instance;
//
// public AdvancedConfig() {
// //super(mcMMO.getDataFolderPath().getAbsoluteFile(), "advanced.yml", true);
// super("advanced", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true);
// }
//
// /**
// * This grabs an instance of this config 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 AdvancedConfig getInstance() {
// return pluginRef.getConfigManager().getAdvancedConfig();
// }
//
// /**
// * The version of this config
// *
// * @return
// */
// @Override
// public double getConfigVersion() {
// return 1;
// }
//
// @Override
// public List<String> validateKeys() {
// // Validate all the settings!
// List<String> reason = new ArrayList<>();
// return reason;
// }
//
// /* GENERAL */
//
// /* Notification Settings */
//
// /* FISHING */
// public double getShakeChance(int rank) {
// return getDoubleValue(SKILLS, FISHING, SHAKE, CHANCE, RANK, String.valueOf(rank));
// }
//
// public double getMasterAnglerBoatModifier() {
// return getDoubleValue(SKILLS, FISHING, MASTER_ANGLER, BOAT_MODIFIER);
// }
//
// public double getMasterAnglerBiomeModifier() {
// return getDoubleValue(SKILLS, FISHING, MASTER_ANGLER, BIOME_MODIFIER);
// }
//
// /* TAMING */
// public double getGoreModifier() {
// return getDoubleValue(SKILLS, TAMING, GORE, MODIFIER);
// }
//
// public double getFastFoodChance() {
// return getDoubleValue(SKILLS, TAMING, FAST_FOOD_SERVICE, CHANCE);
// }
//
// public double getPummelChance() {
// return getDoubleValue(SKILLS, TAMING, PUMMEL, CHANCE);
// }
//
// public double getThickFurModifier() {
// return getDoubleValue(SKILLS, TAMING, THICK_FUR, MODIFIER);
// }
//
// public double getShockProofModifier() {
// return getDoubleValue(SKILLS, TAMING, SHOCK_PROOF, MODIFIER);
// }
//
// public double getSharpenedClawsBonus() {
// return getDoubleValue(SKILLS, TAMING, SHARPENED_CLAWS, BONUS);
// }
//
// public double getMinHorseJumpStrength() {
// return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD, MIN_HORSE_JUMP_STRENGTH);
// }
//
// public double getMaxHorseJumpStrength() {
// return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD, MAX_HORSE_JUMP_STRENGTH);
// }
//
//}

View File

@@ -0,0 +1,481 @@
//package com.gmail.nossr50.config;
//
//import com.google.common.io.Files;
//import com.google.common.reflect.TypeToken;
//import ninja.leaping.configurate.commented.CommentedConfigurationNode;
//import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
//import ninja.leaping.configurate.loader.ConfigurationLoader;
//import ninja.leaping.configurate.objectmapping.ObjectMappingException;
//
//import java.io.File;
//import java.io.IOException;
//import java.io.InputStream;
//import java.nio.file.Path;
//import java.nio.file.Paths;
//import java.util.List;
//
///**
// * Handles loading and cacheing configuration settings from a configurable compatible config file
// */
//public abstract class Config implements VersionedConfig {
//
// public static final String HOCON_FILE_EXTENSION = ".conf";
// public final File DIRECTORY_DATA_FOLDER; //Directory that the file is in
// public final String FILE_RELATIVE_PATH; //Relative Path to the file
// protected final String DIRECTORY_DEFAULTS = "defaults";
// /* SETTINGS */
// //private static final String FILE_EXTENSION = ".conf"; //HOCON
// private boolean mergeNewKeys; //Whether or not to merge keys found in the default config
// private boolean removeOldKeys; //Whether or not to remove unused keys form the config
//
// /* PATH VARS */
// private boolean copyDefaults; //Whether or not to copy the default config when first creating the file
// private boolean generateDefaults; //Whether or not we use Configurate to generate a default file, if this is false we copy the file from the JAR
// private String fileName; //The file name of the config
//
// /* LOADERS */
// private HoconConfigurationLoader defaultCopyLoader;
// private HoconConfigurationLoader userCopyLoader;
//
// //private ConfigurationLoader<CommentedCommentedConfigurationNode> defaultCopyLoader;
// //private ConfigurationLoader<CommentedCommentedConfigurationNode> userCopyLoader;
//
// /* CONFIG FILES */
//
// private File resourceConfigCopy; //Copy of the default config from the JAR (file is copied so that admins can easily compare to defaults)
// private File resourceUserCopy; //File in the /$MCMMO_ROOT/mcMMO/ directory that may contain user edited settings
//
// /* ROOT NODES */
//
// private CommentedConfigurationNode userRootNode = null;
// private CommentedConfigurationNode defaultRootNode = null;
//
// /* CONFIG MANAGER */
// //private ConfigurationLoader<CommentedCommentedConfigurationNode> configManager;
//
// /*public Config(String pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
// //TODO: Check if this works...
// this(new File(pathToParentFolder), relativePath, mergeNewKeys, copyDefaults, removeOldKeys);
// System.out.println("mcMMO Debug: Don't forget to check if loading config file by string instead of File works...");
// }*/
//
// public Config(String fileName, File pathToParentFolder, String relativePath, boolean generateDefaults, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
// mkdirDefaults(); // Make our default config dir
//
// /*
// * These must be at the top
// */
// this.fileName = fileName;
// this.generateDefaults = generateDefaults;
// this.copyDefaults = copyDefaults;
// this.mergeNewKeys = mergeNewKeys; //Whether or not we add new keys when they are found
// this.removeOldKeys = removeOldKeys;
//
// DIRECTORY_DATA_FOLDER = pathToParentFolder; //Data Folder for our plugin
// FILE_RELATIVE_PATH = relativePath + fileName + HOCON_FILE_EXTENSION; //Relative path to config from a parent folder
// }
//
// public void initFullConfig() {
// //Attempt IO Operations
// try {
// //Makes sure we have valid Files corresponding to this config
// initConfigFiles();
//
// //Init MainConfig Loaders
// initConfigLoaders();
//
// //Load MainConfig Nodes
// loadConfig();
//
// //Attempt to update user file, and then load it into memory
// readConfig();
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// //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
// */
// private void registerFileBackup() {
// pluginRef.getConfigManager().registerUserFile(getUserConfigFile());
// }
//
// /**
// * Initializes the default copy File and the user config File
// *
// * @throws IOException
// */
// private void initConfigFiles() throws IOException {
// //Init our config copy
// resourceConfigCopy = initDefaultConfig();
//
// //Init the user file
// resourceUserCopy = initUserConfig();
// }
//
// /**
// * Loads the root node for the default config File and user config File
// */
// private void loadConfig() {
// try {
// final CommentedConfigurationNode defaultConfig = this.defaultCopyLoader.load();
// defaultRootNode = defaultConfig;
//
// final CommentedConfigurationNode userConfig = this.userCopyLoader.load();
// userRootNode = userConfig;
//
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// /**
// * Initializes the Configuration Loaders for this config
// */
// private void initConfigLoaders() {
// this.defaultCopyLoader = HoconConfigurationLoader.builder().setPath(resourceConfigCopy.toPath()).build();
// this.userCopyLoader = HoconConfigurationLoader.builder().setPath(resourceUserCopy.toPath()).build();
// }
//
// /**
// * Copies a new file from the JAR to the defaults directory and uses that new file to initialize our resourceConfigCopy
// *
// * @throws IOException
// * @see Config#resourceConfigCopy
// */
// private File initDefaultConfig() throws IOException {
// if (generateDefaults) {
// return generateDefaultFile();
// } else
// return copyDefaultFromJar(getDefaultConfigCopyRelativePath(), true);
// }
//
// /**
// * Generates a default config file using the Configurate library, makes use of @Setting and @ConfigSerializable annotations in the config file
// * Assigns the default root node to the newly loaded default config if successful
// *
// * @return the File for the newly created config
// */
// private File generateDefaultFile() {
// pluginRef.getLogger().info("Attempting to create a default config for " + fileName);
//
// //Not sure if this will work properly...
// Path potentialFile = Paths.get(getDefaultConfigCopyRelativePath());
// ConfigurationLoader<CommentedConfigurationNode> generation_loader
// = HoconConfigurationLoader.builder().setPath(potentialFile).build();
//
// try {
// pluginRef.getLogger().info("Config File Full Path: " + getDefaultConfigFile().getAbsolutePath());
// //Delete any existing default config
// if (getDefaultConfigFile().exists())
// getDefaultConfigFile().delete();
//
// //Make new file
// getDefaultConfigFile().createNewFile();
//
// //Load the config
// defaultRootNode = generation_loader.load();
//
// //Save to a new file
// generation_loader.save(defaultRootNode);
//
// pluginRef.getLogger().info("Generated a default file for " + fileName);
// } catch (IOException e) {
// pluginRef.getLogger().severe("Error when trying to generate a default configuration file for " + getDefaultConfigCopyRelativePath());
// e.printStackTrace();
// }
//
// //Return the default file
// return getDefaultConfigFile();
// }
//
// /**
// * Attemps to load the config file if it exists, if it doesn't it copies a new one from within the JAR
// *
// * @return user config File
// * @throws IOException
// * @see Config#resourceUserCopy
// */
// private File initUserConfig() throws IOException {
// File userCopy = new File(DIRECTORY_DATA_FOLDER, FILE_RELATIVE_PATH); //Load the user file;
//
// if (userCopy.exists()) {
// // Yay
// return userCopy;
// } else {
// //If it's gone we copy default files
// //Note that we don't copy the values from the default copy put in /defaults/ that file exists only as a reference to admins and is unreliable
// if (copyDefaults)
// return copyDefaultFromJar(FILE_RELATIVE_PATH, false);
// else {
// //Make a new empty file
// userCopy.createNewFile();
// return userCopy;
// }
// }
// }
//
// /**
// * Gets the File representation of the this users config
// *
// * @return the users config File
// */
// public File getUserConfigFile() {
// return new File(DIRECTORY_DATA_FOLDER, FILE_RELATIVE_PATH);
// }
//
// /**
// * Used to make a new config file at a specified relative output path inside the data directory by copying the matching file found in that same relative path within the JAR
// *
// * @param relativeOutputPath the path to the output file
// * @param deleteOld whether or not to delete the existing output file on disk
// * @return a copy of the default config within the JAR
// * @throws IOException
// */
// private File copyDefaultFromJar(String relativeOutputPath, boolean deleteOld) throws IOException {
// /*
// * Gen a Default config from inside the JAR
// */
// pluginRef.getLogger().info("Preparing to copy internal resource file (in JAR) - " + FILE_RELATIVE_PATH);
// //InputStream inputStream = McmmoCore.getResource(FILE_RELATIVE_PATH);
// InputStream inputStream = pluginRef.getResource(FILE_RELATIVE_PATH);
//
// byte[] buffer = new byte[inputStream.available()];
// inputStream.read(buffer);
//
// //This is a copy of the default file, which we will overwrite every time mcMMO loads
// File targetFile = new File(DIRECTORY_DATA_FOLDER, relativeOutputPath);
//
// //Wipe old default file on disk
// if (targetFile.exists() && deleteOld) {
// pluginRef.getLogger().info("Updating file " + relativeOutputPath);
// targetFile.delete(); //Necessary?
// }
//
// if (!targetFile.exists()) {
// targetFile.getParentFile().mkdirs();
// targetFile.createNewFile(); //New File Boys
// }
//
// Files.write(buffer, targetFile);
// pluginRef.getLogger().info("Created config file - " + relativeOutputPath);
//
// inputStream.close(); //Close the input stream
//
// return targetFile;
// }
//
// /**
// * The path to the defaults directory
// *
// * @return the path to the defaults directory
// */
// private String getDefaultConfigCopyRelativePath() {
// return getDefaultConfigFile().getPath();
// }
//
// /**
// * Grabs the File representation of the default config, which is stored on disk in a defaults folder
// * this file will be overwritten every time mcMMO starts to keep it up to date.
// *
// * @return the copy of the default config file, stored in the defaults directory
// */
// private File getDefaultConfigFile() {
// return new File(ConfigConstants.getDefaultsFolder(), FILE_RELATIVE_PATH);
// }
//
// /**
// * Creates the defaults directory
// */
// private void mkdirDefaults() {
// ConfigConstants.makeAllConfigDirectories();
// }
//
// /**
// * Configs are versioned based on when they had significant changes to keys
// *
// * @return current MainConfig Version String
// */
// public String getVersion() {
// return String.valueOf(getConfigVersion());
// }
//
// /**
// * Attempts to read the loaded config file
// * MainConfig will have any necessary updates applied
// * MainConfig will be compared to the default config to see if it is missing any nodes
// * MainConfig will have any missing nodes inserted with their default value
// */
// public void readConfig() {
// pluginRef.getLogger().info("Attempting to read " + FILE_RELATIVE_PATH + ".");
//
// int version = this.userRootNode.getNode("ConfigVersion").getInt();
// pluginRef.getLogger().info(FILE_RELATIVE_PATH + " version is " + version);
//
// //Update our config
// updateConfig();
// }
//
// /**
// * Compares the users config file to the default and adds any missing nodes and applies any necessary updates
// */
// private void updateConfig() {
// pluginRef.getLogger().info(defaultRootNode.getChildrenMap().size() + " items in default children map");
// pluginRef.getLogger().info(userRootNode.getChildrenMap().size() + " items in default root map");
//
// // Merge Values from default
// if (mergeNewKeys)
// userRootNode = userRootNode.mergeValuesFrom(defaultRootNode);
//
// removeOldKeys();
//
// // Update config version
// updateConfigVersion();
//
// //Attempt to save
// try {
// saveUserCopy();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// /**
// * Finds any keys in the users config that are not present in the default config and removes them
// */
// //TODO: Finish this
// private void removeOldKeys() {
// if (!removeOldKeys)
// return;
//
// for (CommentedConfigurationNode CommentedConfigurationNode : defaultRootNode.getChildrenList()) {
//
// }
// }
//
// /**
// * Saves the current state information of the config to the users copy (which they may edit)
// *
// * @throws IOException
// */
// private void saveUserCopy() throws IOException {
// pluginRef.getLogger().info("Saving new node");
// userCopyLoader.save(userRootNode);
// }
//
// /**
// * Performs any necessary operations to update this config
// */
// private void updateConfigVersion() {
// // Set a version for our config
// this.userRootNode.getNode("ConfigVersion").setValue(getConfigVersion());
// pluginRef.getLogger().info("Updated config to [" + getConfigVersion() + "] - " + FILE_RELATIVE_PATH);
// }
//
// /**
// * Returns the root node of this config
// *
// * @return the root node of this config
// */
// protected CommentedConfigurationNode getUserRootNode() {
// return userRootNode;
// }
//
// /**
// * Gets an int from the config and casts it to short before returning
// *
// * @param path the path to the int
// * @return the value of the int after being cast to short at the node, null references will zero initialize
// */
// public short getShortValue(String... path) {
// return (short) userRootNode.getNode(path).getInt();
// }
//
// /**
// * Grabs an int from the specified node
// *
// * @param path
// * @return the int from the node, null references will zero initialize
// */
// public int getIntValue(String... path) {
// return userRootNode.getNode(path).getInt();
// }
//
// /**
// * Grabs a double from the specified node
// *
// * @param path
// * @return the double from the node, null references will zero initialize
// */
// public double getDoubleValue(String... path) {
// return userRootNode.getNode(path).getDouble();
// }
//
// /**
// * Grabs a long from the specified node
// *
// * @param path
// * @return the long from the node, null references will zero initialize
// */
// public long getLongValue(String... path) {
// return userRootNode.getNode(path).getLong();
// }
//
// /**
// * Grabs a boolean from the specified node
// *
// * @param path
// * @return the boolean from the node, null references will zero initialize
// */
// public boolean getBooleanValue(String... path) {
// return userRootNode.getNode(path).getBoolean();
// }
//
// /**
// * Grabs a string from the specified node
// *
// * @param path
// * @return the string from the node, null references will zero initialize
// */
// public String getStringValue(String... path) {
// return userRootNode.getNode(path).getString();
// }
//
// /**
// * Checks to see if a node exists in the user's config file
// *
// * @param path path to the node
// * @return true if the node exists
// */
// public boolean hasNode(String... path) {
// return (userRootNode.getNode(path) != null);
// }
//
// /**
// * Returns the children of a specific node
// *
// * @param path the path to the parent node
// * @return the list of children for the target parent node
// */
// public List<? extends CommentedConfigurationNode> getChildren(String... path) {
// return userRootNode.getNode(path).getChildrenList();
// }
//
// public List<String> getListFromNode(String... path) throws ObjectMappingException {
// return userRootNode.getNode(path).getList(TypeToken.of(String.class));
// }
//}

View File

@@ -0,0 +1,20 @@
//package com.gmail.nossr50.config;
//
//
//import java.io.File;
//
///**
// * This class is used for config files that validate their entries
// */
//public abstract class ConfigValidated extends Config implements UnsafeValueValidation {
// /**
// * @param pathToParentFolder File for 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
// */
// public ConfigValidated(String fileName, File pathToParentFolder, String relativePath, boolean generateDefaults, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
// super(fileName, pathToParentFolder, relativePath, generateDefaults, mergeNewKeys, copyDefaults, removeOldKeys);
// validateEntries();
// }
//}

View File

@@ -0,0 +1,269 @@
//package com.gmail.nossr50.config;
//
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.StringUtils;
//import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
//import org.bukkit.Material;
//import org.bukkit.entity.EntityType;
//
//import java.util.ArrayList;
//import java.util.List;
//
//@ConfigSerializable
//public class MainConfig extends ConfigValidated {
//
// public static final String METRICS = "Metrics";
// public static final String BSTATS = "bstats";
// public static final String GENERAL = "General";
// public static final String RETRO_MODE = "RetroMode";
// public static final String ENABLED = "Enabled";
// public static final String LOCALE = "LocaleManager";
// public static final String EN_US = "en_us";
// public static final String SHOW_PROFILE_LOADED = "Show_Profile_Loaded";
// public static final String DONATE_MESSAGE = "Donate_Message";
// public static final String MCMMO = "mcmmo";
// public static final String DATABASE_PREFIX = MCMMO + "_";
// public static final String COMMANDS = "Commands";
// public static final String SAVE_INTERVAL = "Save_Interval";
// public static final String STATS = "Stats";
// public static final String STATS_TRACKING = STATS + "_Tracking";
// public static final String UPDATE_CHECK = "Update_Check";
// public static final String PREFER_BETA = "Prefer_Beta";
// public static final String VERBOSE_LOGGING = "Verbose_Logging";
// public static final String PARTYCHAT = "partychat";
// public static final String CHAT_PREFIX_FORMAT = "Chat_Prefix_Format";
// public static final String NAME = "Name";
// public static final String GOLD_LEADER_NAME = "Gold_Leader_" + NAME;
// public static final String USE_DISPLAY_NAMES = "Use_Display_" + NAME + "s";
// public static final String ALLY = "_Ally";
// public static final String ADMINCHAT = "adminchat";
// public static final String GENERIC = "Generic";
// public static final String MATCH_OFFLINE_PLAYERS = "Match_OfflinePlayers";
// public static final String DATABASE = "Database";
// public static final String COOLDOWN = "Cooldown";
// public static final String PLAYER_COOLDOWN = "Player_" + COOLDOWN;
// public static final String LEVEL_UP = "LevelUp_";
// public static final String SOUND = "Sound";
// public static final String LEVEL_UP_SOUNDS = "LevelUp_Sounds";
// public static final String REFRESH_CHUNKS = "Refresh_Chunks";
// public static final String MOB_HEALTHBAR = "Mob_Healthbar";
// public static final String DISPLAY_TYPE = "Display_Type";
// public static final String HEARTS = "HEARTS";
// public static final String DISPLAY_TIME = "Display_Time";
// public static final String SCOREBOARD = "ConfigScoreboard";
// public static final String USE_SCOREBOARDS = "UseScoreboards";
// public static final String POWER = "Power_";
// public static final String POWER_LEVEL_TAGS = POWER + "Level_Tags";
// public static final String KEEP = "Keep";
// public static final String ALLOW_KEEP = "Allow_" + KEEP;
// public static final String TIPS_AMOUNT = "Tips_Amount";
// public static final String SHOW_STATS_AFTER_LOGIN = "Show_" + STATS + "_After_Login";
// public static final String RAINBOWS = "Rainbows";
// public static final String ABILITY_NAMES = "Ability_" + NAME + "s";
// public static final String TYPES = "Types";
// public static final String RANK = "Rank";
// public static final String PRINT = "Print";
// public static final String BOARD = "Board";
// public static final String TOP = "Top";
// public static final String INSPECT = "Inspect";
// public static final String SKILL = "Skill";
// public static final String TIME = "Time";
// public static final String PURGING = "_Purging";
// public static final String PURGE_INTERVAL = "Purge_Interval";
// public static final String OLD_USER_CUTOFF = "Old_User_Cutoff";
// public static final String BACKUPS = "Backups";
// public static final String KEEP_LAST_24_HOURS = KEEP + ".Last_24_Hours";
// public static final String DAILY_LAST_WEEK = "Daily_Last_Week";
// public static final String WEEKLY_PAST_MONTHS = "Weekly_Past_Months";
// public static final String MY_SQL = "MySQL";
// public static final String TABLE_PREFIX = "TablePrefix";
// public static final String USER_NAME = "User_" + NAME;
// public static final String SERVER = "Server";
// public static final String PORT = "Port";
// public static final String ADDRESS = "Address";
// public static final String LOCALHOST = "localhost";
// public static final String USER_PASSWORD = "User_Password";
// public static final String MAX_CONNECTIONS = "MaxConnections";
// public static final String MAX_POOL_SIZE = "MaxPoolSize";
// public static final String SSL = "SSL";
// public static final String HARDCORE = "Hardcore";
// public static final String DEATH_STAT_LOSS = "Death_Stat_Loss";
// public static final String PENALTY_PERCENTAGE = "Penalty_Percentage";
// public static final String LEVEL_THRESHOLD = "Level_Threshold";
// public static final String VAMPIRISM = "Vampirism";
// public static final String LEECH_PERCENTAGE = "Leech_Percentage";
// public static final String ITEMS = "Items";
// public static final String CHIMAERA_WING = "Chimaera_Wing";
// public static final String USE_COST = "Use_Cost";
// public static final String RECIPE_COST = "Recipe_Cost";
// public static final String ITEM = "Item_";
// public static final String FEATHER = "Feather";
// public static final String PREVENT = "Prevent_";
// public static final String PREVENT_USE_UNDERGROUND = PREVENT + "Use_Underground";
// public static final String USE_BED_SPAWN = "Use_Bed_Spawn";
// public static final String WARMUP = "Warmup";
// public static final String RECENTLY_HURT = "RecentlyHurt_";
// public static final String PARTICLES = "Particles";
// public static final String ACTIVATION = "Activation";
// public static final String ABILITY_ACTIVATION = "Ability_" + ACTIVATION;
// public static final String ABILITY_DEACTIVATION = "Ability_Deactivation";
// public static final String BLEED = "Bleed";
// public static final String DODGE = "Dodge";
// public static final String FLUX = "Flux";
// public static final String GREATER_IMPACT = "Greater_Impact";
// public static final String CALL_OF_THE_WILD = "Call_of_the_Wild";
// public static final String TIER = "Tier";
// public static final String LARGE_FIREWORKS = "LargeFireworks";
// public static final String PARTY = "Party";
// public static final String FRIENDLY_FIRE = "FriendlyFire";
// public static final String MAX_SIZE = "MaxSize";
// public static final String AUTO_KICK_INTERVAL = "AutoKick_Interval";
// public static final String OLD_PARTY_MEMBER_CUTOFF = "Old_Party_Member_Cutoff";
// public static final String SHARING = "Sharing";
// public static final String SHARING_EXP_SHARE_BONUS_BASE = SHARING + "ExpShare_bonus_base";
// public static final String EXP_SHARE_BONUS_INCREASE = "ExpShare_bonus_increase";
// public static final String EXP_SHARE_BONUS_CAP = "ExpShare_bonus_cap";
// public static final String RANGE = "Range";
// public static final String LEVELING = "Leveling";
// public static final String LEVEL_CAP = "Level_Cap";
// public static final String XP_CURVE_MODIFIER = "Xp_Curve_Modifier";
// public static final String NEAR_MEMBERS_NEEDED = "Near_Members_Needed";
// public static final String INFORM_ALL_PARTY_MEMBERS_ON_LEVEL_UP = "Inform_All_Party_Members_On_LevelUp";
// public static final String UNLOCK_LEVEL = "_UnlockLevel";
// public static final String PTP = "ptp";
// public static final String ACCEPT_REQUIRED = "Accept_Required";
// public static final String REQUEST_TIMEOUT = "Request_Timeout";
// public static final String WORLD_BASED_PERMISSIONS = "World_Based_Permissions";
// public static final String INSPECT1 = "inspect";
// public static final String MAX_DISTANCE = "Max_Distance";
// public static final String SKILLS = "Skills";
// public static final String URL_LINKS = "URL_Links";
// public static final String ABILITIES = "Abilities";
// public static final String MESSAGES = "Messages";
// public static final String ONLY_ACTIVATE_WHEN_SNEAKING = "Only_Activate_When_Sneaking";
// public static final String LEVEL_GATE_ABILITIES = "Level_Gate_Abilities";
// public static final String COOLDOWNS = "Cooldowns";
// public static final String MAX_SECONDS = "Max_Seconds";
// public static final String TOOLS = "Tools";
// public static final String DURABILITY_LOSS = "Durability_Loss";
// public static final String LIMITS = "Limits";
// public static final String TREE_FELLER = "Tree_Feller_";
// public static final String TREE_FELLER_THRESHOLD = TREE_FELLER + "Threshold";
// public static final String DOUBLE_DROPS = "Double_Drops";
// public static final String AXES = "Axes";
// public static final String TRUNCATE = "Truncate";
// public static final String FOR_PVP = "_For_PVP";
// public static final String FOR_PVE = "_For_PVE";
// public static final String ACROBATICS = "Acrobatics";
// public static final String PREVENT_AFK = PREVENT + "AFK_";
// public static final String WOODCUTTING = "Woodcutting";
// public static final String SOUNDS = "Sounds";
// public static final String MAX_TRIES_AT_SAME_LOCATION = "Max_Tries_At_Same_Location";
// public static final String HERBALISM = "Herbalism";
// public static final String TAMING = "Taming";
// public static final String CALL_OF_THE_WILD1 = "Call_Of_The_Wild";
// public static final String SUMMON_AMOUNT = "Summon_Amount";
// public static final String SUMMON_LENGTH = "Summon_Length";
// public static final String SUMMON_MAX_AMOUNT = "Summon_Max_Amount";
// public static final String AMOUNT = "Amount";
// public static final String MATERIAL = "Material";
// public static final String REPAIR = "Repair";
// public static final String CONFIRM_REQUIRED = "Confirm_Required";
// public static final String ANVIL = "Anvil_";
// public static final String ANVIL_MATERIAL = ANVIL + "Material";
// public static final String IRON_BLOCK = "IRON_BLOCK";
// public static final String ANVIL_USE = ANVIL + "Use_";
// public static final String ANVIL_PLACED = ANVIL + "Placed_";
// public static final String SALVAGE = "Salvage";
// public static final String UNARMED = "Unarmed";
// public static final String BLOCK_CRACKER = "Block_Cracker";
// public static final String SMOOTH_BRICK_TO_CRACKED_BRICK = "SmoothBrick_To_CrackedBrick";
// public static final String PICKUP_DISABLED_FULL_INVENTORY = "Pickup_Disabled_Full_Inventory";
// public static final String AS = "_As_";
// public static final String MINING = "Mining";
// public static final String DETONATOR = "Detonator_";
// public static final String FLINT_AND_STEEL = "FLINT_AND_STEEL";
// public static final String FISHING = "Fishing";
// public static final String LURE_MODIFIER = "Lure_Modifier";
// public static final String EXTRA_FISH = "Extra_Fish";
// public static final String OVERRIDE_VANILLA_TREASURES = "Override_Vanilla_Treasures";
// public static final String DROPS = "Drops_";
// public static final String ALCHEMY = "Alchemy";
// public static final String PREVENT_HOPPER_TRANSFER_BOTTLES = PREVENT + "Hopper_Transfer_Bottles";
// public static final String PREVENT_HOPPER_TRANSFER_INGREDIENTS = PREVENT + "Hopper_Transfer_Ingredients";
// public static final String FOR_HOPPERS = "_for_Hoppers";
// public static final String XP_AFTER_TELEPORT = "XP_After_Teleport_";
// public static final String LIGHTNING = "_Lightning";
// public static final String GOLD_BLOCK = "GOLD_BLOCK";
// public static final String PICKAXE = "_Pickaxe";
// public static final String EXP_SHARE_BONUS_BASE = "ExpShare_bonus_base";
//
// public MainConfig() {
// //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "config.yml", true);
// super("main", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true);
// }
//
// /**
// * This grabs an instance of this config 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 MainConfig getInstance() {
// return pluginRef.getConfigManager().getMainConfig();
// }
//
// /**
// * The version of this config
// *
// * @return
// */
// @Override
// public double getConfigVersion() {
// return 1;
// }
//
// @Override
// public List<String> validateKeys() {
// // Validate all the settings!
// List<String> reason = new ArrayList<>();
// return reason;
// }
//
// public boolean getPreventHopperTransferIngredients() {
// return getBooleanValue(SKILLS, ALCHEMY, PREVENT_HOPPER_TRANSFER_INGREDIENTS);
// }
//
// public boolean getPreventHopperTransferBottles() {
// return getBooleanValue(SKILLS, ALCHEMY, PREVENT_HOPPER_TRANSFER_BOTTLES);
// }
//
// /* Taming */
// public Material getTamingCOTWMaterial(EntityType type) {
// return Material.matchMaterial(getStringValue(SKILLS, TAMING, CALL_OF_THE_WILD1, StringUtils.getPrettyEntityTypeString(type), ITEM + MATERIAL));
// }
//
// public int getTamingCOTWCost(EntityType type) {
// return getIntValue(SKILLS, TAMING, CALL_OF_THE_WILD1, StringUtils.getPrettyEntityTypeString(type), ITEM + AMOUNT);
// }
//
// public int getTamingCOTWAmount(EntityType type) {
// return getIntValue(SKILLS, TAMING, CALL_OF_THE_WILD1, StringUtils.getPrettyEntityTypeString(type), SUMMON_AMOUNT);
// }
//
// public int getTamingCOTWLength(EntityType type) {
// return getIntValue(SKILLS, TAMING, CALL_OF_THE_WILD1, StringUtils.getPrettyEntityTypeString(type), SUMMON_LENGTH);
// }
//
// public int getTamingCOTWMaxAmount(EntityType type) {
// return getIntValue(SKILLS, TAMING, CALL_OF_THE_WILD1, StringUtils.getPrettyEntityTypeString(type), SUMMON_MAX_AMOUNT);
// }
//
// public double getTamingCOTWRange() {
// return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD1, RANGE);
// }
//
//}

View File

@@ -0,0 +1,27 @@
//package com.gmail.nossr50.config;
//
//import java.util.List;
//
///**
// * This is for config validation
// */
//public interface UnsafeValueValidation {
// List<String> validateKeys();
//
// /**
// * Prints all errors found when validating the config
// */
// default void validateEntries() {
// /*
// * Print Errors about Keys
// */
//
// List<String> validKeyErrors = validateKeys(); // Validate Keys
//
// if (validKeyErrors != null && validKeyErrors.size() > 0) {
// for (String error : validKeyErrors) {
// pluginRef.getLogger().severe(error);
// }
// }
// }
//}