コード例 #1
0
ファイル: User.java プロジェクト: PeanutArts/GroupManager
  /** @return User clone */
  @Override
  public User clone() {

    User clone = new User(getDataSource(), this.getName());
    clone.group = this.group;
    for (String perm : this.getPermissionList()) {
      clone.addPermission(perm);
    }
    // clone.variables = this.variables.clone();
    // clone.flagAsChanged();
    return clone;
  }
コード例 #2
0
ファイル: User.java プロジェクト: PeanutArts/GroupManager
  /**
   * Use this to deliver a user from one WorldDataHolder to another
   *
   * @param dataSource
   * @return null if given dataSource already contains the same user
   */
  public User clone(WorldDataHolder dataSource) {

    if (dataSource.isUserDeclared(this.getName())) {
      return null;
    }
    User clone = dataSource.createUser(this.getName());
    if (dataSource.getGroup(group) == null) {
      clone.setGroup(dataSource.getDefaultGroup());
    } else {
      clone.setGroup(dataSource.getGroup(this.getGroupName()));
    }
    for (String perm : this.getPermissionList()) {
      clone.addPermission(perm);
    }
    clone.variables = this.variables.clone(this);
    clone.flagAsChanged();
    return clone;
  }