Better update for the User object player reference.

This commit is contained in:
ElgarL 2012-06-16 19:12:54 +01:00
parent 78d4987d5d
commit 5683ea35fc
2 changed files with 6 additions and 14 deletions

View File

@ -256,15 +256,10 @@ public class User extends DataUnit implements Cloneable {
}
}
public void clearPlayer() {
bukkitPlayer = null;
}
public User updatePlayer(Player player) {
if (player != null) {
bukkitPlayer = player;
}
bukkitPlayer = player;
return this;
}

View File

@ -145,6 +145,11 @@ public class BukkitPermissions {
if (player == null || !GroupManager.isLoaded()) {
return;
}
// Reset the User objects player reference.
User user = plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName());
if (user != null)
user.updatePlayer(player);
PermissionAttachment attachment;
@ -441,10 +446,6 @@ public class BukkitPermissions {
public void onPlayerKick(PlayerKickEvent event) {
Player player = event.getPlayer();
User user = plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName());
if (user != null)
user.clearPlayer();
/*
* force remove any attachments as bukkit may not
@ -459,10 +460,6 @@ public class BukkitPermissions {
return;
Player player = event.getPlayer();
User user = plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName());
if (user != null)
user.clearPlayer();
/*
* force remove any attachments as bukkit may not