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