13
0

Fix teleport depth
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2022-03-11 21:49:49 +01:00
Ursprung ecf855a256
Commit d48185a57f

Datei anzeigen

@ -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<Portal> 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