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
+13 -2

No files matched your search

@@ -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;
}
@@ -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;