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/src/org | |
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/src/org')
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java | 6 | ||||
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java | 26 |
2 files changed, 19 insertions, 13 deletions
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() { |