Fixed to make extra logic completely optional.
This commit is contained in:
parent
c10dd7cd02
commit
c4a4479602
|
@ -86,15 +86,18 @@ public class Server implements Runnable {
|
||||||
running = true;
|
running = true;
|
||||||
new Thread(new UdpReceiver(datagramSocket, this::handleUdpMessage)).start();
|
new Thread(new UdpReceiver(datagramSocket, this::handleUdpMessage)).start();
|
||||||
new Thread(worldUpdater).start();
|
new Thread(worldUpdater).start();
|
||||||
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
ScheduledExecutorService executorService = null;
|
||||||
|
if (config.registries != null && config.registries.length > 0) {
|
||||||
|
executorService = Executors.newSingleThreadScheduledExecutor();
|
||||||
var registryUpdater = new RegistryUpdater(this);
|
var registryUpdater = new RegistryUpdater(this);
|
||||||
executorService.scheduleAtFixedRate(registryUpdater::sendUpdates, 0, 30, TimeUnit.SECONDS);
|
executorService.scheduleAtFixedRate(registryUpdater::sendUpdates, 0, 30, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
System.out.printf("Started AoS2 Server on TCP/UDP port %d; now accepting connections.%n", serverSocket.getLocalPort());
|
System.out.printf("Started AoS2 Server on TCP/UDP port %d; now accepting connections.%n", serverSocket.getLocalPort());
|
||||||
while (running) {
|
while (running) {
|
||||||
acceptClientConnection();
|
acceptClientConnection();
|
||||||
}
|
}
|
||||||
System.out.println("Shutting down the server.");
|
System.out.println("Shutting down the server.");
|
||||||
executorService.shutdown();
|
if (executorService != null) executorService.shutdown();
|
||||||
playerManager.deregisterAll();
|
playerManager.deregisterAll();
|
||||||
worldUpdater.shutdown();
|
worldUpdater.shutdown();
|
||||||
datagramSocket.close(); // Shuts down the UdpReceiver.
|
datagramSocket.close(); // Shuts down the UdpReceiver.
|
||||||
|
|
Loading…
Reference in New Issue