private static String[] getPermissions(Player p, String s) {
    PluginManager pm = Bukkit.getPluginManager();
    if (pm.isPluginEnabled("PermissionsEx") && isForceThis(0)) {
      return getAllPEXPlayerPerms(p, s);
    }
    if (pm.isPluginEnabled("PermissionsBukkit") && isForceThis(1)) {
      return new String[0];
    }
    if (pm.isPluginEnabled("bPermissions") && isForceThis(2)) {
      Permission ps[] =
          ApiLayer.getPermissions(p.getWorld().getName(), CalculableType.USER, p.getName());
      List<String> sr = new LinkedList<String>();
      Permission apermission[];
      int k = (apermission = ps).length;
      for (int j = 0; j < k; j++) {
        Permission px = apermission[j];
        sr.add(px.nameLowerCase());
      }

      for (int i = 0; i < sr.size(); i++) {
        if (!sr.get(i).startsWith(s)) {
          sr.remove(i);
          i--;
        }
      }

      String lz[] = sr.toArray(new String[0]);
      sr.clear();
      return lz;
    }
    if (pm.isPluginEnabled("GroupManager") && isForceThis(3)) {
      GroupManager ps = (GroupManager) pm.getPlugin("GroupManager");
      List<String> sr = new LinkedList<String>();
      User user = ps.getWorldsHolder().getWorldData(p).getUser(p.getName());
      sr.addAll(user.getPermissionList());
      sr.addAll(user.getGroup().getPermissionList());
      String a;
      for (Iterator<String> iterator = user.getGroup().getInherits().iterator();
          iterator.hasNext();
          sr.add(a)) {
        a = iterator.next();
      }

      for (int i = 0; i < sr.size(); i++) {
        if (!sr.get(i).startsWith(s)) {
          sr.remove(i);
          i--;
        }
      }

      String lz[] = sr.toArray(new String[0]);
      sr.clear();
      return lz;
    } else {
      return new String[0];
    }
  }
示例#2
0
  /** @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;
  }
示例#3
0
  /**
   * 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;
  }