Class Region

java.lang.Object
me.tayebyassine.homestead.models.Region

public final class Region extends Object
Represents a claimable region in the world.

A region is the primary territorial unit. Each region has an owner, optional metadata (display name, description), bitmask-based player and world flags, financial state (taxes, bank), map rendering options, a configurable weather/time override, and an optional rent system.

Every mutating method automatically pushes the change to Homestead.REGION_CACHE via update() so that callers never have to remember to persist.

  • Constructor Details

    • Region

      public Region(String name, org.bukkit.OfflinePlayer player)
      Create a new region with a generated snowflake ID.
      Parameters:
      name - the region name
      player - the owner
    • Region

      public Region(String name, UUID ownerId)
      Create a new region with a generated snowflake ID.
      Parameters:
      name - the region name
      ownerId - the owner UUID
    • Region

      public Region(long id, String name, UUID ownerId, long createdAt)
      Create a region from pre-existing data (deserialization).
      Parameters:
      id - the snowflake ID
      name - the region name
      ownerId - the owner UUID
      createdAt - the creation timestamp
  • Method Details

    • getUniqueId

      public long getUniqueId()
      Get the unique snowflake ID of this region.
      Returns:
      the region ID
    • getCreatedAt

      public long getCreatedAt()
      Get the creation timestamp.
      Returns:
      the epoch-millis timestamp when the region was created
    • getName

      @NotNull public @NotNull String getName()
      Get the region name.
      Returns:
      the name
    • setName

      public void setName(@NotNull @NotNull String name)
      Set the region name.
      Parameters:
      name - the new name
    • getDisplayName

      @Nullable public @Nullable String getDisplayName()
      Get the optional display name.
      Returns:
      the display name, or null if not set
    • setDisplayName

      public void setDisplayName(@Nullable @Nullable String displayName)
      Set the optional display name.
      Parameters:
      displayName - the display name, or null to clear
    • getDescription

      @Nullable public @Nullable String getDescription()
      Get the optional description.
      Returns:
      the description, or null if not set
    • setDescription

      public void setDescription(@Nullable @Nullable String description)
      Set the optional description.
      Parameters:
      description - the description, or null to clear
    • getOwnerId

      @NotNull public @NotNull UUID getOwnerId()
      Get the owner UUID.
      Returns:
      the owner UUID
    • setOwnerId

      public void setOwnerId(@NotNull @NotNull UUID ownerId)
      Set the owner UUID.
      Parameters:
      ownerId - the new owner UUID
    • getOwner

      @Nullable public @Nullable org.bukkit.OfflinePlayer getOwner()
      Get the owner as an offline player.
      Returns:
      the owner, or null if not found
    • setOwner

      public void setOwner(@NotNull @NotNull org.bukkit.OfflinePlayer owner)
      Set the owner.
      Parameters:
      owner - the new owner
    • getOwnerName

      @NotNull public @NotNull String getOwnerName()
      Get the owner's name safely. If the player was not found by their ID, it will return "?" instead.
      Returns:
      the owner's name if found, "?" otherwise
    • isOwner

      public boolean isOwner(org.bukkit.OfflinePlayer player)
      Check whether the given player is the owner.
      Parameters:
      player - the player to check
      Returns:
      true if the player is the owner
    • isOwner

      public boolean isOwner(UUID id)
      Check whether the given UUID is the owner.
      Parameters:
      id - the UUID to check
      Returns:
      true if the UUID matches the owner
    • getLocation

      @Nullable public @Nullable SeLocation getLocation()
      Get the region's set location (spawn/home point).
      Returns:
      the location, or null if not set
    • setLocation

      public void setLocation(@Nullable @Nullable org.bukkit.Location location)
      Set the region's location from a Bukkit location.
      Parameters:
      location - the new location, or null to clear
    • setLocation

      public void setLocation(@Nullable @Nullable SeLocation location)
      Set the region's location from a serialisable location.
      Parameters:
      location - the new location, or null to clear
    • resetLocation

      public void resetLocation()
      Reset the region's location to null.
    • getPlayerFlags

      public long getPlayerFlags()
      Get the player flags bitmask.
      Returns:
      the player flags
    • setPlayerFlags

      public void setPlayerFlags(long playerFlags)
      Set the player flags bitmask.
      Parameters:
      playerFlags - the new player flags
    • isPlayerFlagSet

      public boolean isPlayerFlagSet(long flag)
      Check whether a specific player flag is set.
      Parameters:
      flag - the flag bitmask
      Returns:
      true if the flag is set, or if protection mode is enabled
    • isPlayerFlagSet

      public boolean isPlayerFlagSet(PlayerFlag flag)
      Check whether a specific player flag is set.
      Parameters:
      flag - the flag
      Returns:
      true if the flag is set
    • getWorldFlags

      public long getWorldFlags()
      Get the world flags' bitmask.
      Returns:
      the world flags
    • setWorldFlags

      public void setWorldFlags(long worldFlags)
      Set the world flags' bitmask.
      Parameters:
      worldFlags - the new world flags
    • isWorldFlagSet

      public boolean isWorldFlagSet(long flag)
      Check whether a specific world flag is set.
      Parameters:
      flag - the flag bitmask
      Returns:
      true if the flag is set
    • isWorldFlagSet

      public boolean isWorldFlagSet(WorldFlag flag)
      Check whether a specific world flag is set.
      Parameters:
      flag - the flag
      Returns:
      true if the flag is set
    • getTaxes

      public double getTaxes()
      Get the accumulated taxes.
      Returns:
      the taxes
    • setTaxes

      public void setTaxes(double taxes)
      Set the accumulated taxes.
      Parameters:
      taxes - the new tax amount
    • getBank

      public double getBank()
      Get the bank balance.
      Returns:
      the bank balance
    • setBank

      public void setBank(double bank)
      Set the bank balance.
      Parameters:
      bank - the new balance
    • depositBank

      public void depositBank(double amount)
      Deposit an amount into the bank. Ignored if the amount is non-positive.
      Parameters:
      amount - the amount to deposit
    • withdrawBank

      public void withdrawBank(double amount)
      Withdraw an amount from the bank. Ignored if the amount is non-positive or non-finite. The balance never goes below zero.
      Parameters:
      amount - the amount to withdraw
    • getMapColor

      public int getMapColor()
      Get the map colour index.
      Returns:
      the colour index
    • setMapColor

      public void setMapColor(int mapColor)
      Set the map colour index.
      Parameters:
      mapColor - the new colour index
    • getMapIcon

      @Nullable public @Nullable String getMapIcon()
      Get the map icon code.
      Returns:
      the icon, or null if not set
    • setMapIcon

      public void setMapIcon(@Nullable @Nullable String mapIcon)
      Set the map icon code.
      Parameters:
      mapIcon - the icon, or null to clear
    • getRent

      @NotNull public @NotNull SeRent getRent()
      Get the rent configuration. Always returns a non-null instance.
      Returns:
      the rent
    • setRent

      public void setRent(@Nullable @Nullable SeRent rent)
      Set the rent configuration.
      Parameters:
      rent - the new rent, or null to reset to defaults
    • getWeather

      public int getWeather()
      Get the weather override.
      Returns:
      the weather state
    • setWeather

      public void setWeather(int weather)
      Set the weather override.
      Parameters:
      weather - the new weather state
    • getTime

      public int getTime()
      Get the time override.
      Returns:
      the time state
    • setTime

      public void setTime(int time)
      Set the time override.
      Parameters:
      time - the new time state
    • getWelcomeSign

      @Nullable public @Nullable SeLocation getWelcomeSign()
      Get the welcome sign location.
      Returns:
      the sign location, or null if not set
    • setWelcomeSign

      public void setWelcomeSign(@Nullable @Nullable SeLocation welcomeSign)
      Set the welcome sign location.
      Parameters:
      welcomeSign - the sign location, or null to clear
    • getUpkeepAt

      public long getUpkeepAt()
      Get the last upkeep timestamp.
      Returns:
      the epoch-millis timestamp
    • setUpkeepAt

      public void setUpkeepAt(long upkeepAt)
      Set the last upkeep timestamp.
      Parameters:
      upkeepAt - the epoch-millis timestamp
    • isPublic

      public boolean isPublic()
      Check if the region is public. A region is public when both the PlayerFlag.PASSTHROUGH and PlayerFlag.TELEPORT_SPAWN flags are enabled for global players.
      Returns:
      true if the region is public