예제 #1
0
  @Override
  public boolean playerInGroup(String world, String player, String group) {
    OfflinePlayer op = Bukkit.getOfflinePlayer(player);
    GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
    User user = set.getUser(op);

    if (set.hasGroup(group)) {
      Group g = set.getGroup(group);
      return user.hasChild(g, true);
    } else {
      return false;
    }
  }
예제 #2
0
  @Override
  public String getPrimaryGroup(String world, String player) {
    OfflinePlayer op = Bukkit.getOfflinePlayer(player);
    GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
    User user = set.getUser(op);

    Set<Group> children = user.getChildren(false);
    if (!children.isEmpty()) {
      return children.iterator().next().getName();
    } else {
      return null;
    }
  }
예제 #3
0
  @Override
  public String[] getPlayerGroups(String world, String player) {
    OfflinePlayer op = Bukkit.getOfflinePlayer(player);
    GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
    User user = set.getUser(op);

    Set<Group> children = user.getChildren(true);
    List<String> groups = new ArrayList<String>();
    for (Group child : children) {
      groups.add(child.getName());
    }
    return groups.toArray(new String[groups.size()]);
  }
예제 #4
0
  @Override
  public boolean playerAdd(String world, String player, String permission) {
    OfflinePlayer op = Bukkit.getOfflinePlayer(player);
    GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
    User user = set.getUser(op);

    boolean value = !permission.startsWith("^");
    permission = value ? permission : permission.substring(1);
    user.addPermission(permission, value, true, true);

    if (user.isActive()) {
      user.applyPermissions(perms.getGroupManager().getFactory());
    }
    return true;
  }
예제 #5
0
  @Override
  public boolean groupAdd(String world, String group, String permission) {
    GroupManager gm = perms.getGroupManager();
    GroupSet set = gm.getWorldSet(Bukkit.getWorld(world));
    if (set.hasGroup(group)) {
      Group g = set.getGroup(group);

      boolean value = !permission.startsWith("^");
      permission = value ? permission : permission.substring(1);
      g.addPermission(permission, value, true, true);

      for (User user : gm.getAffectedUsers(g)) {
        user.applyPermissions(gm.getFactory());
      }
      return true;
    } else {
      return false;
    }
  }
예제 #6
0
  @Override
  public boolean playerRemoveGroup(String world, String player, String group) {
    OfflinePlayer op = Bukkit.getOfflinePlayer(player);
    GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
    User user = set.getUser(op);

    if (set.hasGroup(group)) {
      Group g = set.getGroup(group);
      if (user.hasChild(g, false)) {
        user.removeChild(g, true);

        if (user.isActive()) {
          user.applyPermissions(perms.getGroupManager().getFactory());
        }
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }