diff --git a/common/src/main/java/net/william278/huskhomes/request/RequestManager.java b/common/src/main/java/net/william278/huskhomes/request/RequestManager.java index 2c14facc..fa15c4df 100644 --- a/common/src/main/java/net/william278/huskhomes/request/RequestManager.java +++ b/common/src/main/java/net/william278/huskhomes/request/RequestManager.java @@ -109,16 +109,16 @@ public class RequestManager { MessagePayload.withTeleportRequest(request), Message.RelayType.MESSAGE, plugin.getSettings().clusterId)) - .thenApply(message -> { - if (message.payload.teleportRequest == null) { + .orTimeout(3, TimeUnit.SECONDS) + .exceptionally(throwable -> null) + .thenApply(reply -> { + if (reply == null || reply.payload.teleportRequest == null) { return false; } // If the message was ignored by the recipient, return false - return message.payload.teleportRequest.status == TeleportRequest.RequestStatus.PENDING; - }) - .orTimeout(3, TimeUnit.SECONDS) - .exceptionally(throwable -> false).join(); + return reply.payload.teleportRequest.status == TeleportRequest.RequestStatus.PENDING; + }).join(); }); } return CompletableFuture.supplyAsync(() -> false); diff --git a/common/src/main/java/net/william278/huskhomes/teleport/TeleportManager.java b/common/src/main/java/net/william278/huskhomes/teleport/TeleportManager.java index ffb2d5c7..e2e6b739 100644 --- a/common/src/main/java/net/william278/huskhomes/teleport/TeleportManager.java +++ b/common/src/main/java/net/william278/huskhomes/teleport/TeleportManager.java @@ -165,8 +165,10 @@ public class TeleportManager { MessagePayload.withPosition(position), Message.RelayType.MESSAGE, plugin.getSettings().clusterId)) + .orTimeout(3, TimeUnit.SECONDS) + .exceptionally(throwable -> null) .thenApply(result -> { - if (result.payload.teleportResult == null) { + if (result == null || result.payload.teleportResult == null) { return Optional.empty(); } return Optional.of(result.payload.teleportResult);