From 5dc773032bd24b588638ce4ad95dad2d846a4631 Mon Sep 17 00:00:00 2001 From: Virizion <9b717b9d4e5f09e89fa3@gmail.com> Date: Sat, 23 Jan 2016 02:10:11 -0500 Subject: [PATCH] Add joining players to guardians team instead of spectator. --- .../games/speedbuilders/SpeedBuilders.java | 53 ++++++++++++++++--- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index e551481cf..6dd555789 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -31,15 +31,15 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.speedbuilders.stattrackers.DependableTracker; -import nautilus.game.arcade.game.games.speedbuilders.stattrackers.FirstBuildTracker; -import nautilus.game.arcade.game.games.speedbuilders.stattrackers.PerfectionistTracker; import nautilus.game.arcade.game.games.speedbuilders.data.BuildData; import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData; import nautilus.game.arcade.game.games.speedbuilders.data.MobData; import nautilus.game.arcade.game.games.speedbuilders.data.RecreationData; import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; import nautilus.game.arcade.game.games.speedbuilders.kits.DefaultKit; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.DependableTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.FirstBuildTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.PerfectionistTracker; import nautilus.game.arcade.game.games.speedbuilders.stattrackers.SpeediestBuilderizerTracker; import nautilus.game.arcade.kit.Kit; import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; @@ -77,6 +77,7 @@ import org.bukkit.event.entity.ItemMergeEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.StructureGrowEvent; @@ -396,10 +397,13 @@ public class SpeedBuilders extends SoloGame } } - public void moveToGuardians(Player player) + public void moveToGuardians(Player player, boolean elimination) { - GetTeamList().get(0).SetPlacement(player, PlayerState.OUT); - GetTeamList().get(0).RemovePlayer(player); + if (elimination) + { + GetTeamList().get(0).SetPlacement(player, PlayerState.OUT); + GetTeamList().get(0).RemovePlayer(player); + } GetTeamList().get(1).AddPlayer(player, true); @@ -423,7 +427,11 @@ public class SpeedBuilders extends SoloGame if (event.GetState() != GameState.Live) return; - GameTeam guardians = new GameTeam(this, "Guardians", ChatColor.GRAY, new ArrayList()); + //Add 1 spawn so it doesn't freak out + ArrayList spawns = new ArrayList(); + spawns.add(GetSpectatorLocation()); + + GameTeam guardians = new GameTeam(this, "Guardians", ChatColor.GRAY, spawns); AddTeam(guardians); } @@ -973,7 +981,7 @@ public class SpeedBuilders extends SoloGame _buildRecreations.remove(eliminating.Player); - moveToGuardians(eliminating.Player); + moveToGuardians(eliminating.Player, true); } }, 40L); } @@ -1444,6 +1452,34 @@ public class SpeedBuilders extends SoloGame event.setCancelled(true); } + //Add to guardians before arcade manager adds to spectator to trick it into thinking the player is "alive" + @EventHandler(priority = EventPriority.LOW) + public void joinAddGuardian(PlayerJoinEvent event) + { + if (!InProgress()) + return; + + moveToGuardians(event.getPlayer(), false); + event.getPlayer().teleport(GetSpectatorLocation()); + + //We need to disguise a tick after + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + DisguiseGuardian disguise = new DisguiseGuardian(event.getPlayer()); + disguise.setName(C.cGray + event.getPlayer().getName()); + disguise.setCustomNameVisible(true); + + Manager.GetDisguise().disguise(disguise); + + event.getPlayer().setAllowFlight(true); + event.getPlayer().setFlying(true); + } + }, 1); + } + @Override public void EndCheck() { @@ -1489,6 +1525,7 @@ public class SpeedBuilders extends SoloGame List losers = GetTeamList().get(1).GetPlayers(false); losers.removeAll(winners); + losers.retainAll(GetTeamList().get(0).GetPlacements(true)); return losers; }