automatically join lobby when selfhosting

This commit is contained in:
Johannes Schmelz 2024-11-24 21:36:03 +01:00
parent 6b78733a5d
commit dcf10e0819
2 changed files with 11 additions and 6 deletions

View File

@ -39,10 +39,9 @@ public class CreateGameMenu extends SimpleDialog {
private final NetworkSupport network;
private final TextField host = new TextField(LOCALHOST);
private final TextField port = new TextField(DEFAULT_PORT);
// private final Button serverButton = new Button(lookup("client.server-star"));
private final Button serverButton = new Button(lookup("client.server-start"));
private final Button cancelButton = addChild(new Button("Abbrechen"));
private final Button joinButton = addChild(new Button("Beitreten"));
private final Button serverButton = new Button("Selber hosten");
private final Button cancelButton = new Button("Abbrechen");
private final Button joinButton = new Button("Beitreten");
private String hostname;
private int portNumber;
private Future<Object> connectionFuture;
@ -175,7 +174,6 @@ public class CreateGameMenu extends SimpleDialog {
Thread serverThread = new Thread(() -> {
try {
MonopolyServer.main(null);
connect();
} catch (Exception e) {
serverButton.setEnabled(true);
LOGGER.log(Level.ERROR, "Server could not be started", e);
@ -183,5 +181,12 @@ public class CreateGameMenu extends SimpleDialog {
}
});
serverThread.start();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
connect();
}
}

View File

@ -28,7 +28,7 @@ public class MonopolyConfig extends Config {
* The default port number for the Monopoly server.
*/
@Property("port")
private int port = 4321;
private int port = 42069;
/**
* The width of the game map in terms of grid units.