Skip to content

Feature: Repatable Permissions #451

@TheMeinerLP

Description

@TheMeinerLP

If i have a command thats needs multiple permissions for the same commands.
The the developer needs to add this checks inside of his command methods.
For example like this:

@CommandMethod("/schematic save <filename> [format]")
@CommandPermission("worldedit.schematic.save")
fun saveSchematic(
    player: Player,
    @Argument("filename") filename: String,
    @Argument("format", defaultValue = "fast") format: String,
    @Flag("f") override: Boolean,
    @Flag("f") global: Boolean
) {
    if(player.hasPermission("Permisson.A") || player.hasPermission("Permisson.B")) {
        // Code here
    }
    
}

Now java allows to repeate annotations. As a result we get a cleaner code.
Docs/Ref: https://rolyhewage.medium.com/type-annotations-repeating-annotations-in-java-722073df9f99
Example code:

@CommandMethod("/schematic save <filename> [format]")
@CommandPermission("worldedit.schematic.save")
@CommandPermission("Permisson.A")
@CommandPermission("Permisson.B")
fun saveSchematic(
    player: Player,
    @Argument("filename") filename: String,
    @Argument("format", defaultValue = "fast") format: String,
    @Flag("f") override: Boolean,
    @Flag("f") global: Boolean
) {
    save(player, filename, format, override, global)
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions