From e7c9b72c39c5e957afde86e3cc236d19eaf699ec Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 1 Jan 2021 00:18:59 +0100 Subject: [PATCH] Fix Border --- src/de/steamwar/lobby/listener/PlayerMoveListener.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/de/steamwar/lobby/listener/PlayerMoveListener.java b/src/de/steamwar/lobby/listener/PlayerMoveListener.java index ebe2e92..6780405 100644 --- a/src/de/steamwar/lobby/listener/PlayerMoveListener.java +++ b/src/de/steamwar/lobby/listener/PlayerMoveListener.java @@ -20,6 +20,7 @@ package de.steamwar.lobby.listener; import de.steamwar.lobby.utils.Config; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -28,12 +29,17 @@ import org.bukkit.util.Vector; public class PlayerMoveListener implements Listener { + private static final Location spawnLocation = new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch); + private static final Vector borderMinVector = new Vector(Config.BorderMinX, Config.BorderMinY, Config.BorderMinZ); private static final Vector borderMaxVector = new Vector(Config.BorderMaxX, Config.BorderMaxY, Config.BorderMaxZ); @EventHandler public void handleWorldBorder(PlayerMoveEvent event) { Location to = event.getTo(); + if (to.getY() < 0) { + event.getPlayer().teleport(spawnLocation); + } if (!to.toVector().isInAABB(borderMinVector, borderMaxVector)) { event.getPlayer().teleport(event.getFrom()); }