From 8a5eba9664c8ba381d66d3970d4c06be187072e1 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Wed, 25 Jan 2012 22:33:22 +0000 Subject: Fixed subgroups (I broke earlier). --- .../src/org/anjocaido/groupmanager/data/User.java | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index 6e9b7ad21..7a590c412 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -152,21 +152,27 @@ public class User extends DataUnit implements Cloneable { if (this.group.equalsIgnoreCase(subGroup.getName())) { return false; } + // User already has this subgroup + if (containsSubGroup(subGroup)) + return false; + + // If the group doesn't exists add it if (!this.getDataSource().groupExists(subGroup.getName())) { getDataSource().addGroup(subGroup); - - flagAsChanged(); - if (GroupManager.isLoaded()) { - if (!GroupManager.BukkitPermissions.isPlayer_join()) - GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); - GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED); - } - return true; } + + subGroups.add(subGroup.getName()); + flagAsChanged(); + if (GroupManager.isLoaded()) { + if (!GroupManager.BukkitPermissions.isPlayer_join()) + GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); + GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED); + } + return true; + //subGroup = getDataSource().getGroup(subGroup.getName()); //removeSubGroup(subGroup); //subGroups.add(subGroup.getName()); - return false; } public int subGroupsSize() { -- cgit v1.2.3 From d6d4afc3f58e4f5e954351088bf43e0e1989312f Mon Sep 17 00:00:00 2001 From: ElgarL Date: Wed, 25 Jan 2012 22:35:24 +0000 Subject: Check for a null player object in the PlayerTeleportEvent. --- .../src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 481779c3c..3ab2dbbeb 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -397,7 +397,7 @@ public class BukkitPermissions { @EventHandler(priority = EventPriority.LOWEST) public void onPlayerTeleport(PlayerTeleportEvent event) { // can be teleported into another world - if ((event.getTo() != null) && (!event.getFrom().getWorld().equals(event.getTo().getWorld()))) { // only if world actually changed + if ((event.getTo() != null) && (event.getPlayer() != null) && (!event.getFrom().getWorld().equals(event.getTo().getWorld()))) { // only if world actually changed updatePermissions(event.getPlayer(), event.getTo().getWorld().getName()); } } -- cgit v1.2.3 From 29ca77791c8f7fd4e44b1fd3f0217f3666dbe63a Mon Sep 17 00:00:00 2001 From: ElgarL Date: Wed, 25 Jan 2012 22:43:07 +0000 Subject: Trap errors in fetching the mirrors map. --- .../src/org/anjocaido/groupmanager/GMConfiguration.java | 6 ++++-- .../org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java index 591afe3fa..d830696e7 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java @@ -66,10 +66,12 @@ public class GMConfiguration { public Map getMirrorsMap() { // Try to fetch the old mirror path first - if (GMconfig.isConfigurationSection("settings.permission.world.mirror")) + if (GMconfig.isConfigurationSection("settings.permission.world.mirror")) { return (Map) GMconfig.getConfigurationSection("settings.permission.world.mirror").getValues(false); - else + } else if (GMconfig.isConfigurationSection("settings.mirrors")){ return (Map) GMconfig.getConfigurationSection("settings.mirrors").getValues(false); + } + return null; } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java index 320fe3e26..686a5495d 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java @@ -116,7 +116,8 @@ public class WorldsHolder { public void mirrorSetUp() { mirrorsGroup.clear(); mirrorsUser.clear(); - Map mirrorsMap = plugin.getGMConfig().getMirrorsMap(); + Map mirrorsMap = plugin.getGMConfig().getMirrorsMap(); + if (mirrorsMap != null) { for (String source : mirrorsMap.keySet()) { // Make sure all non mirrored worlds have a set of data files. -- cgit v1.2.3 From 6642d9996a48c28905774277501148f6ab304040 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Wed, 25 Jan 2012 23:44:14 +0000 Subject: Fixed an infinite loop error when using '/manudel' on a logged in player. It caused setDefaultGroup to trigger a bukkit update when no GM User existed yet. --- .../src/org/anjocaido/groupmanager/data/User.java | 11 ++++++++++- .../anjocaido/groupmanager/dataholder/WorldDataHolder.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index 7a590c412..980b0846c 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -122,6 +122,15 @@ public class User extends DataUnit implements Cloneable { * the group to set */ public void setGroup(Group group) { + setGroup(group, true); + } + + /** + * @param group the group to set + * @param updatePerms if we are to trigger a superperms update. + * + */ + public void setGroup(Group group, Boolean updatePerms) { if (!this.getDataSource().groupExists(group.getName())) { getDataSource().addGroup(group); } @@ -129,7 +138,7 @@ public class User extends DataUnit implements Cloneable { String oldGroup = this.group; this.group = group.getName(); flagAsChanged(); - if (GroupManager.isLoaded()) { + if (GroupManager.isLoaded() && (updatePerms)) { if (!GroupManager.BukkitPermissions.isPlayer_join()) GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index c9c1d2b64..3cbfbd50b 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -245,7 +245,7 @@ public class WorldDataHolder { return null; } User newUser = new User(this, userName); - newUser.setGroup(groups.getDefaultGroup()); + newUser.setGroup(groups.getDefaultGroup(), false); addUser(newUser); setUsersChanged(true); return newUser; -- cgit v1.2.3