From 75af1f00bad488393e83b1ba4c2e7d08daf96c9b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 25 Jan 2024 11:24:22 +0100 Subject: [PATCH 1/2] Fix respawn own Schematic collision Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/fight/Fight.java | 2 +- .../src/de/steamwar/fightsystem/listener/TeamArea.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java index cd7a232..5b8f62f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java @@ -123,7 +123,7 @@ public class Fight { if(!player.isOnline()) return; pseudoSpectator(player, true); - }, 2); + }, 1); }else if(gameMode == GameMode.SURVIVAL) { for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) { if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java index 154919c..53c484f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.events.BoardingEvent; import de.steamwar.fightsystem.events.TeamDeathEvent; import de.steamwar.fightsystem.events.TeamSpawnEvent; @@ -31,6 +32,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -114,8 +116,14 @@ public class TeamArea implements Listener { fightPlayer.ifPlayer(player -> { boolean inRegion = team.getExtendRegion().playerInRegion(player.getLocation()); if(inRegion && !realSpectator.contains(player)) { - Fight.pseudoSpectator(player, false); realSpectator.add(player); + + //Later to prevent race condition with Fight.setSpecatator() during respawn + Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { + if(!player.isOnline()) + return; + Fight.pseudoSpectator(player, false); + }, 2); }else if(!inRegion && realSpectator.contains(player)) { Fight.pseudoSpectator(player, true); realSpectator.remove(player); From 33a84d6a66c15eb1171360276e885ee6716bd8cd Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 26 Jan 2024 09:06:54 +0100 Subject: [PATCH 2/2] Fix team leave Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/listener/Border.java | 5 ++++- .../src/de/steamwar/fightsystem/listener/TeamArea.java | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java index 6ae3384..6f8bddd 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java @@ -58,7 +58,10 @@ public class Border { } public void addPlayer(Player player) { - ghostBarriers.computeIfAbsent(player, uuid -> new HashSet<>()); + if(ghostBarriers.containsKey(player)) + return; + + ghostBarriers.put(player, new HashSet<>()); lastLocation.put(player, player.getLocation()); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java index 53c484f..cf241bd 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.events.BoardingEvent; import de.steamwar.fightsystem.events.TeamDeathEvent; +import de.steamwar.fightsystem.events.TeamLeaveEvent; import de.steamwar.fightsystem.events.TeamSpawnEvent; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightPlayer; @@ -77,6 +78,14 @@ public class TeamArea implements Listener { } } + @EventHandler + public void teamLeave(TeamLeaveEvent e) { + FightPlayer fightPlayer = e.getFightPlayer(); + fightPlayer.ifPlayer(spectatorBorder::addPlayer); + if(fightPlayer.getTeam() == team) + fightPlayer.ifPlayer(bordingBorder::removePlayer); + } + @EventHandler public void boarding(BoardingEvent e) { FightPlayer fightPlayer = e.getFightPlayer();