Class CheckPermission

java.lang.Object
com.github.mafelp.utils.CheckPermission

public class CheckPermission
extends java.lang.Object
Class used to check permissions on Discord or on the Minecraft server
  • Constructor Summary

    Constructors
    Constructor Description
    CheckPermission()  
  • Method Summary

    Modifier and Type Method Description
    static boolean checkPermission​(Permissions permission, long id)
    Checks the configuration if the user id is in the configuration path.
    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.
    static boolean checkPermission​(Permissions permission, org.bukkit.entity.Player player)
    Checks the configuration if a player has a specific permission or has a specific level.
    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.
    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.
    static org.javacord.api.entity.message.embed.EmbedBuilder getPermissionDeniedEmbed​(org.javacord.api.entity.message.MessageAuthor messageAuthor, java.lang.String action)
    Gets the embed to server to the user, when he/she does not have the required permissions for something.
    static boolean hasAdminLevel​(org.bukkit.entity.Player player, int level)
    Checks if a player has a specific admin level.
    static boolean hasAdminPermission​(org.javacord.api.entity.message.MessageAuthor messageAuthor)
    Checks if a user is a server admin or in the permission.adminIDs list in the config.yml file.
    static boolean isBotAdmin​(org.javacord.api.entity.message.MessageAuthor messageAuthor)
    Checks if a user a server admin or in the permissions.botAdminIDs list in the config.yml file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CheckPermission

      public CheckPermission()
  • Method Details

    • getPermissionDeniedEmbed

      public static org.javacord.api.entity.message.embed.EmbedBuilder getPermissionDeniedEmbed​(org.javacord.api.entity.message.MessageAuthor messageAuthor, java.lang.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 the permission.adminIDs list in the config.yml file.
      Parameters:
      messageAuthor - The user to check the permissions from.
      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 the permissions.botAdminIDs list in the config.yml file.
      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

      public static boolean checkPermission​(Permissions permission, long id)
      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

      public static boolean checkPermission​(Permissions permission, org.bukkit.entity.Player player)
      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 discord User of a command to check the permission of.
      Returns:
      if the command sender has the permission.