예제 #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
  @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);
  }
예제 #3
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);
    }
  }
예제 #4
0
  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];
    }
  }
예제 #5
0
  @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);
  }
예제 #6
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);
    }
  }
예제 #7
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;
  }
예제 #8
0
 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);
 }
예제 #9
0
 @Override
 public void removePermission(OfflinePlayer player, String permission) {
   groupManager
       .getWorldsHolder()
       .getDefaultWorld()
       .getUser(player.getName())
       .removePermission(permission);
 }
예제 #10
0
  @Override
  public String getGroupOfPlayer(OfflinePlayer player) {
    if (!isActive()) return "";

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

    return group.getName();
  }
예제 #11
0
  @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;
  }
예제 #12
0
  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;
  }
예제 #13
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;
  }