Package org.bukkit.permissions

Examples of org.bukkit.permissions.Permission


    }

    private Permission registerPermission(String permString, PermissionDefault value) {
        PluginManager pm = plugin.getServer().getPluginManager();

        Permission perm = pm.getPermission(permString);
        if (perm == null) {
            perm = new Permission(permString);
            perm.setDefault(value);
            pm.addPermission(perm);
        }
        return perm;
    }
View Full Code Here


                        return true;

                    return false;
                } else {
                    try {
                        Permission perm = new Permission(node);
                        if(player.hasPermission(perm) || player.hasPermission(node) || player.hasPermission(node.toLowerCase()))
                            return true;

                        return false;
                    } catch(Exception e) {
View Full Code Here

     */
    public int internalHasPermission(Permissible perms, String permission) {
        if (perms.isPermissionSet(permission)) {
            return perms.hasPermission(permission) ? 1 : -1;
        } else {
            Permission perm = server.getPluginManager().getPermission(permission);
            if (perm != null) {
                return perm.getDefault().getValue(perms.isOp()) ? 1 : 0;
            } else {
                return 0;
            }
        }
    }
View Full Code Here

    final Set<String> checked = new HashSet<String>();
    for (String label : ignoredCommands) {
      checked.add(CommandUtil.getCommandLabel(label, false));
    }
    final PluginManager pm = Bukkit.getPluginManager();
    Permission rootPerm = pm.getPermission(permissionBase);
    if (rootPerm == null) {
      rootPerm = new Permission(permissionBase);
      pm.addPermission(rootPerm);
    }
    final List<CommandProtectionEntry> changed = new LinkedList<CommandProtectionEntry>();
    // Apply protection based on white-list or black-list.
    for (final Command command : CommandUtil.getCommands()) {
      final String lcLabel = command.getLabel().trim().toLowerCase();
      if (checked.contains(lcLabel) || containsAnyAliases(checked, command)) {
        if (!invertIgnored) {
          continue;
        }
      }
      else if (invertIgnored) {
        continue;
      }
      // Set the permission for the command.
      String cmdPermName = command.getPermission();
      boolean cmdHadPerm;
      if (cmdPermName == null) {
        // Set a permission.
        cmdPermName = permissionBase + "." + lcLabel;
        command.setPermission(cmdPermName);
        cmdHadPerm = false;
      }
      else{
        cmdHadPerm = true;
      }
      // Set permission default behavior.
      Permission cmdPerm = pm.getPermission(cmdPermName);
      if (cmdPerm == null) {
        if (!cmdHadPerm) {
          cmdPerm = new Permission(cmdPermName);
          cmdPerm.addParent(rootPerm, true);
          pm.addPermission(cmdPerm);
        }
      }
      // Create change history entry.
      if (cmdHadPerm) {
          if (cmdPerm == null) {
              changed.add(new CommandProtectionEntry(command, lcLabel, cmdPermName, null, command.getPermissionMessage()));
          }
          else {
              changed.add(new CommandProtectionEntry(command, lcLabel, cmdPermName, cmdPerm.getDefault(), command.getPermissionMessage()));
          }
      }
      else {
        changed.add(new CommandProtectionEntry(command, lcLabel, null, null, command.getPermissionMessage()));
      }
      // Change
      cmdPerm.setDefault(ops ? PermissionDefault.OP : PermissionDefault.FALSE);
      command.setPermissionMessage(permissionMessage);
    }
    return changed;
  }
View Full Code Here

   * @param permissions Not expected to exist.
   * @param childPermissionName
   */
  public static void addChildPermission(final Collection<String> permissions, final String childPermissionName, final PermissionDefault permissionDefault) {
    final PluginManager pm = Bukkit.getPluginManager();
    Permission childPermission = pm.getPermission(childPermissionName);
    if (childPermission == null) {
      childPermission = new Permission(childPermissionName, "auto-generated child permission (NoCheatPlus)", permissionDefault);
      pm.addPermission(childPermission);
    }
    for (final String permissionName : permissions) {
      Permission permission = pm.getPermission(permissionName);
      if (permission == null) {
        permission = new Permission(permissionName, "auto-generated permission (NoCheatPlus)", permissionDefault);
        pm.addPermission(permission);
      }
      if (!permission.getChildren().containsKey(childPermissionName)) {
        childPermission.addParent(permission, true);
      }
    }
  }
View Full Code Here

      if (!label.equalsIgnoreCase(command.getLabel().trim().toLowerCase())) {
        command.setLabel(label);
      }
      command.setPermission(permission);
      if (permission != null && permissionDefault != null) {
        Permission perm = Bukkit.getPluginManager().getPermission(permission);
        if (perm != null && perm.getDefault() != permissionDefault) {
          perm.setDefault(permissionDefault);
        }
      }
      command.setPermissionMessage(permissionMessage);
    }
View Full Code Here

          if (isDebug()) {
            plugin.getLogger().info("User " + player.getName() + " checked for permission '" + permission + "', superperms-matched a value of " + ret);
          }
          return ret;
        } else {
          Permission perm = player.getServer().getPluginManager().getPermission(permission);
          return perm == null ? Permission.DEFAULT_PERMISSION.getValue(player.isOp()) : perm.getDefault().getValue(player.isOp());
        }
    }
  }
View Full Code Here

    return super.put(k, v);
  }

  @Override
  public Permission remove(Object k) {
    Permission ret = super.remove(k);
    if (ret != null) {
      removeAllChildren(k.toString());
      getFieldReplacer(ret).set(ret, new LinkedHashMap<>(ret.getChildren()));
    }
    return ret;
  }
View Full Code Here

    updateAttachment(player, player.getWorld().getName());
  }

  protected void updateAttachment(Player player, String worldName) {
    PermissionAttachment attach = attachments.get(player.getUniqueId());
    Permission playerPerm = getCreateWrapper(player, "");
    Permission playerOptionPerm = getCreateWrapper(player, ".options");
    if (attach == null) {
      attach = player.addAttachment(plugin);
      attachments.put(player.getUniqueId(), attach);
      attach.setPermission(playerPerm, true);
      attach.setPermission(playerOptionPerm, true);
View Full Code Here

    plugin.getServer().getPluginManager().removePermission(permissionName(player, suffix));
  }

  private Permission getCreateWrapper(Player player, String suffix) {
    final String name = permissionName(player, suffix);
    Permission perm = plugin.getServer().getPluginManager().getPermission(name);
    if (perm == null) {
      perm = new Permission(name, "Internal permission for PEX. DO NOT SET DIRECTLY", PermissionDefault.FALSE) {
        @Override
        public void recalculatePermissibles() {
          // no-op
        }
      };
View Full Code Here

TOP

Related Classes of org.bukkit.permissions.Permission

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.