Class Permissions

java.lang.Object
de.Keyle.MyPet.api.player.Permissions

public class Permissions extends Object
Static permission-check utility. All MyPet permission queries go through this class rather than calling player.hasPermission() directly, because MyPet supports an "extended permissions" mode (MyPetGlobal.Permissions.EXTENDED) that gates optional features behind additional permission nodes.

Two families of checks:

  • has() — unconditional check. Returns true if the player is OP or has the node.
  • hasExtended() — conditional check. Only evaluates the node when extended-permissions mode is enabled; otherwise returns true (or the supplied default). This lets admins run MyPet with minimal permission setup when extended mode is off.
  • Constructor Details

    • Permissions

      public Permissions()
      Not intended for instantiation -- every member of this class is static.
  • Method Details

    • has

      public static boolean has(MyPetPlayer player, String node)
      Checks a permission node against a MyPetPlayer. Returns false if the player is null or offline.
      Parameters:
      player - the player to test
      node - the permission node to check
      Returns:
      true if the player holds the node
    • has

      public static boolean has(Player player, String node)
      Checks a permission node against an online player. OP always passes.
      Parameters:
      player - the player to test
      node - the permission node to check
      Returns:
      true if the player holds the node
    • hasExtended

      public static boolean hasExtended(MyPetPlayer player, String node)
      Extended-mode check for a MyPetPlayer. When extended permissions are disabled globally, returns true without checking the node.
      Parameters:
      player - the player to test
      node - the permission node to check
      Returns:
      true if the player holds the node, or extended permissions are off
    • hasExtended

      public static boolean hasExtended(Player player, String node)
      Extended-mode check. Returns true if extended permissions are disabled, or if the player has the node.
      Parameters:
      player - the player to test
      node - the permission node to check
      Returns:
      true if the player holds the node, or extended permissions are off
    • hasExtended

      public static boolean hasExtended(Player player, String node, boolean defaultValue)
      Extended-mode check with an explicit default. When extended permissions are disabled, returns defaultValue instead of unconditionally passing.
      Parameters:
      player - the player to test
      node - the permission node to check
      defaultValue - what to return when extended permissions are switched off
      Returns:
      true if the player holds the node, otherwise defaultValue when extended permissions are off
    • has

      public static boolean has(OfflinePlayer player, String node)
      Offline permission check. Constructs a temporary PermissibleBase to evaluate the node without an active session. OP always passes.
      Parameters:
      player - the player to test
      node - the permission node to check
      Returns:
      true if the player holds the node
    • hasExtended

      public static boolean hasExtended(OfflinePlayer player, String node)
      Extended-mode offline check. See hasExtended(Player, String).
      Parameters:
      player - the player to test
      node - the permission node to check
      Returns:
      true if the player holds the node, or extended permissions are off
    • hasExtended

      public static boolean hasExtended(OfflinePlayer player, String node, boolean defaultValue)
      Extended-mode offline check with explicit default.
      Parameters:
      player - the player to test
      node - the permission node to check
      defaultValue - what to return when extended permissions are switched off
      Returns:
      true if the player holds the node, otherwise defaultValue when extended permissions are off