Can't run out of the arena while ingame.
This commit is contained in:
parent
ea13ac17ad
commit
7f6ec7ca2b
@ -2,6 +2,7 @@ package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
@ -20,32 +21,40 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
double maxX = Math.max(arena.pos1.getX(), arena.pos2.getX());
|
||||
double minX = Math.min(arena.pos1.getX(), arena.pos2.getX());
|
||||
double maxY = Math.max(arena.pos1.getY(), arena.pos2.getY());
|
||||
double minY = Math.min(arena.pos1.getY(), arena.pos2.getY());
|
||||
double maxZ = Math.max(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
double minZ = Math.min(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
double maxX = Math
|
||||
.max(arena.pos1.getX(), arena.pos2.getX());
|
||||
double minX = Math
|
||||
.min(arena.pos1.getX(), arena.pos2.getX());
|
||||
double maxY = Math
|
||||
.max(arena.pos1.getY(), arena.pos2.getY());
|
||||
double minY = Math
|
||||
.min(arena.pos1.getY(), arena.pos2.getY());
|
||||
double maxZ = Math
|
||||
.max(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
double minZ = Math
|
||||
.min(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
|
||||
Location loc = player.getLocation();
|
||||
if (loc.getBlockX() > maxX || loc.getBlockX() < minX) {
|
||||
event.setCancelled(true);
|
||||
loc.getWorld().playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
loc.getWorld().playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
} else if (loc.getBlockZ() > maxZ || loc.getBlockZ() < minZ) {
|
||||
event.setCancelled(true);
|
||||
loc.getWorld().playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
loc.getWorld().playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
} else if (loc.getBlockY() > maxY) {
|
||||
event.setCancelled(true);
|
||||
loc.getWorld().playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
loc.getWorld().playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.subtract(0, 1, 0));
|
||||
} else if (loc.getBlockY() < minY) {
|
||||
event.setCancelled(true);
|
||||
loc.getWorld().playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
loc.getWorld().playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.add(0, 5, 0));
|
||||
Location loc = player.getLocation();
|
||||
if (loc.getBlockX() > maxX || loc.getBlockX() < minX) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
} else if (loc.getBlockZ() > maxZ || loc.getBlockZ() < minZ) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
} else if (loc.getBlockY() > maxY) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.subtract(0, 1, 0));
|
||||
} else if (loc.getBlockY() < minY) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.add(0, 5, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user