Guard against exceptions when setting scoreboards for disconnecting players.

Turns out that a player who disconnects while in the arena is actually still online if you ask the Player object. The setScoreboard() javadoc specifically says it throws an IllegalStateException in that case, so we can just catch and swallow it.

It's unclear what the state of the player's scoreboard is when they rejoin the server, but a borken scoreboard is better than a rogue exception.
This commit is contained in:
Andreas Troelsen 2018-04-23 11:53:24 +02:00
parent 99f57b7128
commit 5d2881383f

View File

@ -44,7 +44,11 @@ public class ScoreboardManager {
* @param player a player
*/
void removePlayer(Player player) {
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
try {
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
} catch (IllegalStateException e) {
// Happens if the player is logging out, just swallow it
}
}
/**