summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2012-04-01 03:44:37 +0100
committerElgarL <ElgarL@palmergames.com>2012-04-01 03:44:37 +0100
commit3f732725245955da9e3e2527a00a6150bec18044 (patch)
treec873a1e2e961d355695d0cbdd26dd45ab345355d /EssentialsGroupManager/src/org
parent590357004d324122fcc4ec0f61f7b73b6b395d34 (diff)
downloadEssentials-3f732725245955da9e3e2527a00a6150bec18044.tar
Essentials-3f732725245955da9e3e2527a00a6150bec18044.tar.gz
Essentials-3f732725245955da9e3e2527a00a6150bec18044.tar.lz
Essentials-3f732725245955da9e3e2527a00a6150bec18044.tar.xz
Essentials-3f732725245955da9e3e2527a00a6150bec18044.zip
Force remove player attachments on disconnect, and tidyup during player
join in case of any errors. Fixes a bug of losing permissions.
Diffstat (limited to 'EssentialsGroupManager/src/org')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java39
1 files changed, 38 insertions, 1 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
index dc08168dc..5c711351e 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
@@ -38,6 +38,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.permissions.Permission;
@@ -342,6 +343,18 @@ public class BukkitPermissions {
if (player != null)
this.updatePermissions(player, null);
}
+
+ /**
+ * Force remove any attachments
+ *
+ * @param player
+ */
+ private void removeAttachment(Player player) {
+ if (attachments.containsKey(player)) {
+ player.removeAttachment(attachments.get(player));
+ attachments.remove(player);
+ }
+ }
/**
* Player events tracked to cause Superperms updates
@@ -355,6 +368,12 @@ public class BukkitPermissions {
public void onPlayerJoin(PlayerJoinEvent event) {
setPlayer_join(true);
Player player = event.getPlayer();
+
+ /*
+ * Tidy up any lose ends
+ */
+ removeAttachment(player);
+
// force GM to create the player if they are not already listed.
if (plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName()) != null) {
setPlayer_join(false);
@@ -370,7 +389,25 @@ public class BukkitPermissions {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerKick(PlayerKickEvent event) {
- attachments.remove(event.getPlayer());
+ Player player = event.getPlayer();
+
+ /*
+ * force remove any attachments as bukkit may not
+ */
+ removeAttachment(player);
+ }
+
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onPlayerQuit(PlayerQuitEvent event) {
+ if (!GroupManager.isLoaded())
+ return;
+
+ Player player = event.getPlayer();
+
+ /*
+ * force remove any attachments as bukkit may not
+ */
+ removeAttachment(player);
}
}