Fixed player leaving / group membership

This commit is contained in:
Daniel Saukel 2016-06-10 20:05:59 +02:00
parent 01c869f897
commit 7ffec6412b
2 changed files with 16 additions and 18 deletions

View File

@ -461,25 +461,21 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (!(dPlayers.getByPlayer(player) instanceof DInstancePlayer)) {
return;
}
DInstancePlayer dPlayer = (DInstancePlayer) dPlayers.getByPlayer(player);
if (dPlayer == null) {
dPlayers.removePlayer(dPlayer);
return;
}
DGlobalPlayer dPlayer = dPlayers.getByPlayer(player);
DGroup dGroup = DGroup.getByPlayer(player);
// Check GameWorld
Game game = Game.getByWorld(player.getWorld());
if (game != null) {
if (!(dPlayer instanceof DInstancePlayer)) {
dPlayers.removePlayer(dPlayer);
if (dGroup != null) {
dGroup.removePlayer(player);
}
} else if (game != null) {
int timeUntilKickOfflinePlayer = game.getRules().getTimeUntilKickOfflinePlayer();
if (timeUntilKickOfflinePlayer == 0) {
dPlayer.leave();
((DGamePlayer) dPlayer).leave();
} else if (timeUntilKickOfflinePlayer > 0) {
dGroup.sendMessage(DMessages.PLAYER_OFFLINE.getMessage(dPlayer.getPlayer().getName(), String.valueOf(timeUntilKickOfflinePlayer)), player);
@ -490,10 +486,7 @@ public class PlayerListener implements Listener {
}
} else if (dPlayer instanceof DEditPlayer) {
dPlayer.leave();
} else if (dGroup != null) {
dGroup.removePlayer(player);
((DEditPlayer) dPlayer).leave();
}
}

View File

@ -76,6 +76,11 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
dGroup.setGameWorld(game.getWorld());
}
if (game == null) {
cancel();
return;
}
for (Player player : game.getPlayers()) {
new DGamePlayer(player, game.getWorld());
}