= Migrated to CSV
This commit is contained in:
+28
-5
@@ -2,11 +2,15 @@ package core;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import utils.io.FileMonitor;
|
||||
|
||||
public class Config
|
||||
{
|
||||
ConfigCSV configCSV;
|
||||
List<IConfigSection> sections;
|
||||
private static final String filepath = Constants.AssetDirectory + Constants.ConfigFilename;
|
||||
|
||||
private ConfigCSV configCSV;
|
||||
private List<IConfigSection> sections;
|
||||
private FileMonitor monitoredConfigFile;
|
||||
|
||||
public static Config instance;
|
||||
|
||||
@@ -15,10 +19,16 @@ public class Config
|
||||
if(instance == null)
|
||||
{
|
||||
sections = new Vector<IConfigSection>();
|
||||
|
||||
configCSV = new ConfigCSV(sections, "./config.csv");
|
||||
configCSV.writeFile();
|
||||
|
||||
// Add all sections
|
||||
sections.add(new LocCommands());
|
||||
sections.add(new LocStrings());
|
||||
sections.add(new CommandEnabler());
|
||||
|
||||
// Being monitoring configs and mark this as the instance now that it's made
|
||||
monitoredConfigFile = new FileMonitor(filepath);
|
||||
build(filepath);
|
||||
|
||||
instance = this;
|
||||
}
|
||||
else
|
||||
@@ -28,4 +38,17 @@ public class Config
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public void build(String path)
|
||||
{
|
||||
configCSV = new ConfigCSV(sections, path);
|
||||
configCSV.writeFile();
|
||||
}
|
||||
|
||||
public void upkeep()
|
||||
{
|
||||
monitoredConfigFile.update((monitoredFile) -> {
|
||||
build(monitoredFile.path.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user