mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-01 21:24:43 +02:00
fixing many compiler errors for configs
This commit is contained in:
@ -3,6 +3,7 @@ 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;
|
||||
@ -33,8 +34,11 @@ public abstract class Config implements VersionedConfig, Unload {
|
||||
|
||||
/* LOADERS */
|
||||
|
||||
private ConfigurationLoader<CommentedConfigurationNode> defaultCopyLoader;
|
||||
private ConfigurationLoader<CommentedConfigurationNode> userCopyLoader;
|
||||
private YAMLConfigurationLoader defaultCopyLoader;
|
||||
private YAMLConfigurationLoader userCopyLoader;
|
||||
|
||||
//private ConfigurationLoader<CommentedConfigurationNode> defaultCopyLoader;
|
||||
//private ConfigurationLoader<CommentedConfigurationNode> userCopyLoader;
|
||||
|
||||
/* CONFIG FILES */
|
||||
|
||||
@ -43,8 +47,8 @@ public abstract class Config implements VersionedConfig, Unload {
|
||||
|
||||
/* ROOT NODES */
|
||||
|
||||
private CommentedConfigurationNode userRootNode = null;
|
||||
private CommentedConfigurationNode defaultRootNode = null;
|
||||
private ConfigurationNode userRootNode = null;
|
||||
private ConfigurationNode defaultRootNode = null;
|
||||
|
||||
/* CONFIG MANAGER */
|
||||
//private ConfigurationLoader<CommentedConfigurationNode> configManager;
|
||||
@ -124,10 +128,10 @@ public abstract class Config implements VersionedConfig, Unload {
|
||||
private void loadConfig()
|
||||
{
|
||||
try {
|
||||
final CommentedConfigurationNode defaultConfig = this.defaultCopyLoader.load();
|
||||
final ConfigurationNode defaultConfig = this.defaultCopyLoader.load();
|
||||
defaultRootNode = defaultConfig;
|
||||
|
||||
final CommentedConfigurationNode userConfig = this.userCopyLoader.load();
|
||||
final ConfigurationNode userConfig = this.userCopyLoader.load();
|
||||
userRootNode = userConfig;
|
||||
|
||||
} catch (IOException e) {
|
||||
@ -311,7 +315,7 @@ public abstract class Config implements VersionedConfig, Unload {
|
||||
if(!removeOldKeys)
|
||||
return;
|
||||
|
||||
for(CommentedConfigurationNode configurationNode : defaultRootNode.getChildrenList())
|
||||
for(ConfigurationNode configurationNode : defaultRootNode.getChildrenList())
|
||||
{
|
||||
|
||||
}
|
||||
@ -340,7 +344,7 @@ public abstract class Config implements VersionedConfig, Unload {
|
||||
* Returns the root node of this config
|
||||
* @return the root node of this config
|
||||
*/
|
||||
protected CommentedConfigurationNode getUserRootNode() {
|
||||
protected ConfigurationNode getUserRootNode() {
|
||||
return userRootNode;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class MultiConfigContainer<T> implements Unload {
|
||||
//Load Configs
|
||||
|
||||
//Vanilla Config
|
||||
initConfigAndAddCollection(mcMMO.p.getDataFolder().getAbsolutePath(),getVanillaConfigName(configPrefix), false, true, false);
|
||||
initConfigAndAddCollection(getVanillaConfigName(configPrefix), false, true);
|
||||
|
||||
//Custom Configs
|
||||
loadCustomCollections(configPrefix);
|
||||
@ -90,20 +90,19 @@ public class MultiConfigContainer<T> implements Unload {
|
||||
|
||||
/**
|
||||
* Initializes a config and attempts to load add its collection
|
||||
* @param parentFolderPath 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 fileName
|
||||
* @param merge
|
||||
* @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
|
||||
*/
|
||||
private void initConfigAndAddCollection(String parentFolderPath, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys)
|
||||
private void initConfigAndAddCollection(String fileName, boolean merge, boolean copyDefaults)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Reading from collection config - "+relativePath);
|
||||
mcMMO.p.getLogger().info("Reading from collection config - "+fileName);
|
||||
ConfigCollection configCollection = null;
|
||||
|
||||
try {
|
||||
//String parentFolderPath, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys
|
||||
configCollection = (ConfigCollection) getConfigClass(collectionClassType).getConstructor(String.class, String.class, Boolean.class, Boolean.class, Boolean.class).newInstance(parentFolderPath, relativePath, mergeNewKeys, copyDefaults, removeOldKeys);
|
||||
//String fileName, boolean merge, boolean copyDefaults
|
||||
configCollection = (ConfigCollection) getConfigClass(collectionClassType).getConstructor(String.class, Boolean.class, Boolean.class).newInstance(fileName, merge, copyDefaults);
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
@ -150,7 +149,7 @@ public class MultiConfigContainer<T> implements Unload {
|
||||
continue;
|
||||
|
||||
//Load and add the collections
|
||||
initConfigAndAddCollection(dataFolder.getAbsolutePath(), fileName, false, false, false);
|
||||
initConfigAndAddCollection(fileName, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,9 @@ public class RepairConfig extends ConfigCollection {
|
||||
public static final String MINIMUM_LEVEL = "MinimumLevel";
|
||||
public static final String MINIMUM_QUANTITY = "MinimumQuantity";
|
||||
|
||||
public RepairConfig(String fileName, boolean merge) {
|
||||
public RepairConfig(String fileName, boolean merge, boolean copyDefaults) {
|
||||
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false);
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), fileName, false, merge);
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), fileName, merge, copyDefaults, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,9 +27,9 @@ public class SalvageConfig extends ConfigCollection {
|
||||
public static final String XP_MULTIPLIER = "XpMultiplier";
|
||||
public static final String MAXIMUM_QUANTITY = "MaximumQuantity";
|
||||
|
||||
public SalvageConfig(String fileName, boolean merge) {
|
||||
public SalvageConfig(String fileName, boolean merge, boolean copyDefaults) {
|
||||
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false);
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), fileName, false, merge);
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), fileName, merge, copyDefaults, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.config.skills.alchemy;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.ConfigCollection;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -67,6 +68,18 @@ public class PotionConfig extends ConfigCollection {
|
||||
register();
|
||||
}
|
||||
|
||||
/**
|
||||
* This grabs an instance of this config class from the Config Manager
|
||||
* This method is deprecated and will be removed in the future
|
||||
* @see mcMMO#getConfigManager()
|
||||
* @return the instance of this config
|
||||
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static PotionConfig getInstance() {
|
||||
return mcMMO.getConfigManager().getPotionConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of this config
|
||||
*
|
||||
|
@ -3,14 +3,16 @@ package com.gmail.nossr50.config.treasure;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.Registers;
|
||||
import com.gmail.nossr50.config.UnsafeValueValidation;
|
||||
import com.gmail.nossr50.datatypes.treasure.*;
|
||||
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
|
@ -11,9 +11,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
Reference in New Issue
Block a user