Exemple #1
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);
    }
  }