mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-02 21:54:43 +02:00
no more MultiConfigContainers, updating existing config classes for HOCON (WIP)
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
/*
|
||||
package com.gmail.nossr50.config.collectionconfigs;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigCollection;
|
||||
@ -9,16 +10,22 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
*/
|
||||
/**
|
||||
* Represents a type of config collection, these config collections are spread across multiple config files potentially
|
||||
* @param <T>
|
||||
*/
|
||||
*//*
|
||||
|
||||
public class MultiConfigContainer<T> implements Unload {
|
||||
|
||||
/* CONSTANTS */
|
||||
*/
|
||||
/* CONSTANTS *//*
|
||||
|
||||
public static final String DEFAULT_MULTICONFIG_FILENAME_SUFFIX = ".vanilla.yml";
|
||||
|
||||
/* VARS */
|
||||
*/
|
||||
/* VARS *//*
|
||||
|
||||
private final String configPrefix;
|
||||
private Collection<T> collection;
|
||||
public final CollectionClassType collectionClassType;
|
||||
@ -50,20 +57,24 @@ public class MultiConfigContainer<T> implements Unload {
|
||||
loadCustomCollections(configPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
/**
|
||||
* Add another collection to this collection
|
||||
* @param otherCollection
|
||||
*/
|
||||
*//*
|
||||
|
||||
private void addCollection(Collection<T> otherCollection)
|
||||
{
|
||||
collection.addAll(otherCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
/**
|
||||
* Grabs the Class to instance for this config collection
|
||||
* @param collectionClassType the type of class
|
||||
* @return the class to instance for this config collection
|
||||
*/
|
||||
*//*
|
||||
|
||||
private Class getConfigClass(CollectionClassType collectionClassType)
|
||||
{
|
||||
switch(collectionClassType) {
|
||||
@ -77,22 +88,26 @@ public class MultiConfigContainer<T> implements Unload {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
/**
|
||||
* Gets the name of the vanilla config which is always present
|
||||
* @param configPrefix the prefix to the filename, for example "repair" or "salvage"
|
||||
* @return the name of the vanilla config file for this collection
|
||||
*/
|
||||
*//*
|
||||
|
||||
private String getVanillaConfigName(String configPrefix)
|
||||
{
|
||||
return configPrefix+DEFAULT_MULTICONFIG_FILENAME_SUFFIX;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
/**
|
||||
* Initializes a config and attempts to load add its collection
|
||||
* @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
|
||||
*/
|
||||
*//*
|
||||
|
||||
private void initConfigAndAddCollection(String fileName, boolean merge, boolean copyDefaults)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Reading from collection config - "+fileName);
|
||||
@ -105,7 +120,8 @@ public class MultiConfigContainer<T> implements Unload {
|
||||
configCollection = new SalvageConfig(fileName, merge, copyDefaults);
|
||||
}
|
||||
|
||||
/*try {
|
||||
*/
|
||||
/*try {
|
||||
//String parentFolderPath, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys
|
||||
//String fileName, boolean merge, boolean copyDefaults
|
||||
configCollection = (ConfigCollection) getConfigClass(collectionClassType).getConstructor(String.class, Boolean.class, Boolean.class).newInstance(fileName, merge, copyDefaults);
|
||||
@ -117,17 +133,20 @@ public class MultiConfigContainer<T> implements Unload {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
}*//*
|
||||
|
||||
|
||||
//Add the collection loaded from this config
|
||||
addCollection(configCollection.getLoadedCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
/**
|
||||
* mcMMO allows collection config files to be named things like repair.whatevernameyouwanthere.yml and so on,
|
||||
* these files are treated in the same way as the vanilla file. They serve the purpose of organization
|
||||
* @param configPrefix the prefix of the file name, for example "repair", "salvage", etc
|
||||
*/
|
||||
*//*
|
||||
|
||||
public void loadCustomCollections(String configPrefix)
|
||||
{
|
||||
String vanillaConfigFileName = getVanillaConfigName(configPrefix);
|
||||
@ -163,3 +182,4 @@ public class MultiConfigContainer<T> implements Unload {
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.config.collectionconfigs;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigCollection;
|
||||
import com.gmail.nossr50.config.ConfigConstants;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -9,6 +10,7 @@ import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -18,6 +20,7 @@ import java.util.List;
|
||||
/**
|
||||
* This config
|
||||
*/
|
||||
@ConfigSerializable
|
||||
public class RepairConfig extends ConfigCollection {
|
||||
|
||||
public static final String REPAIRABLES = "Repairables";
|
||||
@ -31,9 +34,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, boolean copyDefaults) {
|
||||
public RepairConfig() {
|
||||
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false);
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), fileName, merge, copyDefaults, false);
|
||||
super("repair", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_SKILLS_DIR, true, false, true, false);
|
||||
register();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.config.collectionconfigs;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigCollection;
|
||||
import com.gmail.nossr50.config.ConfigConstants;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -9,12 +10,14 @@ import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ConfigSerializable
|
||||
public class SalvageConfig extends ConfigCollection {
|
||||
|
||||
public static final String SALVAGEABLES = "Salvageables";
|
||||
@ -27,9 +30,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, boolean copyDefaults) {
|
||||
public SalvageConfig() {
|
||||
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false);
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), fileName, merge, copyDefaults, false);
|
||||
super("salvage", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_SKILLS_DIR, true, false, true, false);
|
||||
register();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user