mcMMO/src/main/java/com/gmail/nossr50/config/ConfigCollection.java

50 lines
1.2 KiB
Java
Raw Normal View History

2019-02-16 16:09:48 -08:00
package com.gmail.nossr50.config;
import java.io.File;
import java.util.ArrayList;
2019-02-16 16:09:48 -08:00
import java.util.Collection;
/**
* Represents a config file that registers keys after its initialized
*/
public abstract class ConfigCollection<T> extends Config implements Registers, GenericCollectionContainer {
//The collection held by this class
protected Collection<T> genericCollection;
public ConfigCollection(String pathToParentFolder, String relativePath, boolean mergeNewKeys) {
super(pathToParentFolder, relativePath, mergeNewKeys);
//init
initCollection();
//load
register();
}
private void initCollection() {
if (genericCollection == null)
genericCollection = new ArrayList<>();
}
public ConfigCollection(File pathToParentFolder, String relativePath, boolean mergeNewKeys) {
super(pathToParentFolder, relativePath, mergeNewKeys);
//init
initCollection();
//load
register();
}
@Override
public Collection<T> getLoadedCollection() {
return this.genericCollection;
}
@Override
public void unload() {
genericCollection.clear();
}
2019-02-16 16:09:48 -08:00
}