diff --git a/src/me/yaruma/fightsystem/listener/PistonListener.java b/src/me/yaruma/fightsystem/listener/PistonListener.java index ab3162a..d40f30a 100644 --- a/src/me/yaruma/fightsystem/listener/PistonListener.java +++ b/src/me/yaruma/fightsystem/listener/PistonListener.java @@ -21,8 +21,9 @@ public class PistonListener implements Listener { BlockFace b = e.getDirection(); for(Block block : e.getBlocks()){ if( - !Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) && - !Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) + block.getY() > Config.upperArenaBorder || + (!Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) && + !Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic)) ){ e.setCancelled(true); return; @@ -38,8 +39,9 @@ public class PistonListener implements Listener { BlockFace b = e.getDirection(); for(Block block : e.getBlocks()){ if( - !Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) && - !Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) + block.getY() > Config.upperArenaBorder || + (!Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) && + !Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic)) ){ e.setCancelled(true); return; diff --git a/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java b/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java index d022574..8df688a 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java @@ -30,6 +30,8 @@ public class PlayerMoveListener implements Listener { return; } + boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder; + //Check under Arena if(to.getY() <= Config.underArenaBorder) { if(fightTeam == null){ @@ -42,11 +44,15 @@ public class PlayerMoveListener implements Listener { else player.teleport(Config.TeamBlueSpawn); return; + }else if(fightTeam != null && !inArenaY){ + player.teleport(from); + player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!"); + return; } //Check TeamAreas - boolean inBlueArea = Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic); - boolean inRedArea = Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic); + boolean inBlueArea = inArenaY && Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic); + boolean inRedArea = inArenaY && Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic); if(inBlueArea || inRedArea) { if(fightTeam == null){ diff --git a/src/me/yaruma/fightsystem/utils/Config.java b/src/me/yaruma/fightsystem/utils/Config.java index 5d44a2e..c2f8ec6 100644 --- a/src/me/yaruma/fightsystem/utils/Config.java +++ b/src/me/yaruma/fightsystem/utils/Config.java @@ -32,6 +32,7 @@ public class Config { public static int Schem2BorderZ; public static int underArenaBorder; public static int BorderFromSchematic; + public static int upperArenaBorder; public static boolean OnlyPublicSchematics; public static String SchematicDirectory; @@ -163,6 +164,8 @@ public class Config { TeamBlueCornerZ -= SchemsizeZ; } + upperArenaBorder = TeamBlueCornerY + SchemsizeY + BorderFromSchematic; + TeamRedCornerX = TeamBluetoReddistanceX + TeamBlueCornerX; TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY; TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;