From b0a289e35f19dd93f51a5f9254b314b7871164d4 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Wed, 30 Jun 2021 12:12:14 +0200 Subject: [PATCH] Added some debug statements and registry settings to server. --- .../servlet/ServerInfoServlet.java | 3 ++ .../aos_server/settings/RegistrySettings.java | 34 +++++++++++++++++++ .../aos_server/settings/ServerSettings.java | 2 ++ .../src/main/resources/default_settings.yaml | 10 ++++++ 4 files changed, 49 insertions(+) create mode 100644 server/src/main/java/nl/andrewlalis/aos_server/settings/RegistrySettings.java diff --git a/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ServerInfoServlet.java b/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ServerInfoServlet.java index a4bd6a2..92caba3 100644 --- a/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ServerInfoServlet.java +++ b/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ServerInfoServlet.java @@ -127,6 +127,7 @@ public class ServerInfoServlet extends HttpServlet { int rowCount = createStmt.executeUpdate(); createStmt.close(); if (rowCount != 1) throw new SQLException("Could not insert new server."); + System.out.println("Registered new server " + info.name() + " @ " + info.address()); } else { PreparedStatement updateStmt = con.prepareStatement(""" UPDATE servers SET description = ?, location = ?, max_players = ?, current_players = ? @@ -141,6 +142,7 @@ public class ServerInfoServlet extends HttpServlet { int rowCount = updateStmt.executeUpdate(); updateStmt.close(); if (rowCount != 1) throw new SQLException("Could not update server."); + System.out.println("Updated server information for " + info.name() + " @ " + info.address()); } } @@ -156,5 +158,6 @@ public class ServerInfoServlet extends HttpServlet { int rowCount = stmt.executeUpdate(); stmt.close(); if (rowCount != 1) throw new SQLException("Could not update server status."); + System.out.println("Updated server status for " + status.name() + " @ " + status.address()); } } diff --git a/server/src/main/java/nl/andrewlalis/aos_server/settings/RegistrySettings.java b/server/src/main/java/nl/andrewlalis/aos_server/settings/RegistrySettings.java new file mode 100644 index 0000000..2a39965 --- /dev/null +++ b/server/src/main/java/nl/andrewlalis/aos_server/settings/RegistrySettings.java @@ -0,0 +1,34 @@ +package nl.andrewlalis.aos_server.settings; + +public class RegistrySettings { + private boolean discoverable; + private String registryUri; + private String name; + private String address; + private String description; + private String location; + + public boolean isDiscoverable() { + return discoverable; + } + + public String getRegistryUri() { + return registryUri; + } + + public String getName() { + return name; + } + + public String getAddress() { + return address; + } + + public String getDescription() { + return description; + } + + public String getLocation() { + return location; + } +} diff --git a/server/src/main/java/nl/andrewlalis/aos_server/settings/ServerSettings.java b/server/src/main/java/nl/andrewlalis/aos_server/settings/ServerSettings.java index 7aae1d6..9de8795 100644 --- a/server/src/main/java/nl/andrewlalis/aos_server/settings/ServerSettings.java +++ b/server/src/main/java/nl/andrewlalis/aos_server/settings/ServerSettings.java @@ -6,6 +6,8 @@ public class ServerSettings { private int port; private int maxPlayers; private float ticksPerSecond; + + private RegistrySettings registrySettings; private PlayerSettings playerSettings; private TeamSettings teamSettings; private List gunSettings; diff --git a/server/src/main/resources/default_settings.yaml b/server/src/main/resources/default_settings.yaml index 6fdb8ec..173c7e1 100644 --- a/server/src/main/resources/default_settings.yaml +++ b/server/src/main/resources/default_settings.yaml @@ -2,6 +2,16 @@ port: 8035 max-players: 32 ticks-per-second: 120 +# Information for the public server registry. +registry-data: + discoverable: true + registry-uri: "http://localhost:8567" + name: "Testing Server" + address: "localhost:8035" + description: "A simple testing server for development." + location: "Earth" + + # Settings that control player behavior. player-settings: speed: 10