From ace7d1764c68f6ea679ae60b3104d1af96e1869c Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sun, 31 Jan 2016 10:22:59 -0500 Subject: [PATCH] Fixed various ways of players going invisible through Spec mode. --- .../nautilus/game/arcade/ArcadeManager.java | 3 ++ .../game/games/paintball/Paintball.java | 5 ++ .../arcade/game/games/wither/WitherGame.java | 5 ++ .../arcade/managers/GameSpectatorManager.java | 48 ++++++++++--------- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 4e574f3cf..1c803d15a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -861,6 +861,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation public void Clear(Player player) { + if (player.getGameMode() == GameMode.SPECTATOR) + player.setSpectatorTarget(null); + player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(false); player.setFlySpeed(0.1F); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index 5f4d7b2b4..0d51c64a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -8,6 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -481,6 +482,10 @@ public class Paintball extends TeamGame } //Settings + if (player.getGameMode() == GameMode.SPECTATOR) + player.setSpectatorTarget(null); + + player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(false); player.setFlying(false); ((CraftPlayer)player).getHandle().spectating = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index efa9c8342..6a6749d96 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -9,6 +9,7 @@ import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.EntityEffect; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -820,6 +821,10 @@ public class WitherGame extends TeamGame implements IBlockRestorer } // Settings + if (player.getGameMode() == GameMode.SPECTATOR) + player.setSpectatorTarget(null); + + player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(false); player.setFlying(false); ((CraftPlayer) player).getHandle().spectating = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java index 0082fc1ce..4515bcf47 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java @@ -2,6 +2,19 @@ package nautilus.game.arcade.managers; import java.util.List; +import org.bukkit.GameMode; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; @@ -13,23 +26,6 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.event.vehicle.VehicleDamageEvent; -import org.bukkit.inventory.ItemStack; - public class GameSpectatorManager implements Listener { ArcadeManager Manager; @@ -228,19 +224,25 @@ public class GameSpectatorManager implements Listener @Override public void run() { - if(target instanceof Player) + Player ptarget = null; + if (target instanceof Player) + ptarget = (Player) target; + + if (ptarget != null) { - if(!Manager.GetGame().IsAlive(target)) + if (!Manager.GetGame().IsAlive(ptarget)) return; } + player.setGameMode(GameMode.SPECTATOR); player.setSpectatorTarget(target); - if(target instanceof Player) - UtilTextBottom.display(C.cYellow + "You are spectating " + F.game(((Player) target).getName()), player); - UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating")); + if (ptarget != null) + UtilTextBottom.display(C.cGray + "You are spectating " + F.elem(Manager.GetGame().GetTeam(ptarget).GetColor() + ptarget.getName()) + ".", player); + + UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating.")); } - }, 3); + }, 1); } @EventHandler(priority = EventPriority.LOW)