diff options
author | ElgarL <ElgarL@palmergames.com> | 2012-01-24 14:21:07 +0000 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2012-01-24 14:21:07 +0000 |
commit | 145b0be2f31b944b2bfda751ed05f8e6ac37300d (patch) | |
tree | d8649ad4f5f266aa6fad51639ac029b3f0deb0e3 /EssentialsGroupManager | |
parent | 1dab4f95dd834af67dbc6f6c8e190d62f3e93752 (diff) | |
download | Essentials-145b0be2f31b944b2bfda751ed05f8e6ac37300d.tar Essentials-145b0be2f31b944b2bfda751ed05f8e6ac37300d.tar.gz Essentials-145b0be2f31b944b2bfda751ed05f8e6ac37300d.tar.lz Essentials-145b0be2f31b944b2bfda751ed05f8e6ac37300d.tar.xz Essentials-145b0be2f31b944b2bfda751ed05f8e6ac37300d.zip |
addSubGroup now returns a boolean for success/failure.
'/manuaddsub' now correctly reports if it was able to add the sub
group.
Diffstat (limited to 'EssentialsGroupManager')
3 files changed, 23 insertions, 14 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 22e812dd6..5d9f1fff5 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -113,4 +113,7 @@ v 1.9: - Fixed infinite loop error on player join.
- Optimized code to only update the player logging in instead of all players online.
- Added recursive loop detection for World mirroring (you may not set the main world as a mirror of another).
- - Fixed fetching world data so it no longer returns the mirrored world for groups. Each world data holder now points to the correct data set, so can be returned as an object.
\ No newline at end of file + - Fixed fetching world data so it no longer returns the mirrored world for groups. Each world data holder now points to the correct data set, so can be returned as an object.
+ - Changed addSubGroup() to only add the group if it doesn't already exist (no need to update an already existing group).
+ - addSubGroup now returns a boolean for success/failure.
+ - '/manuaddsub' now correctly reports if it was able to add the sub group.
\ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index d8f5418ed..c0ed77adc 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -489,8 +489,10 @@ public class GroupManager extends JavaPlugin { return false; } // PARECE OK - auxUser.addSubGroup(auxGroup); - sender.sendMessage(ChatColor.YELLOW + "You added subgroup '" + auxGroup.getName() + "' to player '" + auxUser.getName() + "'."); + if (auxUser.addSubGroup(auxGroup)) + sender.sendMessage(ChatColor.YELLOW + "You added subgroup '" + auxGroup.getName() + "' to player '" + auxUser.getName() + "'."); + else + sender.sendMessage(ChatColor.RED + "The subgroup '" + auxGroup.getName() + "' is already available to '" + auxUser.getName() + "'."); targetPlayer = this.getServer().getPlayer(auxUser.getName()); if (targetPlayer != null) diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index fd66bcfa2..6e9b7ad21 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -147,22 +147,26 @@ public class User extends DataUnit implements Cloneable { } } - public void addSubGroup(Group subGroup) { + public boolean addSubGroup(Group subGroup) { + // Don't allow adding a subgroup if it's already set as the primary. if (this.group.equalsIgnoreCase(subGroup.getName())) { - return; + return false; } 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; } - subGroup = getDataSource().getGroup(subGroup.getName()); - removeSubGroup(subGroup); - subGroups.add(subGroup.getName()); - flagAsChanged(); - if (GroupManager.isLoaded()) { - if (!GroupManager.BukkitPermissions.isPlayer_join()) - GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); - GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED); - } + //subGroup = getDataSource().getGroup(subGroup.getName()); + //removeSubGroup(subGroup); + //subGroups.add(subGroup.getName()); + return false; } public int subGroupsSize() { |