Always check game object is not null before attempting to access it (#225)
This commit is contained in:
parent
5d8c079be6
commit
46db80a056
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user