diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-01-26 00:28:10 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-01-26 00:28:10 +0000 |
commit | 0987606eff9c4ac7719684ca4c4555b9d6b98f98 (patch) | |
tree | 0a679a4beeb54e57602a8aa2a3e390188696f874 /EssentialsGroupManager/src/org/anjocaido/groupmanager | |
parent | 1f12d77a3f10aa0dafb53495af670406457369a1 (diff) | |
parent | 6642d9996a48c28905774277501148f6ab304040 (diff) | |
download | Essentials-0987606eff9c4ac7719684ca4c4555b9d6b98f98.tar Essentials-0987606eff9c4ac7719684ca4c4555b9d6b98f98.tar.gz Essentials-0987606eff9c4ac7719684ca4c4555b9d6b98f98.tar.lz Essentials-0987606eff9c4ac7719684ca4c4555b9d6b98f98.tar.xz Essentials-0987606eff9c4ac7719684ca4c4555b9d6b98f98.zip |
Merge remote branch 'remotes/origin/groupmanager'
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager')
5 files changed, 33 insertions, 15 deletions
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<String, Object> 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<String, Object>) GMconfig.getConfigurationSection("settings.permission.world.mirror").getValues(false); - else + } else if (GMconfig.isConfigurationSection("settings.mirrors")){ return (Map<String, Object>) GMconfig.getConfigurationSection("settings.mirrors").getValues(false); + } + return null; } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index 6e9b7ad21..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()); @@ -152,21 +161,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() { 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; 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<String, Object> mirrorsMap = plugin.getGMConfig().getMirrorsMap(); + Map<String, Object> mirrorsMap = plugin.getGMConfig().getMirrorsMap(); + if (mirrorsMap != null) { for (String source : mirrorsMap.keySet()) { // Make sure all non mirrored worlds have a set of data files. 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());
}
}
|