From 697dd58b46bb1087997645c964561d71b8a9a499 Mon Sep 17 00:00:00 2001 From: GoXLR <107289968+GoXLR@users.noreply.github.com> Date: Wed, 19 Oct 2022 09:31:07 +0200 Subject: [PATCH] Fix --- .../route/serverGroups/POSTServerGroups.java | 2 +- .../route/servers/POSTServersHeartbeat.java | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/frozenorb/apiv3/web/route/serverGroups/POSTServerGroups.java b/src/main/java/net/frozenorb/apiv3/web/route/serverGroups/POSTServerGroups.java index 94c6522..d653b39 100644 --- a/src/main/java/net/frozenorb/apiv3/web/route/serverGroups/POSTServerGroups.java +++ b/src/main/java/net/frozenorb/apiv3/web/route/serverGroups/POSTServerGroups.java @@ -25,7 +25,7 @@ public final class POSTServerGroups implements Handler { String image = requestBody.getString("image"); ServerGroup serverGroup = new ServerGroup(id, image); - SyncUtils.runBlocking(v -> serverGroup.insert(v)); + SyncUtils.runBlocking(serverGroup::insert); if (requestBody.containsKey("addedBy")) { AuditLog.log(UuidUtils.parseUuid(requestBody.getString("addedBy")), requestBody.getString("addedByIp"), ctx, AuditLogActionType.SERVER_GROUP_CREATE, ImmutableMap.of("serverGroupId", id), (ignored, error) -> { diff --git a/src/main/java/net/frozenorb/apiv3/web/route/servers/POSTServersHeartbeat.java b/src/main/java/net/frozenorb/apiv3/web/route/servers/POSTServersHeartbeat.java index da01e65..5436fcb 100644 --- a/src/main/java/net/frozenorb/apiv3/web/route/servers/POSTServersHeartbeat.java +++ b/src/main/java/net/frozenorb/apiv3/web/route/servers/POSTServersHeartbeat.java @@ -75,14 +75,16 @@ public final class POSTServersHeartbeat implements Handler { private Future createInfoResponse(Server server, double tps, Map playerNames) { Future callback = Future.future(); - server.receivedHeartbeat(tps, playerNames.keySet()); - server.save((ignored, error) -> { - if (error != null) { - callback.fail(error); - } else { - callback.complete(); - } - }); + if (server != null && playerNames != null) { + server.receivedHeartbeat(tps, playerNames.keySet()); + server.save((ignored, error) -> { + if (error != null) { + callback.fail(error); + } else { + callback.complete(); + } + }); + } return callback; }