mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-21 10:52:01 +00:00
Don't remove an attachment on a player leaving as Bukkit never forgets
it. This fixes non mirrored permissions being messed up if a player relogs.
This commit is contained in:
parent
b72083fb18
commit
6476158462
|
@ -150,4 +150,5 @@ v 1.9:
|
||||||
- Minor optimization when checking bukkit permissions.
|
- Minor optimization when checking bukkit permissions.
|
||||||
- Better reporting when a users.yml is failing to load.
|
- Better reporting when a users.yml is failing to load.
|
||||||
- Expanded '/manuadd'to accept an optional variable for the world (eg '/manuadd <player> <group> <world>').
|
- Expanded '/manuadd'to accept an optional variable for the world (eg '/manuadd <player> <group> <world>').
|
||||||
- Removed some debug spam.
|
- Removed some debug spam.
|
||||||
|
- Don't remove an attachment on a player leaving as Bukkit never forgets it. This fixes non mirrored permissions being messed up if a player relogs.
|
|
@ -347,32 +347,8 @@ public class WorldsHolder {
|
||||||
String worldNameLowered = worldName.toLowerCase();
|
String worldNameLowered = worldName.toLowerCase();
|
||||||
|
|
||||||
// Find this worlds data
|
// Find this worlds data
|
||||||
if (worldsData.containsKey(worldNameLowered)) {
|
if (worldsData.containsKey(worldNameLowered))
|
||||||
|
|
||||||
String usersMirror = mirrorsUser.get(worldNameLowered);
|
|
||||||
String groupsMirror = mirrorsGroup.get(worldNameLowered);
|
|
||||||
|
|
||||||
if (usersMirror != null) {
|
|
||||||
|
|
||||||
// If both are mirrored
|
|
||||||
if (groupsMirror != null) {
|
|
||||||
|
|
||||||
// if the data sources are the same, return the parent
|
|
||||||
if (usersMirror == groupsMirror)
|
|
||||||
return getUpdatedWorldData(usersMirror.toLowerCase());
|
|
||||||
|
|
||||||
// Both data sources are mirrors, but they are from different parents
|
|
||||||
// so we return the actual data object.
|
|
||||||
return getUpdatedWorldData(worldNameLowered);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Groups isn't a mirror so return this this worlds data source
|
|
||||||
return getUpdatedWorldData(worldNameLowered);
|
|
||||||
}
|
|
||||||
|
|
||||||
// users isn't mirrored so we need to return this worlds data source
|
|
||||||
return getUpdatedWorldData(worldNameLowered);
|
return getUpdatedWorldData(worldNameLowered);
|
||||||
}
|
|
||||||
|
|
||||||
// Oddly no data source was found for this world so return the default.
|
// Oddly no data source was found for this world so return the default.
|
||||||
GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
|
GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
|
|
||||||
|
@ -37,7 +38,6 @@ 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;
|
||||||
|
@ -54,7 +54,7 @@ import org.bukkit.plugin.PluginManager;
|
||||||
*/
|
*/
|
||||||
public class BukkitPermissions {
|
public class BukkitPermissions {
|
||||||
|
|
||||||
protected Map<Player, PermissionAttachment> attachments = new HashMap<Player, PermissionAttachment>();
|
protected WeakHashMap<Player, PermissionAttachment> attachments = new WeakHashMap<Player, PermissionAttachment>();
|
||||||
protected LinkedHashMap<String, Permission> registeredPermissions = new LinkedHashMap<String, Permission>();
|
protected LinkedHashMap<String, Permission> registeredPermissions = new LinkedHashMap<String, Permission>();
|
||||||
protected GroupManager plugin;
|
protected GroupManager plugin;
|
||||||
protected boolean dumpAllPermissions = true;
|
protected boolean dumpAllPermissions = true;
|
||||||
|
@ -368,14 +368,6 @@ public class BukkitPermissions {
|
||||||
updatePermissions(event.getPlayer(), event.getPlayer().getWorld().getName());
|
updatePermissions(event.getPlayer(), event.getPlayer().getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
if (!GroupManager.isLoaded())
|
|
||||||
return;
|
|
||||||
|
|
||||||
attachments.remove(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
attachments.remove(event.getPlayer());
|
attachments.remove(event.getPlayer());
|
||||||
|
|
Loading…
Reference in a new issue