diff options
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() { |