@Override
  public void addGroup(OfflinePlayer player, String group) {
    Group groupObj = groupManager.getWorldsHolder().getDefaultWorld().getGroup(group);
    if (groupObj == null) return;

    groupManager.getWorldsHolder().getDefaultWorld().getUser(player.getName()).setGroup(groupObj);
  }
  @Override
  public void removeSubgroup(OfflinePlayer player, String subgroup) {
    Group subgroupObj = groupManager.getWorldsHolder().getDefaultWorld().getGroup(subgroup);
    if (subgroupObj == null) return;

    groupManager
        .getWorldsHolder()
        .getDefaultWorld()
        .getUser(player.getName())
        .removeSubGroup(subgroupObj);
  }
 private boolean hasPermissionGroupManager(final Player base, final String node) {
   final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
   if (handler == null) {
     return false;
   }
   return handler.has(base, node);
 }
 @Override
 public void removePermission(OfflinePlayer player, String permission) {
   groupManager
       .getWorldsHolder()
       .getDefaultWorld()
       .getUser(player.getName())
       .removePermission(permission);
 }
  @Override
  public String getGroupOfPlayer(OfflinePlayer player) {
    if (!isActive()) return "";

    Group group = groupManager.getWorldsHolder().getDefaultWorld().getDefaultGroup();
    if (group == null) return "";

    return group.getName();
  }
  @Override
  public List<String> listSubgroups(OfflinePlayer player) {
    List<String> ret = new LinkedList<String>();
    for (Group group : groupManager.getWorldsHolder().getDefaultWorld().getGroupList()) {
      ret.add(group.getName());
    }

    return ret;
  }
  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];
    }
  }
  @Override
  public ArrayList<String> getGroups() {
    ArrayList<String> groups = new ArrayList<String>();
    if (!isActive()) return groups;

    Collection<Group> groupList = groupManager.getWorldsHolder().getDefaultWorld().getGroupList();

    for (Group group : groupList) {
      groups.add(group.getName());
    }

    return groups;
  }
  public static boolean hasPermission(Player p, String type, String node1, String node2) {
    try {
      String n1 = node1 != "" ? "." + node1 : "";
      String n2 = node2 != "" ? "." + node2 : "";
      String perm = "tekkitrestrict." + type + n1 + n2;

      PluginManager pm = Bukkit.getPluginManager();
      if (pm.isPluginEnabled("Vault")) {
        if (v == null)
          v =
              Bukkit.getServer()
                  .getServicesManager()
                  .getRegistration(net.milkbowl.vault.permission.Permission.class);
        if (v != null) {
          net.milkbowl.vault.permission.Permission permission = v.getProvider();
          return permission.has(p, perm);
        }
      } else if (pm.isPluginEnabled("PermissionsEx") && isForceThis(0)) {
        return ((PermissionManager) tekkitrestrict.perm).getUser(p).has(perm);
      } else if (pm.isPluginEnabled("bPermissions") && isForceThis(2)) {
        return ApiLayer.hasPermission(
            p.getWorld().getName(), CalculableType.USER, p.getName(), perm);
      } else if (pm.isPluginEnabled("GroupManager") && isForceThis(3)) {
        GroupManager ps = (GroupManager) pm.getPlugin("GroupManager");
        return ps.getWorldsHolder()
            .getWorldData(p)
            .getUser(p.getName())
            .hasSamePermissionNode(perm);
      } else {
        return p.hasPermission(perm);
      }
    } catch (Exception e) {
      TRLogger.Log(
          "debug",
          (new StringBuilder("Error: [PermHandle_hasPermission] "))
              .append(e.getMessage())
              .toString());
    }
    return false;
  }