diff --git a/common/src/main/java/net/william278/huskhomes/messenger/Message.java b/common/src/main/java/net/william278/huskhomes/messenger/Message.java index 1bf9e035..3346af37 100644 --- a/common/src/main/java/net/william278/huskhomes/messenger/Message.java +++ b/common/src/main/java/net/william278/huskhomes/messenger/Message.java @@ -24,7 +24,7 @@ public class Message { public MessageType type; /** - * The kind of message this is - {@link RelayType#MESSAGE} or a {@link RelayType#REPLY} to a message. + * Represents the context under which this message is being relayed; an outbound {@link RelayType#MESSAGE} or a {@link RelayType#REPLY} to one. */ @SerializedName("relay_type") @NotNull @@ -91,7 +91,13 @@ public class Message { * Identifies the source of the message being relayed - a {@link RelayType#MESSAGE} or a {@link RelayType#REPLY} to a message. */ public enum RelayType { + /** + * An outbound message to/from a server + */ MESSAGE, + /** + * A reply to an outbound message + */ REPLY } diff --git a/common/src/main/java/net/william278/huskhomes/teleport/TeleportBuilder.java b/common/src/main/java/net/william278/huskhomes/teleport/TeleportBuilder.java index c53512cf..49e9ab6f 100644 --- a/common/src/main/java/net/william278/huskhomes/teleport/TeleportBuilder.java +++ b/common/src/main/java/net/william278/huskhomes/teleport/TeleportBuilder.java @@ -226,12 +226,12 @@ public class TeleportBuilder { return Optional.empty(); } return plugin.getNetworkMessenger() - .sendMessage(executor, new Message(Message.MessageType.POSITION_REQUEST, executor.username, - playerName, MessagePayload.empty(), Message.RelayType.MESSAGE, - plugin.getSettings().clusterId)) + .sendMessage(executor, new Message(Message.MessageType.POSITION_REQUEST, + executor.username, playerName, MessagePayload.empty(), + Message.RelayType.MESSAGE, plugin.getSettings().clusterId)) .orTimeout(3, TimeUnit.SECONDS) .exceptionally(throwable -> null) - .thenApply(reply -> Optional.ofNullable(reply.payload.position)).join(); + .thenApply(reply -> Optional.ofNullable(reply == null ? null : reply.payload.position)).join(); }); } return CompletableFuture.supplyAsync(Optional::empty);