Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Improvements to @Permission annotation #7

Closed
Andre601 opened this issue Mar 30, 2020 · 1 comment
Closed

[Suggestion] Improvements to @Permission annotation #7

Andre601 opened this issue Mar 30, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Andre601
Copy link

Andre601 commented Mar 30, 2020

I would like to propose some changes to the @Permission annotation, to make its use a bit more unique and helpful.

Make it usable on classes

It would be a good addition to make the annotation usable on classes.
What this would do is essentially making the set permission(s) the parent of any other that get defined for sub commands.

Add option to make permission default

I'm not sure how the framework adds/registers the permissions, but I assume they're loaded with default being set to op or false?

My second suggestion is to have an option to make the permission be set with default as true (Granted to everyone).
It could perhaps be done like the #range option for the @Completion annotation, where you prefix the permission with #default: and it would be assigned as default.

Example

Imagine the above suggestions would've been implemented already, then a command class could look like this:

@Command("mycommand")
@Permission("myplugin.mycommand")
public class MyCmdClass extends CommandBase{

    @Default
    @SubCommand("help")
    @Permission("#default:myplugin.command.help")
    public void sendHelp(final CommandSender sender){
        // Do something here
    }

    @SubCommand("stuff")
    @Permission("myplugin.command.stuff")
    public void doStuff(final CommandSender sender){
        // Do something here
    }
}

The above example would be the equivalent of the following setting of the plugin.yml

permissions:
  myplugin.mycommand:
    default: op
    children:
      myplugin.command.help: true
      myplugin.command.stuff: true
  myplugin.command.help:
    default: true
  myplugin.command.stuff:
    default: op
@LichtHund LichtHund added the enhancement New feature or request label Apr 5, 2020
@LichtHund
Copy link
Member

LichtHund commented Feb 2, 2023

Very old and you probably don't use this anymore, but added in #84 for version 2.0.0.
Slightly different implementation but does the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants