-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1916076
commit 2ae5d55
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...main/java/snw/kookbc/impl/command/litecommands/annotations/permission/KookPermission.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package snw.kookbc.impl.command.litecommands.annotations.permission; | ||
|
||
import snw.jkook.Permission; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
public @interface KookPermission { | ||
Permission[] value(); | ||
} |
26 changes: 26 additions & 0 deletions
26
...bc/impl/command/litecommands/annotations/permission/KookPermissionAnnotationResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package snw.kookbc.impl.command.litecommands.annotations.permission; | ||
|
||
import dev.rollczi.litecommands.annotations.AnnotationInvoker; | ||
import dev.rollczi.litecommands.annotations.AnnotationProcessor; | ||
import dev.rollczi.litecommands.meta.Meta; | ||
import snw.jkook.permissions.Permissions; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* 2024/10/21<br> | ||
* KookBC<br> | ||
* | ||
* @author huanmeng_qwq | ||
*/ | ||
public class KookPermissionAnnotationResolver<SENDER> implements AnnotationProcessor<SENDER> { | ||
@Override | ||
public AnnotationInvoker<SENDER> process(AnnotationInvoker<SENDER> invoker) { | ||
return invoker.on(KookPermission.class, (annotation, metaHolder) -> { | ||
metaHolder.meta().listEditor(Meta.PERMISSIONS) | ||
.addAll(Arrays.stream(annotation.value()).map(Permissions::getPermission).collect(Collectors.toList())) | ||
.apply(); | ||
}); | ||
} | ||
} |