Package ru.tehkode.permissions

Examples of ru.tehkode.permissions.PermissionGroup


      permission = "permissions.manage.users.cleanup",
      description = "Clean users of specified group, which last login was before threshold (in days). By default threshold is 30 days.")
  public void usersCleanup(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    long threshold = 2304000;

    PermissionGroup group = plugin.getPermissionsManager().getGroup(args.get("group"));

    if (args.containsKey("threshold")) {
      try {
        threshold = Integer.parseInt(args.get("threshold")) * 86400; // 86400 - seconds in one day
      } catch (NumberFormatException e) {
        sender.sendMessage(ChatColor.RED + "Threshold should be number (in days)");
        return;
      }
    }

    int removed = 0;

    Long deadline = (System.currentTimeMillis() / 1000L) - threshold;
    for (PermissionUser user : group.getUsers()) {
      int lastLogin = user.getOwnOptionInteger("last-login-time", null, 0);

      if (lastLogin > 0 && lastLogin < deadline) {
        user.remove();
        removed++;
View Full Code Here


      syntax = "group <group> weight [weight]",
      permission = "permissions.manage.groups.weight.<group>",
      description = "Display or set group weight")
  public void groupDisplaySetWeight(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 + "\" doesn't exist.");
      return;
    }

    if (args.containsKey("weight")) {
      try {
        group.setWeight(Integer.parseInt(args.get("weight")));
      } catch (NumberFormatException e) {
        sender.sendMessage("Error! Weight should be integer value.");
        return;
      }
    }

    sender.sendMessage("Group \"" + group.getIdentifier() + "\" has " + group.getWeight() + " calories.");
  }
View Full Code Here

      syntax = "group <group> toggle debug",
      permission = "permissions.manage.groups.debug.<group>",
      description = "Toggle debug mode for group")
  public void groupToggleDebug(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 + "\" doesn't exist.");
      return;
    }

    group.setDebug(!group.isDebug());

    sender.sendMessage("Debug mode for group " + group.getIdentifier() + " have been " + (group.isDebug() ? "enabled" : "disabled") + "!");
  }
View Full Code Here

      description = "Get or set <group> prefix.")
  public void groupPrefix(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.containsKey("newprefix")) {
      group.setPrefix(args.get("newprefix"), worldName);
      sender.sendMessage(group.getIdentifier() + "'s prefix" + (worldName != null ? " (in world \"" + worldName + "\") " : "") + " has been set to \"" + group.getPrefix() + "\"");
    } else {
      sender.sendMessage(group.getIdentifier() + "'s prefix" + (worldName != null ? " (in world \"" + worldName + "\") " : "") + " is \"" + group.getPrefix() + "\"");
    }
  }
View Full Code Here

      description = "Get or set <group> suffix")
  public void groupSuffix(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.containsKey("newsuffix")) {
      group.setSuffix(args.get("newsuffix"), worldName);
      sender.sendMessage(group.getIdentifier() + "'s suffix" + (worldName != null ? " (in world \"" + worldName + "\") " : "") + " has been set to \"" + group.getSuffix() + "\"");
    } else {
      sender.sendMessage(group.getIdentifier() + "'s suffix" + (worldName != null ? " (in world \"" + worldName + "\") " : "") + " is \"" + group.getSuffix() + "\"");
    }
  }
View Full Code Here

      syntax = "group <group> create [parents]",
      permission = "permissions.manage.groups.create.<group>",
      description = "Create <group> and/or set [parents]")
  public void groupCreate(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 + "\" doesn't exist.");
      return;
    }

    if (!group.isVirtual()) {
      sender.sendMessage(ChatColor.RED + "Group \"" + args.get("group") + "\" already exists.");
      return;
    }

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

      for (String parent : parents) {
        groups.add(plugin.getPermissionsManager().getGroup(parent));
      }

      group.setParents(groups, null);
    }

    sender.sendMessage(ChatColor.WHITE + "Group \"" + group.getIdentifier() + "\" created!");

    group.save();
  }
View Full Code Here

      permission = "permissions.manage.groups.remove.<group>",
      description = "Remove <group>")
  public void groupDelete(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 + "\" doesn't exist.");
      return;
    }

    sender.sendMessage(ChatColor.WHITE + "Group \"" + group.getIdentifier() + "\" removed!");

    group.remove();
    plugin.getPermissionsManager().resetGroup(group.getIdentifier());
  }
View Full Code Here

      description = "List parents for <group>")
  public void groupListParents(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> parentNames = group.getParentIdentifiers(worldName);
    if (parentNames.isEmpty()) {
      sender.sendMessage(ChatColor.RED + "Group \"" + group.getIdentifier() + "\" has no parents.");
      return;
    }

    sender.sendMessage("Group " + group.getIdentifier() + " parents:");

    for (String parent : parentNames) {
      sender.sendMessage("  " + parent);
    }
View Full Code Here

      description = "Set parent(s) for <group> (single or comma-separated list)")
  public void groupSetParents(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<>();

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

        if (parentGroup != null && !groups.contains(parentGroup)) {
          groups.add(parentGroup);
        }
      }
View Full Code Here

      description = "Set parent(s) for <group> (single or comma-separated list)")
  public void groupAddParents(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));

        if (parentGroup != null && !groups.contains(parentGroup)) {
          groups.add(parentGroup);
        }
      }
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.