From 704f79a166f368e0cf3a98ac0182814d209a6795 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 1 Mar 2023 20:00:32 +0100 Subject: [PATCH] Fix arena border, piston border, and y-Damage Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/Config.java | 10 ++--- .../fightsystem/listener/ArenaBorder.java | 39 ++++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index 8d28cfa..423a9c3 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -61,6 +61,7 @@ public class Config { public static final Region BlueExtendRegion; public static final Region RedExtendRegion; public static final Region ArenaRegion; + public static final Region PlayerRegion; public static final Location TeamBlueSpawn; public static final Location TeamRedSpawn; @@ -300,14 +301,13 @@ public class Config { RedRotate = teamRedRotate; BlueRotate = teamBlueRotate; - int arenaYSize = blueCornerY - underBorder + schemsizeY + PreperationArea; - RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ); BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ); - RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); - BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); - ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ); + RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); + BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); + ArenaRegion = new Region(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0); + PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, world.getMaxHeight() - underBorder, arenaMaxZ - arenaMinZ); EventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); if(EventKampfID >= 1){ diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java index 600a798..9eab82d 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java @@ -26,7 +26,9 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.states.StateDependentTask; import net.md_5.bungee.api.ChatMessageType; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -38,40 +40,39 @@ public class ArenaBorder implements Listener { public ArenaBorder() { new StateDependentListener(ArenaMode.All, FightState.All, this); + new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2); } @EventHandler public void arenaBorder(PlayerMoveEvent event){ Player player = event.getPlayer(); - if(Config.ArenaLeaveable && !Fight.fighting(player)) + FightTeam team = Fight.getPlayerTeam(player); + + if(Config.ArenaLeaveable && team == null) return; Location to = event.getTo(); assert to != null; - if(!Config.ArenaRegion.in2dRegion(to)){ - reset(event); + if(Config.PlayerRegion.inRegion(to)) return; - } - FightTeam team = Fight.getPlayerTeam(player); - if(team == null || player.getGameMode() == GameMode.SPECTATOR){ - if(to.getY() <= Config.ArenaRegion.getMinY()) - reset(event); - return; - } - - if(to.getY() <= Config.ArenaRegion.getMinY()) { - if(FightState.infight()) - player.damage(2); - else if(!Config.GroundWalkable) + if(to.getY() <= Config.PlayerRegion.getMinY() && player.getGameMode() != GameMode.SPECTATOR && team != null) { + if(!Config.GroundWalkable && !FightState.infight()) player.teleport(team.getSpawn()); - } - } - private void reset(PlayerMoveEvent event){ - Player player = event.getPlayer(); + return; + } + player.teleport(event.getFrom()); FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR); } + + private void damage() { + for(Player player : Bukkit.getServer().getOnlinePlayers()) { + FightTeam team = Fight.getPlayerTeam(player); + if(team != null && player.getLocation().getY() <= Config.PlayerRegion.getMinY()) + player.damage(1); + } + } }