Class TargetRegionSession
java.lang.Object
me.tayebyassine.homestead.sessions.TargetRegionSession
Manages the "target region" session for each player.
The target region is the region that subsequent actions (claim,
unclaim, set spawn, etc.) will operate on. Sessions are stored
both in memory and in the player's PersistentDataContainer
so they survive reconnects.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic RegiongetRegion(org.bukkit.OfflinePlayer player) Get the target region for the given player.static booleanhasSession(org.bukkit.entity.Player player) Check whether the given player has an active target-region session that resolves to a valid region.static voidnewSession(org.bukkit.entity.Player player) Create a new session for the given player, automatically selecting the first region they own.static voidnewSession(org.bukkit.entity.Player player, Region region) Create a new session for the given player targeting a specific region.static voidrandomizeRegion(org.bukkit.entity.Player player) Randomly select one of the regions owned by the given player and set it as the target.static voidremoveSession(org.bukkit.entity.Player player) Remove the target-region session for the given player.static voidSet the target region for the given player by region name.static voidSet the target region for the given player.
-
Field Details
-
SESSIONS
-
-
Method Details
-
newSession
Create a new session for the given player targeting a specific region.- Parameters:
player- the playerregion- the region to target
-
newSession
public static void newSession(org.bukkit.entity.Player player) Create a new session for the given player, automatically selecting the first region they own. If they own no regions, a sentinel value of-1is used.- Parameters:
player- the player
-
getRegion
Get the target region for the given player.If no session exists in memory, the persisted value is loaded. If auto-set is enabled and the player owns regions, a random one is selected.
- Parameters:
player- the player- Returns:
- the target region, or
nullif none is set
-
hasSession
public static boolean hasSession(org.bukkit.entity.Player player) Check whether the given player has an active target-region session that resolves to a valid region.- Parameters:
player- the player- Returns:
trueif a valid target region is set
-
setRegion
Set the target region for the given player.- Parameters:
player- the playerregion- the region to target
-
setRegion
Set the target region for the given player by region name.- Parameters:
player- the playerregionName- the name of the region to target
-
randomizeRegion
public static void randomizeRegion(org.bukkit.entity.Player player) Randomly select one of the regions owned by the given player and set it as the target.- Parameters:
player- the player
-
removeSession
public static void removeSession(org.bukkit.entity.Player player) Remove the target-region session for the given player.- Parameters:
player- the player
-