diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index 4bf3b87..927c67b 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -55,7 +55,7 @@ public class LobbySystem extends JavaPlugin { new ParticleListener(); new InventoryInteraction(); new WorldInteraction(); - new WorldBorder(); + new AlphaWall(l -> l.getZ() > 1250, AlphaWall.REFLECT_Z); } diff --git a/src/de/steamwar/lobby/listener/WorldBorder.java b/src/de/steamwar/lobby/listener/AlphaWall.java similarity index 50% rename from src/de/steamwar/lobby/listener/WorldBorder.java rename to src/de/steamwar/lobby/listener/AlphaWall.java index bb9f534..502488b 100644 --- a/src/de/steamwar/lobby/listener/WorldBorder.java +++ b/src/de/steamwar/lobby/listener/AlphaWall.java @@ -19,50 +19,36 @@ package de.steamwar.lobby.listener; -import org.bukkit.Bukkit; +import de.steamwar.lobby.command.ModifyCommand; import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerTeleportEvent; -public class WorldBorder extends BasicListener { +import java.util.function.Function; - final BorderData data = new BorderData(); +public class AlphaWall extends BasicListener { + + public static float REFLECT_X = 360f; + public static float REFLECT_Z = 180f; + + private final Function allowed; + private final float reflect; + + public AlphaWall(Function allowed, float reflect) { + this.allowed = allowed; + this.reflect = reflect; + } @EventHandler public void onMove(PlayerMoveEvent event) { Player player = event.getPlayer(); + if(ModifyCommand.modifying(player) || allowed.apply(event.getTo())) + return; - if(!data.locationIsInRegion(event.getTo())) { - //player.teleport(event.getFrom()); - } - } - - public static final class BorderData { - - final World world = Bukkit.getWorlds().get(0); - - final Location loc1 = new Location(world,1337,0,1803); - final Location loc2 = new Location(world,2610,0,1800); - - private double maxX; - private double maxZ; - - private double minX; - private double minZ; - - public BorderData() { - maxX = Math.max(loc1.getX(), loc2.getX()); - maxZ = Math.max(loc1.getZ(), loc2.getZ()); - - minX = Math.min(loc1.getX(), loc2.getX()); - minZ = Math.min(loc1.getZ(), loc2.getZ()); - } - - public boolean locationIsInRegion(Location loc) { - return loc.getX() > minX && loc.getX() < maxX - && loc.getZ() > minZ && loc.getZ() < maxZ; - } + Location to = event.getFrom().clone(); + to.setYaw(reflect - to.getYaw()); + player.teleport(to, PlayerTeleportEvent.TeleportCause.PLUGIN); } } diff --git a/src/de/steamwar/lobby/portal/FightserverPortal.java b/src/de/steamwar/lobby/portal/FightserverPortal.java index e8f87f7..d5b0579 100644 --- a/src/de/steamwar/lobby/portal/FightserverPortal.java +++ b/src/de/steamwar/lobby/portal/FightserverPortal.java @@ -76,7 +76,13 @@ public class FightserverPortal implements PortalHandler, Comparable