if (match == null) return;
// leave the team, if necessary
AutoRefTeam team = plugin.getTeam(player);
if (team != null) match.messageReferees("player", player.getName(), "logout");
if (team != null && !match.getCurrentState().inProgress()) team.leave(player);
AutoRefPlayer apl = match.getPlayer(player);
if (apl != null && player.getLocation() != null)
apl.setLastLogoutLocation(player.getLocation());