diff options
author | Wesley Wolfe <weswolf@aol.com> | 2013-04-12 21:31:24 -0500 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2013-04-12 21:31:24 -0500 |
commit | 7939572c33130103609c245f49c03dbfe4a59ad6 (patch) | |
tree | 64268c03826e1ab42bd9adcdaff0307ec03c0f2e | |
parent | 3e0d8331bee965738bc4e6741183939512ec7995 (diff) | |
download | craftbukkit-7939572c33130103609c245f49c03dbfe4a59ad6.tar craftbukkit-7939572c33130103609c245f49c03dbfe4a59ad6.tar.gz craftbukkit-7939572c33130103609c245f49c03dbfe4a59ad6.tar.lz craftbukkit-7939572c33130103609c245f49c03dbfe4a59ad6.tar.xz craftbukkit-7939572c33130103609c245f49c03dbfe4a59ad6.zip |
Check connection status before setting scoreboard. Fixes BUKKIT-4064
Two connection status checks were added to setting a scoreboard for a
player. The first checks to see if a player has logged in yet, which
implicates the ability to receive packets. The second checks to affirm
that the CraftPlayer reference is still to a logged in player; setting
it while not logged in would maintain a stale player reference in the
scoreboard manager.
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index a93625c4..8c30bf5a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -983,6 +983,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void setScoreboard(Scoreboard scoreboard) { Validate.notNull(scoreboard, "Scoreboard cannot be null"); + PlayerConnection playerConnection = getHandle().playerConnection; + if (playerConnection == null) { + throw new IllegalStateException("Cannot set scoreboard yet"); + } + if (playerConnection.disconnected) { + throw new IllegalStateException("Cannot set scoreboard for invalid CraftPlayer"); + } + this.server.getScoreboardManager().setPlayerBoard(this, scoreboard); } } |