Class PlayerUtility
java.lang.Object
me.tayebyassine.homestead.util.minecraft.players.PlayerUtility
Utility methods for player-related operations: teleportation, operator checks and, most
importantly, the resolution of
PlayerFlag/ControlFlag permissions inside regions
and sub-areas.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequals(org.bukkit.OfflinePlayer p1, org.bukkit.OfflinePlayer p2) static StringgetPlayerGroup(org.bukkit.OfflinePlayer player) Returns the player's primary permission group, ornullwhen the limits method is notLimits.LimitMethod.GROUPSor no permissions provider is available.static booleanhasControlPermissionFlag(long regionId, org.bukkit.entity.Player player, ControlFlag flag, boolean notify) Checks whether the player has the givenControlFlagin the region.static booleanhasControlPermissionFlag(Region region, org.bukkit.entity.Player player, ControlFlag flag, boolean notify) Resolves a control flag for a region by delegating tohasControlPermissionFlag(long, Player, ControlFlag, boolean).static booleanhasPermissionFlag(long regionId, long subAreaId, org.bukkit.entity.Player player, PlayerFlag flag, boolean notify) static booleanhasPermissionFlag(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.static booleanhasPermissionFlag(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.static booleanhasPermissionFlag(Region region, org.bukkit.entity.Player player, PlayerFlag flag, boolean notify) Resolves a player flag for a region by delegating tohasPermissionFlag(long, Player, PlayerFlag, boolean).static booleanisOperator(org.bukkit.entity.Player player) Returns whether the player is considered a Homestead operator (OP or holding thehomestead.operatorpermission).static booleanisOperator(org.bukkit.OfflinePlayer player) static voidteleportPlayer(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.static voidteleportPlayerToChunk(org.bukkit.entity.Player player, org.bukkit.Chunk chunk) Teleports the player to the center of the given chunk.static voidteleportPlayerToChunkSafely(org.bukkit.entity.Player player, RegionChunk chunk, @Nullable Runnable after) Teleport a player to a chunk safely, thread-safe for Folia.
-
Field Details
-
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 teleportchunk- 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 teleportlocation- the destination location (no-op ifnull)
-
isOperator
public static boolean isOperator(org.bukkit.entity.Player player) Returns whether the player is considered a Homestead operator (OP or holding thehomestead.operatorpermission).- Parameters:
player- the player to check- Returns:
trueif the player is an operator
-
isOperator
public static boolean isOperator(org.bukkit.OfflinePlayer player) - Returns:
trueif 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 tohasPermissionFlag(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 theTAKE_FALL_DAMAGEflag where no message is shown.Resolution order:
1. If the player is the active renter of the region, permissions are granted for all flags exceptPVP.
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 IDplayer- The player to fetchflag- The PlayerFlag to check- Returns:
trueIf the action is allowed;falseotherwise
-
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. SeehasPermissionFlag(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 tohasControlPermissionFlag(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 givenControlFlagin 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 IDplayer- the player to checkflag- the control flag requirednotify- whether to display a denial message to the player- Returns:
trueif the player may perform the controlled action
-
getPlayerGroup
Returns the player's primary permission group, ornullwhen the limits method is notLimits.LimitMethod.GROUPSor 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:
trueif both players share the sameUUID.
-