2019-08-25 12:39:08 +03:00
|
|
|
package pro.gravit.launchserver;
|
|
|
|
|
|
|
|
import pro.gravit.launchserver.config.LaunchServerConfig;
|
|
|
|
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
|
2019-10-17 16:22:24 +03:00
|
|
|
import pro.gravit.launchserver.manangers.CertificateManager;
|
2019-08-26 13:24:19 +03:00
|
|
|
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
2019-08-25 12:39:08 +03:00
|
|
|
import pro.gravit.utils.command.CommandHandler;
|
|
|
|
|
2019-10-19 19:46:04 +03:00
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.security.interfaces.ECPrivateKey;
|
|
|
|
import java.security.interfaces.ECPublicKey;
|
|
|
|
|
2019-08-25 12:39:08 +03:00
|
|
|
public class LaunchServerBuilder {
|
|
|
|
private LaunchServerConfig config;
|
|
|
|
private LaunchServerRuntimeConfig runtimeConfig;
|
|
|
|
private CommandHandler commandHandler;
|
|
|
|
private LaunchServer.LaunchServerEnv env;
|
2019-08-26 13:24:19 +03:00
|
|
|
private LaunchServerModulesManager modulesManager;
|
2019-08-25 12:39:08 +03:00
|
|
|
private LaunchServer.LaunchServerDirectories directories = new LaunchServer.LaunchServerDirectories();
|
2019-10-16 12:38:44 +03:00
|
|
|
private ECPublicKey publicKey;
|
|
|
|
private ECPrivateKey privateKey;
|
2019-10-17 16:22:24 +03:00
|
|
|
private CertificateManager certificateManager;
|
2019-08-25 12:39:08 +03:00
|
|
|
private LaunchServer.LaunchServerConfigManager launchServerConfigManager;
|
|
|
|
|
|
|
|
public LaunchServerBuilder setConfig(LaunchServerConfig config) {
|
|
|
|
this.config = config;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LaunchServerBuilder setEnv(LaunchServer.LaunchServerEnv env) {
|
|
|
|
this.env = env;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-08-26 13:24:19 +03:00
|
|
|
public LaunchServerBuilder setModulesManager(LaunchServerModulesManager modulesManager) {
|
2019-08-25 12:39:08 +03:00
|
|
|
this.modulesManager = modulesManager;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LaunchServerBuilder setRuntimeConfig(LaunchServerRuntimeConfig runtimeConfig) {
|
|
|
|
this.runtimeConfig = runtimeConfig;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LaunchServerBuilder setCommandHandler(CommandHandler commandHandler) {
|
|
|
|
this.commandHandler = commandHandler;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LaunchServerBuilder setDirectories(LaunchServer.LaunchServerDirectories directories) {
|
|
|
|
this.directories = directories;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LaunchServerBuilder setDir(Path dir) {
|
|
|
|
this.directories.dir = dir;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-10-16 12:38:44 +03:00
|
|
|
public LaunchServerBuilder setPublicKey(ECPublicKey publicKey) {
|
2019-08-25 12:39:08 +03:00
|
|
|
this.publicKey = publicKey;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-10-16 12:38:44 +03:00
|
|
|
public LaunchServerBuilder setPrivateKey(ECPrivateKey privateKey) {
|
2019-08-25 12:39:08 +03:00
|
|
|
this.privateKey = privateKey;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LaunchServerBuilder setLaunchServerConfigManager(LaunchServer.LaunchServerConfigManager launchServerConfigManager) {
|
|
|
|
this.launchServerConfigManager = launchServerConfigManager;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-10-19 19:46:04 +03:00
|
|
|
public LaunchServer build() throws Exception {
|
2019-08-25 12:39:08 +03:00
|
|
|
//if(updatesDir == null) updatesDir = dir.resolve("updates");
|
|
|
|
//if(profilesDir == null) profilesDir = dir.resolve("profiles");
|
|
|
|
directories.collect();
|
2019-10-19 19:46:04 +03:00
|
|
|
if (launchServerConfigManager == null) {
|
2019-08-25 12:39:08 +03:00
|
|
|
launchServerConfigManager = new LaunchServer.LaunchServerConfigManager() {
|
|
|
|
@Override
|
|
|
|
public LaunchServerConfig readConfig() {
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public LaunchServerRuntimeConfig readRuntimeConfig() {
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeConfig(LaunchServerConfig config) {
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeRuntimeConfig(LaunchServerRuntimeConfig config) {
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2019-10-17 16:22:24 +03:00
|
|
|
return new LaunchServer(directories, env, config, runtimeConfig, launchServerConfigManager, modulesManager, publicKey, privateKey, commandHandler, certificateManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
public LaunchServerBuilder setCertificateManager(CertificateManager certificateManager) {
|
|
|
|
this.certificateManager = certificateManager;
|
|
|
|
return this;
|
2019-08-25 12:39:08 +03:00
|
|
|
}
|
|
|
|
}
|