From aeff866b48d5f935b460ad2dfbe993d673682669 Mon Sep 17 00:00:00 2001 From: William278 Date: Mon, 22 May 2023 12:26:14 +0100 Subject: [PATCH] Fix target world errors not being properly handled, Close #402 --- .../william278/huskhomes/teleport/Teleport.java | 14 ++++++++++++-- .../net/william278/huskhomes/user/OnlineUser.java | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/net/william278/huskhomes/teleport/Teleport.java b/common/src/main/java/net/william278/huskhomes/teleport/Teleport.java index b94cdb7e..73062588 100644 --- a/common/src/main/java/net/william278/huskhomes/teleport/Teleport.java +++ b/common/src/main/java/net/william278/huskhomes/teleport/Teleport.java @@ -116,7 +116,12 @@ public class Teleport { plugin.getDatabase().setLastPosition(teleporter, teleporter.getPosition()); } - teleporter.teleportLocally(localTarget.get().getPosition(), async); + try { + teleporter.teleportLocally(localTarget.get().getPosition(), async); + } catch (TeleportationException e) { + e.displayMessage(teleporter, plugin); + return; + } this.displayTeleportingComplete(teleporter); }); return; @@ -144,7 +149,12 @@ public class Teleport { final Position target = (Position) this.target; if (!plugin.getSettings().doCrossServer() || target.getServer().equals(plugin.getServerName())) { - teleporter.teleportLocally(target, async); + try { + teleporter.teleportLocally(target, async); + } catch (TeleportationException e) { + e.displayMessage(teleporter, plugin); + return; + } this.displayTeleportingComplete(teleporter); return; } diff --git a/common/src/main/java/net/william278/huskhomes/user/OnlineUser.java b/common/src/main/java/net/william278/huskhomes/user/OnlineUser.java index a60dd4b2..65112123 100644 --- a/common/src/main/java/net/william278/huskhomes/user/OnlineUser.java +++ b/common/src/main/java/net/william278/huskhomes/user/OnlineUser.java @@ -180,6 +180,7 @@ public abstract class OnlineUser extends User implements Teleportable, CommandUs * * @param location the {@link Location} to teleport the player to * @param asynchronous if the teleport should be asynchronous + * @throws TeleportationException if the teleport fails */ public abstract void teleportLocally(@NotNull Location location, boolean asynchronous) throws TeleportationException;