Package com.github.mafelp.utils
Class CheckPermission
java.lang.Object
com.github.mafelp.utils.CheckPermission
Class used to check permissions on Discord or on the Minecraft server
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckPermission(Permissions permission, long id)Checks the configuration if the user id is in the configuration path.static booleancheckPermission(Permissions permission, org.bukkit.command.CommandSender commandSender)Checks the configuration if a command executor has a specific permission or has a specific level.static booleancheckPermission(Permissions permission, org.bukkit.entity.Player player)Checks the configuration if a player has a specific permission or has a specific level.static booleancheckPermission(Permissions permission, org.javacord.api.entity.message.MessageAuthor messageAuthor)Checks the configuration if a command executor has a specific permission or has a specific level.static shortgetAdminLevel(org.bukkit.entity.Player player)Gets the admin Level of a player/uuid from the ops.json file in the root directory of the minecraft server.static org.javacord.api.entity.message.embed.EmbedBuildergetPermissionDeniedEmbed(org.javacord.api.entity.user.User messageAuthor, String action)Gets the embed to server to the user, when he/she does not have the required permissions for something.static booleanhasAdminLevel(org.bukkit.entity.Player player, int level)Checks if a player has a specific admin level.static booleanhasAdminPermission(org.javacord.api.entity.message.MessageAuthor messageAuthor)Checks if a user is a server admin or in thepermission.adminIDslist in theconfig.ymlfile.static booleanhasAdminPermission(org.javacord.api.entity.user.User user, org.javacord.api.entity.server.Server server)Checks if a user is a server admin or in thepermission.adminIDslist in theconfig.ymlfile.static booleanisBotAdmin(org.javacord.api.entity.message.MessageAuthor messageAuthor)Checks if a user a server admin or in thepermissions.botAdminIDslist in theconfig.ymlfile.
-
Constructor Details
-
CheckPermission
public CheckPermission()
-
-
Method Details
-
getPermissionDeniedEmbed
public static org.javacord.api.entity.message.embed.EmbedBuilder getPermissionDeniedEmbed(org.javacord.api.entity.user.User messageAuthor, String action)Gets the embed to server to the user, when he/she does not have the required permissions for something.- Parameters:
messageAuthor- The person who sent the message and should be shown in the header.action- The action the person tried to do. Will be inserted into embed.- Returns:
- an embed to sent to the person.
-
hasAdminPermission
public static boolean hasAdminPermission(org.javacord.api.entity.message.MessageAuthor messageAuthor)Checks if a user is a server admin or in thepermission.adminIDslist in theconfig.ymlfile.- Parameters:
messageAuthor- The user to check the permissions from.- Returns:
- if the person is authorized to do so.
-
hasAdminPermission
public static boolean hasAdminPermission(org.javacord.api.entity.user.User user, org.javacord.api.entity.server.Server server)Checks if a user is a server admin or in thepermission.adminIDslist in theconfig.ymlfile.- Parameters:
user- The user to check the permissions from.server- The server to check the if the user has admin permission on.- Returns:
- if the person is authorized to do so.
-
isBotAdmin
public static boolean isBotAdmin(org.javacord.api.entity.message.MessageAuthor messageAuthor)Checks if a user a server admin or in thepermissions.botAdminIDslist in theconfig.ymlfile.- Parameters:
messageAuthor- the user to check the permission from- Returns:
- if the user is authorized to do so.
-
getAdminLevel
public static short getAdminLevel(org.bukkit.entity.Player player)Gets the admin Level of a player/uuid from the ops.json file in the root directory of the minecraft server.- Parameters:
player- The player to check the level of.- Returns:
- the OP level of the player. If non could be found, return a zero.
-
hasAdminLevel
public static boolean hasAdminLevel(org.bukkit.entity.Player player, int level)Checks if a player has a specific admin level.- Parameters:
player- the player to check the level of.level- the minimum level required for the player to have for this equation to be true.- Returns:
- if the player has the required level.
-
checkPermission
Checks the configuration if the user id is in the configuration path.- Parameters:
permission- The permission to have.id- The id of the user to check the permission of- Returns:
- if the permission is granted or not.
-
checkPermission
Checks the configuration if a player has a specific permission or has a specific level.- Parameters:
permission- The permission to check the level of.player- the player to check the permission of.- Returns:
- if the player ahs the required permission.
-
checkPermission
public static boolean checkPermission(Permissions permission, org.bukkit.command.CommandSender commandSender)Checks the configuration if a command executor has a specific permission or has a specific level.- Parameters:
permission- The permission to check the level of.commandSender- the executor of a command to check the permission of.- Returns:
- if the command sender has the permission.
-
checkPermission
public static boolean checkPermission(Permissions permission, org.javacord.api.entity.message.MessageAuthor messageAuthor)Checks the configuration if a command executor has a specific permission or has a specific level.- Parameters:
permission- The permission to check the level of.messageAuthor- the discordUserof a command to check the permission of.- Returns:
- if the command sender has the permission.
-