Ejemplo n.º 1
0
  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 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);
    }

    subGroups.add(subGroup.getName());
    flagAsChanged();
    if (GroupManager.isLoaded()) {
      if (!GroupManager.BukkitPermissions.isPlayer_join())
        GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
      GroupManager.getGMEventHandler().callEvent(this, Action.USER_SUBGROUP_CHANGED);
    }
    return true;

    // subGroup = getDataSource().getGroup(subGroup.getName());
    // removeSubGroup(subGroup);
    // subGroups.add(subGroup.getName());
  }
Ejemplo n.º 2
0
  /**
   * @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);
    }
    group = getDataSource().getGroup(group.getName());
    String oldGroup = this.group;
    this.group = group.getName();
    flagAsChanged();
    if (GroupManager.isLoaded()) {
      if (!GroupManager.BukkitPermissions.isPlayer_join() && (updatePerms))
        GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());

      // Do we notify of the group change?
      String defaultGroupName = getDataSource().getDefaultGroup().getName();
      // if we were not in the default group
      // or we were in the default group and the move is to a different
      // group.
      boolean notify =
          (!oldGroup.equalsIgnoreCase(defaultGroupName))
              || ((oldGroup.equalsIgnoreCase(defaultGroupName))
                  && (!this.group.equalsIgnoreCase(defaultGroupName)));

      if (notify)
        GroupManager.notify(
            this.getName(), String.format(" moved to the group %s.", group.getName()));

      GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED);
    }
  }
Ejemplo n.º 3
0
  public boolean removeSubGroup(Group subGroup) {

    try {
      if (subGroups.remove(subGroup.getName())) {
        flagAsChanged();
        if (GroupManager.isLoaded())
          if (!GroupManager.BukkitPermissions.isPlayer_join())
            GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
        GroupManager.getGMEventHandler().callEvent(this, Action.USER_SUBGROUP_CHANGED);
        return true;
      }
    } catch (Exception e) {
    }
    return false;
  }