Package ru.tehkode.permissions

Examples of ru.tehkode.permissions.PermissionManager


public class PermissionsExResolver extends DinnerPermsResolver {
    private final PermissionManager manager;

    public static PermissionsResolver factory(Server server, YAMLProcessor config) {
        try {
            PermissionManager manager = server.getServicesManager().load(PermissionManager.class);

            if (manager == null) {
                return null;
            }
View Full Code Here


    public void setParams(Map<String, String> params) {
      this.params = params;
    }

    public boolean checkPermissions(Player player) {
      PermissionManager manager = PermissionsEx.getPermissionManager();

      String permission = this.getMethodAnnotation().permission();


      if (permission.contains("<")) {
        for (Entry<String, String> entry : this.getParams().entrySet()) {
          if (entry.getValue() != null) {
            permission = permission.replace("<" + entry.getKey() + ">", entry.getValue().toLowerCase());
          }
        }
      }

      return manager.has(player, permission);

    }
View Full Code Here

      syntax = "world <world> inherit <parentWorlds>",
      description = "Set <parentWorlds> for <world>",
      permission = "permissions.manage.worlds.inheritance")
  public void worldSetInheritance(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String worldName = this.autoCompleteWorldName(args.get("world"));
    PermissionManager manager = plugin.getPermissionsManager();
    if (plugin.getServer().getWorld(worldName) == null) {
      sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
      return;
    }

    List<String> parents = new ArrayList<>();
    String parentWorlds = args.get("parentWorlds");
    if (parentWorlds.contains(",")) {
      for (String world : parentWorlds.split(",")) {
        world = this.autoCompleteWorldName(world, "parentWorlds");
        if (!parents.contains(world)) {
          parents.add(world.trim());
        }
      }
    } else {
      parents.add(parentWorlds.trim());
    }

    manager.setWorldInheritance(worldName, parents);

    sender.sendMessage("World \"" + worldName + "\" inherits " + StringUtils.implode(parents, ", "));
  }
View Full Code Here

      syntax = "import <backend>",
      permission = "permissions.dump",
      description = "Import data from <backend> as specified in the configuration")
  public void dumpData(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    try {
      PermissionManager mgr = plugin.getPermissionsManager();
      PermissionBackend backend = mgr.createBackend(args.get("backend"));
      mgr.getBackend().loadFrom(backend);

      sender.sendMessage(ChatColor.WHITE + "[PermissionsEx] Data from \"" + args.get("backend") + "\" loaded into currently active backend");
    } catch (RuntimeException e) {
      if (e.getCause() instanceof ClassNotFoundException) {
        sender.sendMessage(ChatColor.RED + "Specified backend not found!");
View Full Code Here

  @Command(name = "pex",
      syntax = "toggle debug",
      permission = "permissions.debug",
      description = "Enable/disable debug mode")
  public void toggleFeature(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    PermissionManager manager = plugin.getPermissionsManager();

    manager.setDebug(!manager.isDebug());
    String debugStatusMessage = "Debug mode " + (manager.isDebug() ? "enabled" : "disabled");
    if (sender instanceof Player) {
      sender.sendMessage(debugStatusMessage);
    }
    plugin.getLogger().warning(debugStatusMessage);
  }
View Full Code Here

      description = "Set <group> for <user>")
  public void userSetGroup(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    String userName = this.autoCompletePlayerName(args.get("user"));
    String worldName = this.autoCompleteWorldName(args.get("world"));

    PermissionManager manager = plugin.getPermissionsManager();
    PermissionUser user = manager.getUser(userName);

    if (user == null) {
      sender.sendMessage(ChatColor.RED + "User \"" + userName + "\" doesn't exist.");
      return;
    }

    String groupName = args.get("group");

    List<PermissionGroup> groups;

    if (groupName.contains(",")) {
      String[] groupsNames = groupName.split(",");
      groups = new ArrayList<>(groupsNames.length);

      for (String addName : groupsNames) {
        if (sender instanceof Player && !manager.has((Player) sender, "permissions.manage.membership." + addName.toLowerCase())) {
          sender.sendMessage(ChatColor.RED + "Don't have enough permission for group " + addName);
          return;
        }

        groups.add(manager.getGroup(this.autoCompleteGroupName(addName)));
      }

    } else {
      groupName = this.autoCompleteGroupName(groupName);

      if (groupName != null) {
        groups = Collections.singletonList(manager.getGroup(groupName));

        if (sender instanceof Player && !manager.has((Player) sender, "permissions.manage.membership." + groupName.toLowerCase())) {
          sender.sendMessage(ChatColor.RED + "Don't have enough permission for group " + groupName);
          return;
        }

      } else {
View Full Code Here

    subscriptionHandler.uninject();
    uninjectAllPermissibles();
  }

  public boolean hasDebugMode() {
    PermissionManager manager = plugin.getPermissionsManager();
    return manager != null && manager.isDebug();
  }
View Full Code Here

    builder.addHeading("PEX configuration")
        .addCode(configuration, "yaml");

    // Permissions database
    if (pexPlugin != null) {
      PermissionManager manager = pexPlugin.getPermissionsManager();
      if (manager != null) {
        PermissionBackend backend = manager.getBackend();
        try {
          if (backend != null) {
            final StringWriter writer = new StringWriter();
            backend.writeContents(writer);
            permissionsDb = writer.toString();
View Full Code Here

      this.getPluginLoader().disablePlugin(this);
      return;
    }
    try {
      if (this.permissionsManager == null) {
        this.permissionsManager = new PermissionManager(config, getLogger(), this);
      }

      try {
        OfflinePlayer.class.getMethod("getUniqueId");
      } catch (NoSuchMethodException e) {
View Full Code Here

      isPrimary = true,
      permission = "permissions.manage.worlds")
  public void worldsTree(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
    List<World> worlds = plugin.getServer().getWorlds();

    PermissionManager manager = plugin.getPermissionsManager();

    sender.sendMessage("Worlds on server: ");
    for (World world : worlds) {
      List<String> parentWorlds = manager.getWorldInheritance(world.getName());
      String output = "  " + world.getName();
      if (!parentWorlds.isEmpty()) {
        output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
      }
View Full Code Here

TOP

Related Classes of ru.tehkode.permissions.PermissionManager

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.