From dcf10e08198e81ab43521a9634f17acec9ca82bb Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sun, 24 Nov 2024 21:36:03 +0100 Subject: [PATCH] automatically join lobby when selfhosting --- .../pp/monopoly/client/gui/CreateGameMenu.java | 15 ++++++++++----- .../src/main/java/pp/monopoly/MonopolyConfig.java | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java index 9cebf72..88d5c3a 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java @@ -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 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(); } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/MonopolyConfig.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/MonopolyConfig.java index 2fe9495..cbef5e0 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/MonopolyConfig.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/MonopolyConfig.java @@ -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.