Don't give permission to op?

Discussion in 'Plugin Development' started by Meatiex, Feb 23, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Meatiex

  2. Offline

    teej107

    If you don't think an OP should be allowed to do a certain action, then don't OP them.
     
    Last edited: Feb 24, 2015
  3. Offline

    Meatiex

    I'm sorry, I wasn't clear enough. I want to give permission to bypass a chat filter. But I don't want ops to be able to bypass it by default.

    if I didn't want them to use a command I could give them false permissions, but that's not the best way to do it... If i'm giving this plugin to other people they won't like that.
     
    Last edited: Feb 23, 2015
  4. Offline

    Skionz

    @Meatiex Look at the PermissibleBase, and Permission class. Specifically this static field:
    Code:
    public static final PermissionDefault DEFAULT_PERMISSION = PermissionDefault.OP;
    This field is used in the PermissibleBase class specifically the 'hasPermission' method.
    Code:
    public boolean hasPermission(String inName) {
        if (inName == null) {
          throw new IllegalArgumentException("Permission name cannot be null");
        }
    
        String name = inName.toLowerCase();
    
        if (isPermissionSet(name)) {
          return ((PermissionAttachmentInfo)this.permissions.get(name)).getValue();
        }
        Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);
    
        if (perm != null) {
          return perm.getDefault().getValue(isOp());
        }
        return Permission.DEFAULT_PERMISSION.getValue(isOp());
      }
    
      public boolean hasPermission(Permission perm)
      {
        if (perm == null) {
          throw new IllegalArgumentException("Permission cannot be null");
        }
    
        String name = perm.getName().toLowerCase();
    
        if (isPermissionSet(name)) {
          return ((PermissionAttachmentInfo)this.permissions.get(name)).getValue();
        }
        return perm.getDefault().getValue(isOp());
      }
    This should help you find your solution.
     
    tomudding likes this.
  5. Offline

    mythbusterma

    @Meatiex

    In the plugin.yml file, register the permission and set it's default tag to false.
     
    Meatiex likes this.
Thread Status:
Not open for further replies.

Share This Page