From 5e4190ea75ad09b53cafc11fa048ff22d66919f4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 25 Jun 2023 20:07:41 +0200 Subject: [PATCH] Limit JoinAnytime to variable teams Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/fight/FightTeam.java | 4 +++- .../fightsystem/listener/JoinRequestListener.java | 13 ++++++++++++- .../de/steamwar/fightsystem/listener/Permanent.java | 3 --- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index ecd5b8a..ca19f3b 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -307,7 +307,9 @@ public class FightTeam { if(player.isOnline()){ FightSystem.getTechHider().reloadChunks(player, chunksToReload, true); - HotbarKit.SPECTATOR_KIT.loadToPlayer(player); + + if(ArenaMode.VariableTeams.contains(Config.mode)) + HotbarKit.SPECTATOR_KIT.loadToPlayer(player); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java index ad634a2..1ed3fe8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java @@ -23,6 +23,7 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.HotbarKit; import de.steamwar.fightsystem.fight.JoinRequest; import de.steamwar.fightsystem.states.FightState; @@ -35,6 +36,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; public class JoinRequestListener implements Listener { @@ -48,12 +50,21 @@ public class JoinRequestListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); + FightPlayer fp = Fight.getFightPlayer(player); - if (!Config.ArenaLeaveable && !Fight.fighting(player)) { + if (!Config.ArenaLeaveable && (fp == null || !fp.isLiving())) { HotbarKit.SPECTATOR_KIT.loadToPlayer(player); } } + @EventHandler + public void handlePlayerRespawn(PlayerRespawnEvent event) { + Player player = event.getPlayer(); + if(Fight.fighting(player)) { + HotbarKit.SPECTATOR_KIT.loadToPlayer(player); + } + } + @EventHandler public void onLeave(PlayerQuitEvent event) { JoinRequest request = JoinRequest.get(event.getPlayer()); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index cb17931..b5cb0e7 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -25,7 +25,6 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.fight.HotbarKit; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.BountifulWrapper; @@ -77,7 +76,6 @@ public class Permanent implements Listener { FightTeam team = Fight.getPlayerTeam(player); event.setRespawnLocation(team == null ? Config.SpecSpawn : team.getSpawn()); - HotbarKit.SPECTATOR_KIT.loadToPlayer(player); } } @@ -103,7 +101,6 @@ public class Permanent implements Listener { player.teleport(Config.SpecSpawn); } else if(fp != null && !fp.isLiving()) { Fight.setPlayerGamemode(player, GameMode.SPECTATOR); - HotbarKit.SPECTATOR_KIT.loadToPlayer(player); player.teleport(fp.getTeam().getSpawn()); } }