示例#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());
  }
示例#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);
    }
  }
示例#3
0
  /** @param varList */
  public void setVariables(Map<String, Object> varList) {

    // UserVariables temp = new UserVariables(this, varList);
    variables.clearVars();
    for (String key : varList.keySet()) {
      variables.addVar(key, varList.get(key));
    }
    flagAsChanged();
    if (GroupManager.isLoaded()) {
      // if (!GroupManager.BukkitPermissions.isPlayer_join())
      //	GroupManager.BukkitPermissions.updatePlayer(this.getName());
      GroupManager.getGMEventHandler().callEvent(this, Action.USER_INFO_CHANGED);
    }
  }
示例#4
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;
  }