unified udp and tcp ports into one
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"tcpPort": 9090,
|
||||
"udpPort": 9091
|
||||
"port": 9090
|
||||
}
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.github.eldek0.config;
|
||||
|
||||
public class ServerConfig {
|
||||
public int tcpPort;
|
||||
public int udpPort;
|
||||
public int port;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user