-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Code] Ajout d'un préfixe de permission commun (#18)
- Loading branch information
Showing
3 changed files
with
85 additions
and
1 deletion.
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
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
61 changes: 61 additions & 0 deletions
61
src/main/java/fr/communaywen/core/utils/PermissionCategory.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,61 @@ | ||
package fr.communaywen.core.utils; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Permission categories | ||
*/ | ||
public enum PermissionCategory { | ||
|
||
/** | ||
* Administrative permissions (management commands, etc.) | ||
*/ | ||
ADMIN("admin"), | ||
|
||
/** | ||
* Regular commands | ||
*/ | ||
COMMAND("command"), | ||
; | ||
|
||
/** | ||
* Permission prefix. | ||
* <br> | ||
* Permissions in the plugin <b>SHOULD</b> be prefixed with this prefix. E.g. <code>ayw.command.prout</code> | ||
*/ | ||
public static final @NotNull String PERMISSION_PREFIX = "ayw"; | ||
|
||
/** | ||
* Permission postfix. | ||
*/ | ||
private final @NotNull String postfix; | ||
|
||
/** | ||
* Create a new permission category. | ||
* | ||
* @param postfix the permission postfix | ||
*/ | ||
PermissionCategory(final @NotNull String postfix) { | ||
this.postfix = postfix; | ||
} | ||
|
||
/** | ||
* Get the permission postfix. | ||
* | ||
* @return the permission postfix | ||
*/ | ||
public @NotNull String getPostfix() { | ||
return postfix; | ||
} | ||
|
||
/** | ||
* Format a permission with the permission prefix. | ||
* | ||
* @param suffix the permission suffix | ||
* @return the formatted permission | ||
*/ | ||
public @NotNull String formatPermission(final @NotNull String suffix) { | ||
return PERMISSION_PREFIX + "." + postfix + "." + suffix; | ||
} | ||
|
||
} |