Package ru.tehkode.permissions

Examples of ru.tehkode.permissions.PermissionGroup


      description = "Set parent(s) for <group> (single or comma-separated list)")
  public void groupRemoveParents(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }

    if (args.get("parents") != null) {
      String[] parents = args.get("parents").split(",");
      List<PermissionGroup> groups = new LinkedList<>(group.getOwnParents(worldName));

      for (String parent : parents) {
        PermissionGroup parentGroup = plugin.getPermissionsManager().getGroup(this.autoCompleteGroupName(parent));

        groups.remove(parentGroup);
      }

      group.setParents(groups, worldName);
View Full Code Here


      description = "List all <group> permissions in [world]")
  public void groupListPermissions(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }

    sender.sendMessage("'" + groupName + "' inherits the following groups:");
    printEntityInheritance(sender, group.getParents());

    Map<String, List<PermissionGroup>> parents = group.getAllParents();
    for (String world : parents.keySet()) {
      if (world == null) {
        continue;
      }

      sender.sendMessage("  @" + world + ":");
      printEntityInheritance(sender, parents.get(world));
    }

    sender.sendMessage("Group \"" + group.getIdentifier() + "\"'s permissions:");
    this.sendMessage(sender, this.mapPermissions(worldName, group, 0));

    sender.sendMessage("Group \"" + group.getIdentifier() + "\"'s Options: ");
    for (Map.Entry<String, String> option : group.getOptions(worldName).entrySet()) {
      sender.sendMessage("  " + option.getKey() + " = \"" + option.getValue() + "\"");
    }
  }
View Full Code Here

      description = "Add <permission> to <group> in [world]")
  public void groupAddPermission(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }

    group.addPermission(args.get("permission"), worldName);

    sender.sendMessage(ChatColor.WHITE + "Permission \"" + args.get("permission") + "\" added to group \"" + group.getIdentifier() + "\"!");

    this.informGroup(plugin, group, "Your permissions have been changed");
  }
View Full Code Here

      description = "Set <option> <value> for <group> in [world]")
  public void groupSetOption(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }

    group.setOption(args.get("option"), args.get("value"), worldName);

    if (args.containsKey("value") && args.get("value").isEmpty()) {
      sender.sendMessage(ChatColor.WHITE + "Option \"" + args.get("option") + "\" cleared!");
    } else {
      sender.sendMessage(ChatColor.WHITE + "Option \"" + args.get("option") + "\" set!");
View Full Code Here

      description = "Remove <permission> from <group> in [world]")
  public void groupRemovePermission(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }

    String permission = this.autoCompletePermission(group, args.get("permission"), worldName);

    group.removePermission(permission, worldName);
    group.removeTimedPermission(permission, worldName);

    sender.sendMessage(ChatColor.WHITE + "Permission \"" + permission + "\" removed from group \"" + group.getIdentifier() + "\"!");

    this.informGroup(plugin, group, "Your permissions have been changed");
  }
View Full Code Here

      description = "Swap <permission> and <targetPermission> in permission list. Could be number or permission itself")
  public void userSwapPermission(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }


    List<String> permissions = group.getOwnPermissions(worldName);

    try {
      int sourceIndex = this.getPosition(this.autoCompletePermission(group, args.get("permission"), worldName, "permission"), permissions);
      int targetIndex = this.getPosition(this.autoCompletePermission(group, args.get("targetPermission"), worldName, "targetPermission"), permissions);

      String targetPermission = permissions.get(targetIndex);

      permissions.set(targetIndex, permissions.get(sourceIndex));
      permissions.set(sourceIndex, targetPermission);

      group.setPermissions(permissions, worldName);

      sender.sendMessage("Permissions swapped!");
    } catch (Throwable e) {
      sender.sendMessage(ChatColor.RED + "Error: " + e.getMessage());
    }
View Full Code Here

    if (args.containsKey("lifetime")) {
      lifetime = DateUtils.parseInterval(args.get("lifetime"));
    }

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }

    group.addTimedPermission(args.get("permission"), worldName, lifetime);

    sender.sendMessage(ChatColor.WHITE + "Timed permission added!");
    this.informGroup(plugin, group, "Your permissions have been changed!");

    plugin.getLogger().info("Group " + groupName + " get timed permission \"" + args.get("permission") + "\" "
View Full Code Here

      description = "Remove timed <permissions> for <group> in [world]")
  public void groupRemoveTimedPermission(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }

    group.removeTimedPermission(args.get("permission"), worldName);

    sender.sendMessage(ChatColor.WHITE + "Timed permission \"" + args.get("permission") + "\" removed!");
    this.informGroup(plugin, group, "Your permissions have been changed!");
  }
View Full Code Here

  public void groupDefaultSet(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));
    boolean def = Boolean.parseBoolean(args.get("value"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null || group.isVirtual()) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
      return;
    }

    group.setDefault(def, worldName);
    sender.sendMessage("Group \"" + groupName + "\" is " + (def ? "now" : "no longer") + " default in world \"" + worldName + "\"");
  }
View Full Code Here

      isPrimary = true,
      permission = "permissions.groups.rank.<group>")
  public void rankGroup(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String groupName = this.autoCompleteGroupName(args.get("group"));

    PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);

    if (group == null) {
      sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" not found");
      return;
    }

    if (args.get("rank") != null) {
      String newRank = args.get("rank").trim();

      try {
        group.setRank(Integer.parseInt(newRank));
      } catch (NumberFormatException e) {
        sender.sendMessage("Wrong rank. Make sure it's number.");
      }

      if (args.containsKey("ladder")) {
        group.setRankLadder(args.get("ladder"));
      }
    }

    int rank = group.getRank();

    if (rank > 0) {
      sender.sendMessage("Group " + group.getIdentifier() + " rank is " + rank + " (ladder = " + group.getRankLadder() + ")");
    } else {
      sender.sendMessage("Group " + group.getIdentifier() + " is unranked");
    }
  }
View Full Code Here

TOP

Related Classes of ru.tehkode.permissions.PermissionGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.