|
@@ -1,3 +1,4 @@
|
|
|
|
+/*
|
|
package com.gmail.nossr50.config.collectionconfigs;
|
|
package com.gmail.nossr50.config.collectionconfigs;
|
|
|
|
|
|
import com.gmail.nossr50.config.ConfigCollection;
|
|
import com.gmail.nossr50.config.ConfigCollection;
|
|
@@ -9,16 +10,22 @@ import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
+*/
|
|
/**
|
|
/**
|
|
* Represents a type of config collection, these config collections are spread across multiple config files potentially
|
|
* Represents a type of config collection, these config collections are spread across multiple config files potentially
|
|
* @param <T>
|
|
* @param <T>
|
|
- */
|
|
|
|
|
|
+ *//*
|
|
|
|
+
|
|
public class MultiConfigContainer<T> implements Unload {
|
|
public class MultiConfigContainer<T> implements Unload {
|
|
|
|
|
|
- /* CONSTANTS */
|
|
|
|
|
|
+ */
|
|
|
|
+/* CONSTANTS *//*
|
|
|
|
+
|
|
public static final String DEFAULT_MULTICONFIG_FILENAME_SUFFIX = ".vanilla.yml";
|
|
public static final String DEFAULT_MULTICONFIG_FILENAME_SUFFIX = ".vanilla.yml";
|
|
|
|
|
|
- /* VARS */
|
|
|
|
|
|
+ */
|
|
|
|
+/* VARS *//*
|
|
|
|
+
|
|
private final String configPrefix;
|
|
private final String configPrefix;
|
|
private Collection<T> collection;
|
|
private Collection<T> collection;
|
|
public final CollectionClassType collectionClassType;
|
|
public final CollectionClassType collectionClassType;
|
|
@@ -50,20 +57,24 @@ public class MultiConfigContainer<T> implements Unload {
|
|
loadCustomCollections(configPrefix);
|
|
loadCustomCollections(configPrefix);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ */
|
|
|
|
+/**
|
|
* Add another collection to this collection
|
|
* Add another collection to this collection
|
|
* @param otherCollection
|
|
* @param otherCollection
|
|
- */
|
|
|
|
|
|
+ *//*
|
|
|
|
+
|
|
private void addCollection(Collection<T> otherCollection)
|
|
private void addCollection(Collection<T> otherCollection)
|
|
{
|
|
{
|
|
collection.addAll(otherCollection);
|
|
collection.addAll(otherCollection);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ */
|
|
|
|
+/**
|
|
* Grabs the Class to instance for this config collection
|
|
* Grabs the Class to instance for this config collection
|
|
* @param collectionClassType the type of class
|
|
* @param collectionClassType the type of class
|
|
* @return the class to instance for this config collection
|
|
* @return the class to instance for this config collection
|
|
- */
|
|
|
|
|
|
+ *//*
|
|
|
|
+
|
|
private Class getConfigClass(CollectionClassType collectionClassType)
|
|
private Class getConfigClass(CollectionClassType collectionClassType)
|
|
{
|
|
{
|
|
switch(collectionClassType) {
|
|
switch(collectionClassType) {
|
|
@@ -77,22 +88,26 @@ public class MultiConfigContainer<T> implements Unload {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ */
|
|
|
|
+/**
|
|
* Gets the name of the vanilla config which is always present
|
|
* Gets the name of the vanilla config which is always present
|
|
* @param configPrefix the prefix to the filename, for example "repair" or "salvage"
|
|
* @param configPrefix the prefix to the filename, for example "repair" or "salvage"
|
|
* @return the name of the vanilla config file for this collection
|
|
* @return the name of the vanilla config file for this collection
|
|
- */
|
|
|
|
|
|
+ *//*
|
|
|
|
+
|
|
private String getVanillaConfigName(String configPrefix)
|
|
private String getVanillaConfigName(String configPrefix)
|
|
{
|
|
{
|
|
return configPrefix+DEFAULT_MULTICONFIG_FILENAME_SUFFIX;
|
|
return configPrefix+DEFAULT_MULTICONFIG_FILENAME_SUFFIX;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ */
|
|
|
|
+/**
|
|
* Initializes a config and attempts to load add its collection
|
|
* Initializes a config and attempts to load add its collection
|
|
* @param fileName
|
|
* @param fileName
|
|
* @param merge
|
|
* @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 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)
|
|
private void initConfigAndAddCollection(String fileName, boolean merge, boolean copyDefaults)
|
|
{
|
|
{
|
|
mcMMO.p.getLogger().info("Reading from collection config - "+fileName);
|
|
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);
|
|
configCollection = new SalvageConfig(fileName, merge, copyDefaults);
|
|
}
|
|
}
|
|
|
|
|
|
- /*try {
|
|
|
|
|
|
+ */
|
|
|
|
+/*try {
|
|
//String parentFolderPath, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys
|
|
//String parentFolderPath, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys
|
|
//String fileName, boolean merge, boolean copyDefaults
|
|
//String fileName, boolean merge, boolean copyDefaults
|
|
configCollection = (ConfigCollection) getConfigClass(collectionClassType).getConstructor(String.class, Boolean.class, Boolean.class).newInstance(fileName, merge, 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();
|
|
e.printStackTrace();
|
|
} catch (NoSuchMethodException e) {
|
|
} catch (NoSuchMethodException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- }*/
|
|
|
|
|
|
+ }*//*
|
|
|
|
+
|
|
|
|
|
|
//Add the collection loaded from this config
|
|
//Add the collection loaded from this config
|
|
addCollection(configCollection.getLoadedCollection());
|
|
addCollection(configCollection.getLoadedCollection());
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ */
|
|
|
|
+/**
|
|
* mcMMO allows collection config files to be named things like repair.whatevernameyouwanthere.yml and so on,
|
|
* 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
|
|
* 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
|
|
* @param configPrefix the prefix of the file name, for example "repair", "salvage", etc
|
|
- */
|
|
|
|
|
|
+ *//*
|
|
|
|
+
|
|
public void loadCustomCollections(String configPrefix)
|
|
public void loadCustomCollections(String configPrefix)
|
|
{
|
|
{
|
|
String vanillaConfigFileName = getVanillaConfigName(configPrefix);
|
|
String vanillaConfigFileName = getVanillaConfigName(configPrefix);
|
|
@@ -163,3 +182,4 @@ public class MultiConfigContainer<T> implements Unload {
|
|
return collection;
|
|
return collection;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+*/
|