diff options
author | ElgarL <ElgarL@palmergames.com> | 2012-04-01 03:44:37 +0100 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2012-04-01 03:44:37 +0100 |
commit | 3f732725245955da9e3e2527a00a6150bec18044 (patch) | |
tree | c873a1e2e961d355695d0cbdd26dd45ab345355d | |
parent | 590357004d324122fcc4ec0f61f7b73b6b395d34 (diff) | |
download | Essentials-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.
-rw-r--r-- | EssentialsGroupManager/src/Changelog.txt | 3 | ||||
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java | 39 |
2 files changed, 40 insertions, 2 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index c57b050c3..c6f45bb01 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -156,4 +156,5 @@ v 1.9: - Auto rename all case sensitive world folders to lower case (if possible).
- Update GlobalGroups.yml for new/changed Towny permission nodes.
- Stop attempting to push empty permissions when players edit the yml's incorrectly.
- - Catch errors caused by bad indentation in yml's.
\ No newline at end of file + - Catch errors caused by bad indentation in yml's.
+ - Force remove player attachments on disconnect, and tidyup during player join in case of any errors. Fixes a bug of losing permissions.
\ No newline at end of file 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);
}
}
|