mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-20 18:32:49 +00:00
Force remove player attachments on disconnect, and tidyup during player
join in case of any errors. Fixes a bug of losing permissions.
This commit is contained in:
parent
590357004d
commit
3f73272524
|
@ -156,4 +156,5 @@ v 1.9:
|
||||||
- Auto rename all case sensitive world folders to lower case (if possible).
|
- Auto rename all case sensitive world folders to lower case (if possible).
|
||||||
- Update GlobalGroups.yml for new/changed Towny permission nodes.
|
- Update GlobalGroups.yml for new/changed Towny permission nodes.
|
||||||
- Stop attempting to push empty permissions when players edit the yml's incorrectly.
|
- Stop attempting to push empty permissions when players edit the yml's incorrectly.
|
||||||
- Catch errors caused by bad indentation in yml's.
|
- 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.
|
|
@ -38,6 +38,7 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
|
@ -342,6 +343,18 @@ public class BukkitPermissions {
|
||||||
if (player != null)
|
if (player != null)
|
||||||
this.updatePermissions(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
|
* Player events tracked to cause Superperms updates
|
||||||
|
@ -355,6 +368,12 @@ public class BukkitPermissions {
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
setPlayer_join(true);
|
setPlayer_join(true);
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tidy up any lose ends
|
||||||
|
*/
|
||||||
|
removeAttachment(player);
|
||||||
|
|
||||||
// force GM to create the player if they are not already listed.
|
// force GM to create the player if they are not already listed.
|
||||||
if (plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName()) != null) {
|
if (plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName()) != null) {
|
||||||
setPlayer_join(false);
|
setPlayer_join(false);
|
||||||
|
@ -370,7 +389,25 @@ public class BukkitPermissions {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue