Maven and file access

- Server config file is now accessed through the class loader
- Maven outputs server.jar, moves dependencys to adjacent /libs, and plugins to adjacent /plugins
This commit is contained in:
Jacob Swehla
2017-12-29 10:00:19 -06:00
parent c23ee0dc86
commit 59e3e9430e
8 changed files with 29 additions and 20 deletions

View File

@@ -40,7 +40,7 @@ public class GameServer implements Runnable {
public GameServer() {
this.config = new ServerConfiguration(new File("config.properties"));
this.config = new ServerConfiguration("config.properties");
gameUniverse = new GameUniverse(config);
pluginManager = new PluginManager();

View File

@@ -12,8 +12,7 @@ public class Main {
LogManager.initialize();
ServerConfiguration config = new ServerConfiguration(new File("config.properties"));
ServerConfiguration config = new ServerConfiguration("config.properties");
//Load
GameServer.INSTANCE.getGameUniverse().load(new File("save.json"));

View File

@@ -6,6 +6,7 @@ import net.simon987.server.logging.LogManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
@@ -18,11 +19,11 @@ public class ServerConfiguration {
*/
private Properties properties;
public ServerConfiguration(File file) {
public ServerConfiguration(String file) {
try {
properties = new Properties();
properties.load(new FileInputStream(file));
InputStream is = ServerConfiguration.class.getClassLoader().getResourceAsStream("config.properties");
properties.load(is);
} catch (IOException e) {
LogManager.LOGGER.severe("Problem loading server configuration: " + e.getMessage());