Class TargetRegionSession

java.lang.Object
me.tayebyassine.homestead.sessions.TargetRegionSession

public final class TargetRegionSession extends Object
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
    Modifier and Type
    Field
    Description
    static final HashMap<UUID,Long>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Region
    getRegion(org.bukkit.OfflinePlayer player)
    Get the target region for the given player.
    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.
    static void
    newSession(org.bukkit.entity.Player player)
    Create a new session for the given player, automatically selecting the first region they own.
    static void
    newSession(org.bukkit.entity.Player player, Region region)
    Create a new session for the given player targeting a specific region.
    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.
    static void
    removeSession(org.bukkit.entity.Player player)
    Remove the target-region session for the given player.
    static void
    setRegion(org.bukkit.OfflinePlayer player, String regionName)
    Set the target region for the given player by region name.
    static void
    setRegion(org.bukkit.OfflinePlayer player, Region region)
    Set the target region for the given player.

    Methods inherited from class Object

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

  • Method Details

    • newSession

      public static void newSession(org.bukkit.entity.Player player, Region region)
      Create a new session for the given player targeting a specific region.
      Parameters:
      player - the player
      region - 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 -1 is used.
      Parameters:
      player - the player
    • getRegion

      public static Region getRegion(org.bukkit.OfflinePlayer player)
      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 null if 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:
      true if a valid target region is set
    • setRegion

      public static void setRegion(org.bukkit.OfflinePlayer player, Region region)
      Set the target region for the given player.
      Parameters:
      player - the player
      region - the region to target
    • setRegion

      public static void setRegion(org.bukkit.OfflinePlayer player, String regionName)
      Set the target region for the given player by region name.
      Parameters:
      player - the player
      regionName - 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