= Format revision
This commit is contained in:
+19
-5
@@ -3,25 +3,39 @@ import java.nio.file.Path;
|
||||
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
import utils.io.MonitoredFile;
|
||||
import utils.io.FileMonitor;
|
||||
|
||||
public class Config
|
||||
{
|
||||
private static final Path filepath = Constants.AssetDirectory + Constants.ConfigFilename;
|
||||
MonitoredFile configFile;
|
||||
private static final String filepath = Constants.AssetDirectory + Constants.ConfigFilename;
|
||||
FileMonitor configFile;
|
||||
|
||||
Config instance;
|
||||
public static Config instance;
|
||||
|
||||
// Accessable config related things
|
||||
public LocStrings locStrings;
|
||||
public LocCommands locCommands;
|
||||
public CommandEnabler commandEnabler;
|
||||
|
||||
public Config()
|
||||
{
|
||||
if(instance == null)
|
||||
{
|
||||
configFile = new MonitoredFile(filepath);
|
||||
// Start by reading from things that are external. Because
|
||||
// we require these things to be resolved before the rest of the application,
|
||||
// we place them here.
|
||||
configFile = new FileMonitor(filepath);
|
||||
|
||||
commandEnabler = new CommandEnabler();
|
||||
locStrings = new LocStrings();
|
||||
locCommands = new LocCommands();
|
||||
|
||||
instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.error(LogFilter.Core, "You can't have two of the following: " + this.getClass().getSimpleName());
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,4 @@ public class LocStrings extends BaseLocFile
|
||||
{
|
||||
return instance.getKey(stubbedPreviously);
|
||||
}
|
||||
|
||||
public static void upkeep()
|
||||
{
|
||||
instance.update();
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,8 @@ public class ObjectBuilderFactory
|
||||
@SuppressWarnings("unused") private static LocStrings locStrings;
|
||||
@SuppressWarnings("unused") private static LocCommands locCommands;
|
||||
|
||||
// Handles if we can or can't use specific commands, parsing a config file based on loc data to do so.
|
||||
private static CommandEnabler commandEnabler;
|
||||
// Config
|
||||
private static Config config;
|
||||
|
||||
// Lazy initialization multithreaded mutex stuff to prevent explosions.
|
||||
// TODO: Investigate using 'synchronized' instead potentially
|
||||
@@ -85,11 +85,8 @@ public class ObjectBuilderFactory
|
||||
database = null;
|
||||
stats = null;
|
||||
|
||||
// Start by reading from things that are external. Because
|
||||
// we require these things to be resolved before the rest of the application,
|
||||
// we place them here.
|
||||
locStrings = new LocStrings();
|
||||
locCommands = new LocCommands();
|
||||
// Create the config. We need to do this all first.
|
||||
config = new Config();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -442,17 +439,6 @@ public class ObjectBuilderFactory
|
||||
return manager;
|
||||
}
|
||||
|
||||
// Constructs a CommandEnabler if it doesn't exist, and gets the existing one if it does.
|
||||
public static CommandEnabler constructCommandEnabler()
|
||||
{
|
||||
lazyInit();
|
||||
|
||||
if(commandEnabler == null)
|
||||
commandEnabler = new CommandEnabler();
|
||||
|
||||
return commandEnabler;
|
||||
}
|
||||
|
||||
// Default database manager construction. It can be constructed
|
||||
// in different ways, and so we construct it outside of the constructor for
|
||||
// the factory since it doesn't have to be present / can be elsewhere.
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package core;
|
||||
|
||||
public class Settings {
|
||||
|
||||
}
|
||||
+2
-3
@@ -7,6 +7,7 @@ import javax.security.auth.login.LoginException;
|
||||
import core.CharacterManager;
|
||||
import core.CommandEnabler;
|
||||
import core.CommandManager;
|
||||
import core.Config;
|
||||
import core.DatabaseManager;
|
||||
import core.ObjectBuilderFactory;
|
||||
import core.RPManager;
|
||||
@@ -36,7 +37,6 @@ public class Main extends ListenerAdapter
|
||||
// Variables and bot specific objects
|
||||
private static KittyCore kittyCore;
|
||||
private static DatabaseManager databaseManager;
|
||||
private static CommandEnabler commandEnabler;
|
||||
private static CommandManager commandManager;
|
||||
private static Stats stats;
|
||||
private static RPManager rpManager;
|
||||
@@ -49,8 +49,7 @@ public class Main extends ListenerAdapter
|
||||
// Factory startup. The ordering is intentional.
|
||||
GlobalLog.initialize();
|
||||
databaseManager = ObjectBuilderFactory.constructDatabaseManager();
|
||||
commandEnabler = ObjectBuilderFactory.constructCommandEnabler();
|
||||
commandManager = ObjectBuilderFactory.constructCommandManager(commandEnabler);
|
||||
commandManager = ObjectBuilderFactory.constructCommandManager(Config.instance.commandEnabler);
|
||||
stats = ObjectBuilderFactory.constructStats(commandManager);
|
||||
charManager = new CharacterManager();
|
||||
rpManager = ObjectBuilderFactory.constructRPManager();
|
||||
|
||||
@@ -12,7 +12,7 @@ public class MonitoredFile implements Comparable<Object>
|
||||
this.path = path;
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
|
||||
|
||||
// Override equals operator - used for .contains(...) on list items
|
||||
@Override
|
||||
public boolean equals(Object other)
|
||||
|
||||
Reference in New Issue
Block a user