Fix target world errors not being properly handled, Close #402

This commit is contained in:
William278 committed 2023-05-22 12:26:14 +01:00
1 parent e0961711e7
commit aeff866b48
2 files changed
+11

No files matched your search

@@ -116,7 +116,12 @@ public class Teleport {
plugin.getDatabase().setLastPosition(teleporter, teleporter.getPosition()); plugin.getDatabase().setLastPosition(teleporter, teleporter.getPosition());
} }
try {
teleporter.teleportLocally(localTarget.get().getPosition(), async); teleporter.teleportLocally(localTarget.get().getPosition(), async);
} catch (TeleportationException e) {
e.displayMessage(teleporter, plugin);
return;
}
this.displayTeleportingComplete(teleporter); this.displayTeleportingComplete(teleporter);
}); });
return; return;
@@ -144,7 +149,12 @@ public class Teleport {
final Position target = (Position) this.target; final Position target = (Position) this.target;
if (!plugin.getSettings().doCrossServer() || target.getServer().equals(plugin.getServerName())) { if (!plugin.getSettings().doCrossServer() || target.getServer().equals(plugin.getServerName())) {
try {
teleporter.teleportLocally(target, async); teleporter.teleportLocally(target, async);
} catch (TeleportationException e) {
e.displayMessage(teleporter, plugin);
return;
}
this.displayTeleportingComplete(teleporter); this.displayTeleportingComplete(teleporter);
return; return;
} }
@@ -180,6 +180,7 @@ public abstract class OnlineUser extends User implements Teleportable, CommandUs
* *
* @param location the {@link Location} to teleport the player to * @param location the {@link Location} to teleport the player to
* @param asynchronous if the teleport should be asynchronous * @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; public abstract void teleportLocally(@NotNull Location location, boolean asynchronous) throws TeleportationException;