summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsGroupManager/src/org')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java6
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java26
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() {