From ec1038bce643d835634c11886c245d93fd431d77 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 23 Jul 2018 13:34:04 +0100 Subject: [PATCH] Enable rejoining in other games --- .../game/arcade/game/games/bridge/Bridge.java | 18 +++++++----------- .../game/games/common/CaptureTheFlag.java | 4 ++++ .../arcade/game/games/common/Domination.java | 4 ++++ .../game/arcade/game/games/draw/Draw.java | 4 ++++ .../arcade/game/games/hideseek/HideSeek.java | 11 +++++++++++ .../arcade/game/games/turfforts/TurfForts.java | 4 ++++ .../game/modules/rejoin/RejoinModule.java | 13 ++++++++++++- 7 files changed, 46 insertions(+), 12 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 73bf32677..1f5903042 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -90,6 +90,7 @@ import nautilus.game.arcade.game.games.bridge.kits.KitDestructor; import nautilus.game.arcade.game.games.bridge.kits.KitMiner; import nautilus.game.arcade.game.games.bridge.mission.KillLastTracker; import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.game.modules.rejoin.RejoinModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.perks.PerkBomber; import nautilus.game.arcade.ore.OreHider; @@ -125,6 +126,7 @@ public class Bridge extends TeamGame implements OreObsfucation private boolean _bridgesDown = false; private BridgeAnimation _animation; private CustomBridgeAnimation[] _customAnimations; + private final RejoinModule _rejoinModule; private HashSet _bridgeParts = new HashSet(); @@ -270,6 +272,9 @@ public class Bridge extends TeamGame implements OreObsfucation .setGiveCompassToAlive(true) .register(this); + _rejoinModule = new RejoinModule(manager); + _rejoinModule.register(this); + // So that we can be 110% sure for (Kit kit : GetKits()) { @@ -877,6 +882,7 @@ public class Bridge extends TeamGame implements OreObsfucation { _bridgesDown = true; Manager.GetExplosion().SetLiquidDamage(true); + _rejoinModule.disableRejoining(); Announce(C.cRedB + "ALERT: " + C.Reset + C.Bold + "THE BRIDGES ARE SPAWNING!"); UtilTextMiddle.display(C.cRedB + "ALERT", "The BRIDGES ARE SPAWNING!"); @@ -903,17 +909,7 @@ public class Bridge extends TeamGame implements OreObsfucation return; } - Iterator partIterator = _bridgeParts.iterator(); - - while (partIterator.hasNext()) - { - BridgePart part = partIterator.next(); - - if (part.Update()) - { - partIterator.remove(); - } - } + _bridgeParts.removeIf(BridgePart::Update); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java index bd014fa44..fbf920dc1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java @@ -56,6 +56,7 @@ import nautilus.game.arcade.game.games.common.dominate_data.PlayerData; import nautilus.game.arcade.game.games.common.dominate_data.Resupply; import nautilus.game.arcade.game.modules.SpawnRegenerationModule; import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.game.modules.rejoin.RejoinModule; import nautilus.game.arcade.kit.Kit; public class CaptureTheFlag extends TeamGame @@ -106,6 +107,9 @@ public class CaptureTheFlag extends TeamGame this.HungerSet = 20; this.WorldTimeSet = 2000; + new RejoinModule(manager) + .register(this); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java index b5b66adde..164b11672 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java @@ -45,6 +45,7 @@ import nautilus.game.arcade.game.games.common.dominate_data.PlayerData; import nautilus.game.arcade.game.games.common.dominate_data.Resupply; import nautilus.game.arcade.game.modules.SpawnRegenerationModule; import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.game.modules.rejoin.RejoinModule; import nautilus.game.arcade.kit.Kit; public class Domination extends TeamGame @@ -85,6 +86,9 @@ public class Domination extends TeamGame this.DeathSpectateSecs = 10; + new RejoinModule(manager) + .register(this); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 35ca2f815..b83614949 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -59,6 +59,7 @@ import nautilus.game.arcade.game.games.draw.tools.ToolCircle; import nautilus.game.arcade.game.games.draw.tools.ToolLine; import nautilus.game.arcade.game.games.draw.tools.ToolSquare; import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.game.modules.rejoin.RejoinModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.DrawGuessStatTracker; @@ -262,6 +263,9 @@ public class Draw extends SoloGame new ChatStatData("PureLuck", "Lucky Guesses", true) ); + new RejoinModule(manager) + .register(this); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index be52bd24a..3539f343d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -117,6 +117,8 @@ import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerLeaper; import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerRadar; import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerTNT; import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.game.modules.rejoin.PlayerRejoinGameEvent; +import nautilus.game.arcade.game.modules.rejoin.RejoinModule; import nautilus.game.arcade.game.team.selectors.RatioSelector; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; @@ -358,6 +360,9 @@ public class HideSeek extends TeamGame //Need ideas for this one registerChatStats(); + new RejoinModule(manager) + .register(this); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -1487,6 +1492,12 @@ public class HideSeek extends TeamGame } } + @EventHandler(ignoreCancelled = true) + public void playerRejoin(PlayerRejoinGameEvent event) + { + event.getPlayerGameInfo().setTeam(_seekers); + } + public GameTeam getHiders() { return _hiders; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index c044f58d9..141fce8d9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -63,6 +63,7 @@ import nautilus.game.arcade.game.games.turfforts.kits.KitMarksman; import nautilus.game.arcade.game.games.turfforts.kits.KitShredder; import nautilus.game.arcade.game.games.turfforts.mission.KillMidAirMissionTracker; import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.game.modules.rejoin.RejoinModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.BehindEnemyLinesStatTracker; @@ -177,6 +178,9 @@ public class TurfForts extends TeamGame new ChatStatData("BlocksBroken", "Blocks Broken", true) ); + new RejoinModule(manager) + .register(this); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/rejoin/RejoinModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/rejoin/RejoinModule.java index 920502f93..34fa550f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/rejoin/RejoinModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/rejoin/RejoinModule.java @@ -47,6 +47,12 @@ public class RejoinModule extends Module UtilServer.Unregister(_manager); } + public void disableRejoining() + { + getGame().QuitOut = true; + _rejoinData.clear(); + } + @EventHandler(priority = EventPriority.LOW) public void playerQuit(PlayerQuitEvent event) { @@ -135,7 +141,7 @@ public class RejoinModule extends Module { private final double _health; private final Kit _kit; - private final GameTeam _team; + private GameTeam _team; private boolean _cancelled; PlayerGameInfo(double health, Kit kit, GameTeam team) @@ -155,6 +161,11 @@ public class RejoinModule extends Module return _kit; } + public void setTeam(GameTeam team) + { + _team = team; + } + public GameTeam getTeam() { return _team;