Interface additions and global changes to allow config to be modified

This commit is contained in:
Dave
2014-12-21 16:35:21 +02:00
parent 902a00d625
commit 219253c518
4 changed files with 77 additions and 36 deletions

View File

@@ -19,7 +19,7 @@
package nodash.core;
import java.io.File;
import java.io.IOException;
import java.security.PublicKey;
import nodash.core.spheres.NoByteSetSphere;
@@ -39,23 +39,31 @@ import nodash.models.NoUser;
import nodash.models.NoSession.NoState;
public final class NoCore {
public static NoConfig config;
public static NoConfigInterface config;
public static NoHashSphereInterface hashSphere;
public static void setup(NoConfigInterface config, NoHashSphereInterface hashSphere) {
NoCore.setup(config);
NoCore.setup(hashSphere);
}
public static void setup(NoConfigInterface config) {
NoCore.config = config;
}
public static void setup(NoHashSphereInterface hashSphere) {
File configFile = new File(NoConfig.CONFIG_FILENAME);
if (configFile.exists()) {
config = NoConfig.getNoConfigFromFile(configFile);
} else {
config = new NoConfig();
config.saveNoConfigToFile(configFile);
}
NoCore.hashSphere = hashSphere;
hashSphere.setup();
}
public static void setup() {
NoCore.setup(new NoHashSphereDefault());
NoConfigInterface newConfig = new NoConfigDefault();
try {
newConfig = newConfig.loadNoConfig();
} catch (IOException e) {
newConfig.construct();
}
NoCore.setup(newConfig, new NoHashSphereDefault());
}
public static byte[] login(byte[] data, char[] password) throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException {