Fixed hard-coded host/port, and bump to version 2.1

This commit is contained in:
Andrew Lalis 2021-06-19 22:34:37 +02:00
parent 95ba8c8746
commit 876bd32bdc
5 changed files with 13 additions and 14 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ace-of-shades</artifactId>
<groupId>nl.andrewlalis</groupId>
<version>2.0</version>
<version>2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,6 @@ package nl.andrewlalis.aos_client;
import nl.andrewlalis.aos_client.view.GameFrame;
import nl.andrewlalis.aos_client.view.GamePanel;
import nl.andrewlalis.aos_core.model.Player;
import nl.andrewlalis.aos_core.model.PlayerControlState;
import nl.andrewlalis.aos_core.model.World;
import nl.andrewlalis.aos_core.net.PlayerControlStateMessage;
@ -151,18 +150,18 @@ public class Client {
public static void main(String[] args) {
// String hostAndPort = JOptionPane.showInputDialog("Enter server host and port (host:port):");
// if (hostAndPort == null) throw new IllegalArgumentException("A host and port is required.");
// String[] parts = hostAndPort.split(":");
// if (parts.length != 2) throw new IllegalArgumentException("Invalid host:port.");
// String host = parts[0].trim();
// int port = Integer.parseInt(parts[1]);
// String username = JOptionPane.showInputDialog("Enter a username:");
// if (username == null || username.isBlank()) throw new IllegalArgumentException("Username is required.");
String hostAndPort = JOptionPane.showInputDialog("Enter server host and port (host:port):");
if (hostAndPort == null) throw new IllegalArgumentException("A host and port is required.");
String[] parts = hostAndPort.split(":");
if (parts.length != 2) throw new IllegalArgumentException("Invalid host:port.");
String host = parts[0].trim();
int port = Integer.parseInt(parts[1]);
String username = JOptionPane.showInputDialog("Enter a username:");
if (username == null || username.isBlank()) throw new IllegalArgumentException("Username is required.");
Client client = new Client();
try {
client.connect("localhost", 8035, "andrew");
client.connect(host, port, username);
} catch (IOException | ClassNotFoundException e) {
client.shutdown();
e.printStackTrace();

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ace-of-shades</artifactId>
<groupId>nl.andrewlalis</groupId>
<version>2.0</version>
<version>2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -7,7 +7,7 @@
<groupId>nl.andrewlalis</groupId>
<artifactId>ace-of-shades</artifactId>
<packaging>pom</packaging>
<version>2.0</version>
<version>2.1</version>
<modules>
<module>server</module>
<module>client</module>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ace-of-shades</artifactId>
<groupId>nl.andrewlalis</groupId>
<version>2.0</version>
<version>2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>