From 20bce266b1e17b0f84d2c202db1e8c36bf3892f9 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Sat, 5 Jun 2021 23:12:06 +0200 Subject: [PATCH] feat: made config files globally avaliable via Server --- .../teamname/marvelous/server/Server.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/Server.java b/Server/src/main/java/uulm/teamname/marvelous/server/Server.java index fa87176..d68a0c2 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/Server.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/Server.java @@ -15,10 +15,6 @@ import uulm.teamname.marvelous.server.netconnector.MarvelousServer; import java.io.*; import java.net.InetSocketAddress; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.HashMap; import java.util.Map; @@ -31,6 +27,10 @@ import java.util.Map; */ public class Server { + private static PartyConfig partyConfig; + private static ScenarioConfig scenarioConfig; + private static CharacterConfig characterConfig; + public static void main(String[] args) { ServerArgs serverArgs = new ServerArgs(); @@ -66,13 +66,15 @@ public class Server { System.exit(0); } + Logger.info("populating static Server variables with config objects"); + Server.scenarioConfig = scenarioConfig; + Server.characterConfig = characterConfig; + Server.partyConfig = partyConfig; + InetSocketAddress address = new InetSocketAddress(serverArgs.getPort()); Logger.trace("Inet address {} created", address); - var json = new JSON(characterConfig); - Logger.trace("New JSON instance created with characterConfig"); - - MarvelousServer netConnector = new MarvelousServer(address, json); + MarvelousServer netConnector = new MarvelousServer(address); System.out.println("Starting server"); netConnector.start(); System.out.println("Server started"); @@ -206,4 +208,19 @@ public class Server { return config.get(); } + + /** Returns the party configuration the server was initialized with */ + public static PartyConfig getPartyConfig() { + return partyConfig; + } + + /** Returns the scenario configuration the server was initialized with */ + public static ScenarioConfig getScenarioConfig() { + return scenarioConfig; + } + + /** Returns the character configuration the server was initialized with */ + public static CharacterConfig getCharacterConfig() { + return characterConfig; + } }