From 89345a0e8d08d41179320a5aa9b554d52c864b63 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 17 Aug 2023 21:27:47 +0200 Subject: [PATCH] Add Configs and add move outside --- src/world.yml => configs/acacia.yml | 0 configs/sears.yml | 34 +++++++++++++++++++ .../towerrun/listener/GlobalListener.java | 13 +++++++ 3 files changed, 47 insertions(+) rename src/world.yml => configs/acacia.yml (100%) create mode 100644 configs/sears.yml diff --git a/src/world.yml b/configs/acacia.yml similarity index 100% rename from src/world.yml rename to configs/acacia.yml diff --git a/configs/sears.yml b/configs/sears.yml new file mode 100644 index 0000000..48da9ef --- /dev/null +++ b/configs/sears.yml @@ -0,0 +1,34 @@ +tower: + regions: + 1: + minX: 335 + maxX: 384 + minZ: 530 + maxZ: 579 + escapeHeight: 12 + spawn: + x: 356 + y: 233 + z: 557 + yaw: 0.0 + pitch: 0.0 + doors: + 1: + x: 353 + y: 230 + z: 559 + 2: + x: 354 + y: 230 + z: 559 + lavaY: 280 + laveSpace: 7 + +minX: 325 +maxX: 374 +minZ: 540 +maxZ: 589 + +winconditions: + - LAST_REMAINING + - LAST_OUTSIDE \ No newline at end of file diff --git a/src/de/steamwar/towerrun/listener/GlobalListener.java b/src/de/steamwar/towerrun/listener/GlobalListener.java index edf0dba..50f83e2 100644 --- a/src/de/steamwar/towerrun/listener/GlobalListener.java +++ b/src/de/steamwar/towerrun/listener/GlobalListener.java @@ -19,12 +19,15 @@ package de.steamwar.towerrun.listener; +import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.game.TowerRunPlayer; import de.steamwar.towerrun.state.GameStateBukkitListener; import de.steamwar.towerrun.state.GameStates; +import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import java.util.EnumSet; @@ -46,4 +49,14 @@ public class GlobalListener extends GameStateBukkitListener { } TowerRunPlayer.remove(event.getPlayer()); } + + @EventHandler + public void onPlayerMove(PlayerMoveEvent event) { + Location to = event.getTo(); + if (to.getX() > WorldConfig.MAP_MIN_X && to.getX() < WorldConfig.MAP_MAX_X && to.getZ() > WorldConfig.MAP_MIN_Z && to.getZ() < WorldConfig.MAP_MAX_Z) { + return; + } + + event.setCancelled(true); + } }