From 46db80a056af99dbcf6bbf7c5cc2a3dc3fba21d0 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Tue, 4 Oct 2016 20:32:04 +0100 Subject: [PATCH] Always check game object is not null before attempting to access it (#225) --- .../nautilus/game/arcade/ArcadeManager.java | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 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 79cd35f11..0b5f9ad30 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -839,26 +839,22 @@ public class ArcadeManager extends MiniPlugin implements IRelation { UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); - if (_game.GetCountdown() > 0) //Lobby is counting down + if (_game != null && _game.GetCountdown() > 0) //Lobby is counting down { - // Clean - if (_game != null) + // Remove Data + _game.RemoveTeamPreference(event.getPlayer()); + _game.GetPlayerKits().remove(event.getPlayer()); + _game.GetPlayerGems().remove(event.getPlayer()); + + // Leave Team + GameTeam team = _game.GetTeam(event.getPlayer()); + + if (team != null) { - // Remove Data - _game.RemoveTeamPreference(event.getPlayer()); - _game.GetPlayerKits().remove(event.getPlayer()); - _game.GetPlayerGems().remove(event.getPlayer()); - - // Leave Team - GameTeam team = _game.GetTeam(event.getPlayer()); - - if (team != null) - { - team.RemovePlayer(event.getPlayer()); - } + team.RemovePlayer(event.getPlayer()); } } - else if (_game.GetState() != GameState.Recruit) //Game is NOT in lobby + else if (_game != null && _game.GetState() != GameState.Recruit) //Game is NOT in lobby { addSpectator(event.getPlayer(), true); _specList.add(event.getPlayer()); @@ -874,16 +870,19 @@ public class ArcadeManager extends MiniPlugin implements IRelation { UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); - if (!(_game.GetState() == GameState.Live || _game.GetState() == GameState.Prepare)) + if (_game != null) { - _specList.remove(event.getPlayer()); - if (_game.GetTeam(event.getPlayer()) != null) - _game.GetTeam(event.getPlayer()).SetPlayerState(event.getPlayer(), PlayerState.IN); - } + if (!(_game.GetState() == GameState.Live || _game.GetState() == GameState.Prepare)) + { + _specList.remove(event.getPlayer()); + if (_game.GetTeam(event.getPlayer()) != null) + _game.GetTeam(event.getPlayer()).SetPlayerState(event.getPlayer(), PlayerState.IN); + } - if (_game != null && isSpectator(event.getPlayer())) - { - event.show(false); + if (isSpectator(event.getPlayer())) + { + event.show(false); + } } } }