Add additional teleport execution handling

This commit is contained in:
William committed 2023-03-24 01:20:33 +00:00
1 parent 9c6ed329d5
commit 88f34ac133
8 files changed
+87 -40

No files matched your search

@@ -4,6 +4,7 @@ import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.Home;
import net.william278.huskhomes.position.Warp;
import net.william278.huskhomes.teleport.Teleport;
import net.william278.huskhomes.teleport.TeleportationException;
import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
@@ -35,11 +36,17 @@ public abstract class Broker {
}
switch (message.getType()) {
case TELEPORT_TO_POSITION -> message.getPayload()
.getPosition().ifPresent(position -> Teleport.builder(plugin)
.teleporter(receiver)
.target(position)
.toTeleport()
.execute());
.getPosition().ifPresent(position -> {
try {
Teleport.builder(plugin)
.teleporter(receiver)
.target(position)
.toTeleport()
.execute();
} catch (TeleportationException e) {
e.displayMessage(plugin.getConsole(), plugin, new String[]{});
}
});
case TELEPORT_TO_NETWORKED_POSITION -> Message.builder()
.type(Message.Type.TELEPORT_TO_POSITION)
.target(message.getSender())