From d48185a57f4d0df6332e6fb788574b9fcd764930 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 11 Mar 2022 21:49:49 +0100 Subject: [PATCH] Fix teleport depth --- src/de/steamwar/lobby/portal/TeleportPortal.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/lobby/portal/TeleportPortal.java b/src/de/steamwar/lobby/portal/TeleportPortal.java index be926ba..a06bfa1 100644 --- a/src/de/steamwar/lobby/portal/TeleportPortal.java +++ b/src/de/steamwar/lobby/portal/TeleportPortal.java @@ -25,7 +25,6 @@ import de.steamwar.lobby.listener.Portals; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.util.Vector; import java.util.*; import java.util.logging.Level; @@ -61,13 +60,13 @@ public class TeleportPortal implements PortalHandler { public void handle(Player player, Location from, Location to) { Deque stack = Portals.getStack(player); if(!stack.isEmpty() && sources.contains(stack.peek().getHandler())) { - teleport(player, to, stack.pop()); + teleport(player, from, to, stack.pop()); } else { - teleport(player, to, Portal.getPortal(target)); + teleport(player, from, to, Portal.getPortal(target)); } } - private void teleport(Player player, Location to, Portal target) { + private void teleport(Player player, Location from, Location to, Portal target) { if(target == null) { LobbySystem.getPlugin().getLogger().log(Level.WARNING, "Portal with unknown target: " + portal.getId()); player.sendMessage("§cAus unbekannten Gründen führt dieses Portal zurzeit in den Limbus"); @@ -76,8 +75,7 @@ public class TeleportPortal implements PortalHandler { if(ModifyCommand.modifying(player)) player.sendMessage("teleport " + portal.getId() + " -> " + target.getId()); - Vector normalized = portal.normalize(to); - player.teleport(target.denormalize(normalized.setX(1 - normalized.getX())).toLocation(to.getWorld(), (float) (to.getYaw() - Math.toDegrees(target.getYrotation() - portal.getYrotation())), to.getPitch()), PlayerTeleportEvent.TeleportCause.PLUGIN); + player.teleport(target.denormalize(portal.normalize(to).setX(1 - portal.normalize(from).getX())).toLocation(to.getWorld(), (float) (to.getYaw() - Math.toDegrees(target.getYrotation() - portal.getYrotation())), to.getPitch()), PlayerTeleportEvent.TeleportCause.PLUGIN); } @Override