Class PlayerUtility

java.lang.Object
me.tayebyassine.homestead.util.minecraft.players.PlayerUtility

public final class PlayerUtility extends Object
Utility methods for player-related operations: teleportation, operator checks and, most importantly, the resolution of PlayerFlag/ControlFlag permissions inside regions and sub-areas.
  • Field Details

    • RENT_FLAGS_SET

      public static final Set<PlayerFlag> RENT_FLAGS_SET
  • Method Details

    • teleportPlayerToChunkSafely

      public static void teleportPlayerToChunkSafely(org.bukkit.entity.Player player, RegionChunk chunk, @Nullable @Nullable Runnable after)
      Teleport a player to a chunk safely, thread-safe for Folia.
    • teleportPlayerToChunk

      public static void teleportPlayerToChunk(org.bukkit.entity.Player player, org.bukkit.Chunk chunk)
      Teleports the player to the center of the given chunk.
      Parameters:
      player - the player to teleport
      chunk - the destination chunk
    • teleportPlayer

      public static void teleportPlayer(org.bukkit.entity.Player player, org.bukkit.Location location)
      Teleports the player to the given location, using the async API on Folia and the synchronous API on Spigot/PaperMC.
      Parameters:
      player - the player to teleport
      location - the destination location (no-op if null)
    • isOperator

      public static boolean isOperator(org.bukkit.entity.Player player)
      Returns whether the player is considered a Homestead operator (OP or holding the homestead.operator permission).
      Parameters:
      player - the player to check
      Returns:
      true if the player is an operator
    • isOperator

      public static boolean isOperator(org.bukkit.OfflinePlayer player)
      Returns:
      true if the offline player is an OP.
    • hasPermissionFlag

      public static boolean hasPermissionFlag(Region region, org.bukkit.entity.Player player, PlayerFlag flag, boolean notify)
      Resolves a player flag for a region by delegating to hasPermissionFlag(long, Player, PlayerFlag, boolean).
    • hasPermissionFlag

      public static boolean hasPermissionFlag(long regionId, org.bukkit.entity.Player player, PlayerFlag flag, boolean notify)
      Checks whether the given player has the specified player flag in the target region. If the player lacks the permission, a cooldown-gated info message is sent, except for the TAKE_FALL_DAMAGE flag where no message is shown.

      Resolution order:
      1. If the player is the active renter of the region, permissions are granted for all flags except PVP.
      2. Otherwise, if the player is a member, the member flags are used.
      3. Otherwise, the region's global player flags are used.

      Parameters:
      regionId - The region ID
      player - The player to fetch
      flag - The PlayerFlag to check
      Returns:
      true If the action is allowed; false otherwise
    • hasPermissionFlag

      public static boolean hasPermissionFlag(Region region, SubArea subArea, org.bukkit.entity.Player player, PlayerFlag flag, boolean notify)
      Resolves a player flag inside a sub-area, falling back to the parent region when the sub-area does not exist. See hasPermissionFlag(long, long, Player, PlayerFlag, boolean).
    • hasPermissionFlag

      public static boolean hasPermissionFlag(long regionId, long subAreaId, org.bukkit.entity.Player player, PlayerFlag flag, boolean notify)
    • hasControlPermissionFlag

      public static boolean hasControlPermissionFlag(Region region, org.bukkit.entity.Player player, ControlFlag flag, boolean notify)
      Resolves a control flag for a region by delegating to hasControlPermissionFlag(long, Player, ControlFlag, boolean).
    • hasControlPermissionFlag

      public static boolean hasControlPermissionFlag(long regionId, org.bukkit.entity.Player player, ControlFlag flag, boolean notify)
      Checks whether the player has the given ControlFlag in the region.

      Operators and the region owner always pass. Members are evaluated against their control-flag set; non-members are denied. A cooldown-gated denial message is shown when the check fails.

      Parameters:
      regionId - the region ID
      player - the player to check
      flag - the control flag required
      notify - whether to display a denial message to the player
      Returns:
      true if the player may perform the controlled action
    • getPlayerGroup

      public static String getPlayerGroup(org.bukkit.OfflinePlayer player)
      Returns the player's primary permission group, or null when the limits method is not Limits.LimitMethod.GROUPS or no permissions provider is available.
      Parameters:
      player - the player to query
      Returns:
      the primary group name, or null
    • equals

      public static boolean equals(org.bukkit.OfflinePlayer p1, org.bukkit.OfflinePlayer p2)
      Returns:
      true if both players share the same UUID.