Add configuration stuff (this is not done yet)

This commit is contained in:
Andrew Steinborn
2018-07-27 13:32:15 -04:00
parent 66dcb13b5a
commit f34e9b19c9
14 changed files with 407 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ package com.velocitypowered.proxy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.velocitypowered.network.ConnectionManager;
import com.velocitypowered.proxy.config.VelocityConfiguration;
import com.velocitypowered.proxy.connection.http.NettyHttpClient;
import com.velocitypowered.proxy.util.EncryptionUtils;
import io.netty.bootstrap.Bootstrap;
@@ -11,7 +12,9 @@ import net.kyori.text.serializer.GsonComponentSerializer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.file.Paths;
import java.security.KeyPair;
public class VelocityServer {
@@ -22,6 +25,7 @@ public class VelocityServer {
.create();
private final ConnectionManager cm = new ConnectionManager();
private VelocityConfiguration configuration;
private NettyHttpClient httpClient;
private KeyPair serverKeyPair;
@@ -36,9 +40,23 @@ public class VelocityServer {
return serverKeyPair;
}
public VelocityConfiguration getConfiguration() {
return configuration;
}
public void start() {
// Create a key pair
logger.info("Booting up Velocity...");
try {
configuration = VelocityConfiguration.read(Paths.get("velocity.toml"));
if (!configuration.validate()) {
logger.error("Your configuration is invalid. Velocity will refuse to start up until the errors are resolved.");
System.exit(1);
}
} catch (IOException e) {
logger.error("Unable to load your velocity.toml. The server will shut down.", e);
System.exit(1);
}
serverKeyPair = EncryptionUtils.createRsaKeyPair(1024);
httpClient = new NettyHttpClient(this);