unified udp and tcp ports into one

This commit is contained in:
2026-04-05 19:39:29 -03:00
parent 1bc0ae71bf
commit 4bbc65c528
7 changed files with 11 additions and 20 deletions

View File

@@ -1,4 +1,3 @@
{
"tcpPort": 9090,
"udpPort": 9091
"port": 9090
}

View File

@@ -18,8 +18,7 @@ public class GameServer {
private final Server server;
private final Map<Integer, NetworkPackets.PlayerState> players = new ConcurrentHashMap<>();
private int udpPort = Network.DEFAULT_UDP_PORT;
private int tcpPort = Network.DEFAULT_TCP_PORT;
private int port = Network.DEFAULT_PORT;
public GameServer() {
server = new Server();
@@ -62,8 +61,7 @@ public class GameServer {
ServerConfig config = null;
try {
config = new Gson().fromJson(new FileReader("server-config.json"), ServerConfig.class);
this.udpPort = config.udpPort;
this.tcpPort = config.tcpPort;
this.port = config.port;
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
@@ -112,7 +110,7 @@ public class GameServer {
public void start() throws IOException {
server.start();
server.bind(this.tcpPort, this.udpPort);
server.bind(this.port, this.port);
System.out.println("Servidor iniciado.");
}

View File

@@ -1,6 +1,5 @@
package io.github.eldek0.config;
public class ServerConfig {
public int tcpPort;
public int udpPort;
public int port;
}