diff --git a/client/pom.xml b/client/pom.xml
index 906d536..a60db88 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -5,7 +5,7 @@
ace-of-shades
nl.andrewlalis
- 5.0
+ 0.5.0
4.0.0
diff --git a/client/src/main/java/nl/andrewlalis/aos_client/launcher/servers/PublicServerInfo.java b/client/src/main/java/nl/andrewlalis/aos_client/launcher/servers/PublicServerInfo.java
index 6d3f05e..e72d320 100644
--- a/client/src/main/java/nl/andrewlalis/aos_client/launcher/servers/PublicServerInfo.java
+++ b/client/src/main/java/nl/andrewlalis/aos_client/launcher/servers/PublicServerInfo.java
@@ -6,6 +6,7 @@ import java.awt.*;
public record PublicServerInfo(
String name,
String address,
+ String version,
String description,
String location,
Image icon,
@@ -14,35 +15,53 @@ public record PublicServerInfo(
) {
public static ListCellRenderer cellRenderer() {
return (list, value, index, isSelected, cellHasFocus) -> {
- JPanel panel = new JPanel(new BorderLayout());
- panel.setBorder(BorderFactory.createTitledBorder(value.name()));
+ JPanel panel = new JPanel(new GridBagLayout());
+ var c = new GridBagConstraints();
- panel.add(new JLabel("Address: " + value.address()), BorderLayout.NORTH);
-
- JPanel content = new JPanel();
+ c.anchor = GridBagConstraints.CENTER;
+ c.insets = new Insets(1, 1, 1, 1);
+ c.gridx = 0;
+ c.gridy = 0;
+ c.gridheight = 4;
+ c.weightx = 0.25;
+ c.fill = GridBagConstraints.BOTH;
if (value.icon() != null) {
JLabel iconLabel = new JLabel(new ImageIcon(value.icon()));
- content.add(iconLabel);
+ panel.add(iconLabel, c);
}
+ c.anchor = GridBagConstraints.LINE_START;
+ c.gridx = 1;
+ c.gridy = 0;
+ c.gridheight = 1;
+ c.weightx = 0.75;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ var nameLabel = new JLabel(value.name() + " [" + value.version() + "]");
+ nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD));
+ panel.add(nameLabel, c);
+ c.gridy++;
+ var addressLabel = new JLabel(value.address());
+ addressLabel.setFont(new Font("monospaced", Font.PLAIN, 12));
+ panel.add(addressLabel, c);
+ c.gridy++;
JTextArea descriptionArea = new JTextArea(value.description());
descriptionArea.setEditable(false);
descriptionArea.setWrapStyleWord(true);
descriptionArea.setLineWrap(true);
- content.add(descriptionArea);
- panel.add(content, BorderLayout.CENTER);
-
- JPanel bottomPanel = new JPanel();
- bottomPanel.add(new JLabel(String.format("Current players: %d / %d", value.currentPlayers(), value.maxPlayers())));
-
- panel.add(bottomPanel, BorderLayout.SOUTH);
+ panel.add(descriptionArea, c);
+ c.gridy++;
+ panel.add(new JLabel(String.format("%d / %d Players", value.currentPlayers(), value.maxPlayers())), c);
if (isSelected) {
panel.setBackground(list.getSelectionBackground());
panel.setForeground(list.getSelectionForeground());
+ descriptionArea.setForeground(list.getSelectionForeground());
+ descriptionArea.setBackground(list.getSelectionBackground());
} else {
panel.setBackground(list.getBackground());
panel.setForeground(list.getForeground());
+ descriptionArea.setForeground(list.getForeground());
+ descriptionArea.setBackground(list.getBackground());
}
return panel;
diff --git a/client/src/main/java/nl/andrewlalis/aos_client/launcher/servers/PublicServerListModel.java b/client/src/main/java/nl/andrewlalis/aos_client/launcher/servers/PublicServerListModel.java
index 6e2b26a..6d24c89 100644
--- a/client/src/main/java/nl/andrewlalis/aos_client/launcher/servers/PublicServerListModel.java
+++ b/client/src/main/java/nl/andrewlalis/aos_client/launcher/servers/PublicServerListModel.java
@@ -149,6 +149,7 @@ public class PublicServerListModel extends AbstractListModel {
PublicServerInfo info = new PublicServerInfo(
node.get("name").asText(),
node.get("address").asText(),
+ node.get("version").asText(),
node.get("description").asText(),
node.get("location").asText(),
icon,
diff --git a/core/pom.xml b/core/pom.xml
index 9153652..ea6f593 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -5,7 +5,7 @@
ace-of-shades
nl.andrewlalis
- 5.0
+ 0.5.0
4.0.0
diff --git a/pom.xml b/pom.xml
index 6218cc7..b3bf81b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
nl.andrewlalis
ace-of-shades
pom
- 5.0
+ 0.5.0
server
client
diff --git a/server-registry/pom.xml b/server-registry/pom.xml
index 96f59bb..83aa913 100644
--- a/server-registry/pom.xml
+++ b/server-registry/pom.xml
@@ -5,7 +5,7 @@
ace-of-shades
nl.andrewlalis
- 5.0
+ 0.5.0
4.0.0
diff --git a/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ResponseStatusException.java b/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ResponseStatusException.java
new file mode 100644
index 0000000..d578a9e
--- /dev/null
+++ b/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ResponseStatusException.java
@@ -0,0 +1,21 @@
+package nl.andrewlalis.aos_server_registry.servlet;
+
+public class ResponseStatusException extends Exception {
+ private final int statusCode;
+ private final String message;
+
+ public ResponseStatusException(int statusCode, String message) {
+ super(message);
+ this.statusCode = statusCode;
+ this.message = message;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ServerInfoServlet.java b/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ServerInfoServlet.java
index 06e86f2..fe0cc93 100644
--- a/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ServerInfoServlet.java
+++ b/server-registry/src/main/java/nl/andrewlalis/aos_server_registry/servlet/ServerInfoServlet.java
@@ -40,7 +40,7 @@ public class ServerInfoServlet extends HttpServlet {
));
String orderDir = Requests.getStringParam(req, "dir", "ASC", s -> s.equalsIgnoreCase("ASC") || s.equalsIgnoreCase("DESC"));
try {
- var results = this.getData(size, page, searchQuery, order, orderDir);
+ var results = this.getData(size, page, searchQuery, null, order, orderDir);
Responses.ok(resp, new Page<>(results, page, size, order, orderDir));
} catch (SQLException t) {
t.printStackTrace();
@@ -54,6 +54,8 @@ public class ServerInfoServlet extends HttpServlet {
try {
this.saveNewServer(info);
Responses.ok(resp, Map.of("message", "Server icon saved."));
+ } catch (ResponseStatusException e) {
+ Responses.json(resp, e.getStatusCode(), Map.of("message", e.getMessage()));
} catch (SQLException e) {
e.printStackTrace();
Responses.internalServerError(resp, "Database error.");
@@ -66,11 +68,11 @@ public class ServerInfoServlet extends HttpServlet {
this.updateServerStatus(status, resp);
}
- private List getData(int size, int page, String searchQuery, String order, String orderDir) throws SQLException, IOException {
+ private List getData(int size, int page, String searchQuery, String versionQuery, String order, String orderDir) throws SQLException, IOException {
final List results = new ArrayList<>(20);
var con = DataManager.getInstance().getConnection();
String selectQuery = """
- SELECT name, address, updated_at, description, location, icon, max_players, current_players
+ SELECT name, address, version, updated_at, description, location, icon, max_players, current_players
FROM servers
//CONDITIONS
ORDER BY name
@@ -78,20 +80,30 @@ public class ServerInfoServlet extends HttpServlet {
OFFSET ?
""";
selectQuery = selectQuery.replace("ORDER BY name", "ORDER BY " + order + " " + orderDir);
+ List conditions = new ArrayList<>();
+ List