Class Region
java.lang.Object
me.tayebyassine.homestead.models.Region
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 Summary
ConstructorsConstructorDescriptionCreate a region from pre-existing data (deserialization).Create a new region with a generated snowflake ID.Create a new region with a generated snowflake ID. -
Method Summary
Modifier and TypeMethodDescriptionvoiddepositBank(double amount) Deposit an amount into the bank.doublegetBank()Get the bank balance.longGet the creation timestamp.@Nullable StringGet the optional description.@Nullable StringGet the optional display name.@Nullable SeLocationGet the region's set location (spawn/home point).intGet the map colour index.@Nullable StringGet the map icon code.@NotNull StringgetName()Get the region name.@Nullable org.bukkit.OfflinePlayergetOwner()Get the owner as an offline player.@NotNull UUIDGet the owner UUID.@NotNull StringGet the owner's name safely.longGet the player flags bitmask.@NotNull SeRentgetRent()Get the rent configuration.doublegetTaxes()Get the accumulated taxes.intgetTime()Get the time override.longGet the unique snowflake ID of this region.longGet the last upkeep timestamp.intGet the weather override.@Nullable SeLocationGet the welcome sign location.longGet the world flags' bitmask.booleanCheck whether the given UUID is the owner.booleanisOwner(org.bukkit.OfflinePlayer player) Check whether the given player is the owner.booleanisPlayerFlagSet(long flag) Check whether a specific player flag is set.booleanisPlayerFlagSet(PlayerFlag flag) Check whether a specific player flag is set.booleanisPublic()Check if the region is public.booleanisWorldFlagSet(long flag) Check whether a specific world flag is set.booleanisWorldFlagSet(WorldFlag flag) Check whether a specific world flag is set.voidReset the region's location tonull.voidsetBank(double bank) Set the bank balance.voidsetDescription(@Nullable String description) Set the optional description.voidsetDisplayName(@Nullable String displayName) Set the optional display name.voidsetLocation(@Nullable SeLocation location) Set the region's location from a serialisable location.voidsetLocation(@Nullable org.bukkit.Location location) Set the region's location from a Bukkit location.voidsetMapColor(int mapColor) Set the map colour index.voidsetMapIcon(@Nullable String mapIcon) Set the map icon code.voidSet the region name.voidsetOwner(@NotNull org.bukkit.OfflinePlayer owner) Set the owner.voidsetOwnerId(@NotNull UUID ownerId) Set the owner UUID.voidsetPlayerFlags(long playerFlags) Set the player flags bitmask.voidSet the rent configuration.voidsetTaxes(double taxes) Set the accumulated taxes.voidsetTime(int time) Set the time override.voidsetUpkeepAt(long upkeepAt) Set the last upkeep timestamp.voidsetWeather(int weather) Set the weather override.voidsetWelcomeSign(@Nullable SeLocation welcomeSign) Set the welcome sign location.voidsetWorldFlags(long worldFlags) Set the world flags' bitmask.voidwithdrawBank(double amount) Withdraw an amount from the bank.
-
Constructor Details
-
Region
Create a new region with a generated snowflake ID.- Parameters:
name- the region nameplayer- the owner
-
Region
-
Region
-
-
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
-
setName
Set the region name.- Parameters:
name- the new name
-
getDisplayName
Get the optional display name.- Returns:
- the display name, or
nullif not set
-
setDisplayName
Set the optional display name.- Parameters:
displayName- the display name, ornullto clear
-
getDescription
Get the optional description.- Returns:
- the description, or
nullif not set
-
setDescription
Set the optional description.- Parameters:
description- the description, ornullto clear
-
getOwnerId
-
setOwnerId
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
nullif not found
-
setOwner
public void setOwner(@NotNull @NotNull org.bukkit.OfflinePlayer owner) Set the owner.- Parameters:
owner- the new owner
-
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:
trueif the player is the owner
-
isOwner
Check whether the given UUID is the owner.- Parameters:
id- the UUID to check- Returns:
trueif the UUID matches the owner
-
getLocation
Get the region's set location (spawn/home point).- Returns:
- the location, or
nullif 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, ornullto clear
-
setLocation
Set the region's location from a serialisable location.- Parameters:
location- the new location, ornullto clear
-
resetLocation
public void resetLocation()Reset the region's location tonull. -
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:
trueif the flag is set, or if protection mode is enabled
-
isPlayerFlagSet
Check whether a specific player flag is set.- Parameters:
flag- the flag- Returns:
trueif 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:
trueif the flag is set
-
isWorldFlagSet
Check whether a specific world flag is set.- Parameters:
flag- the flag- Returns:
trueif 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
Get the map icon code.- Returns:
- the icon, or
nullif not set
-
setMapIcon
Set the map icon code.- Parameters:
mapIcon- the icon, ornullto clear
-
getRent
Get the rent configuration. Always returns a non-null instance.- Returns:
- the rent
-
setRent
Set the rent configuration.- Parameters:
rent- the new rent, ornullto 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
Get the welcome sign location.- Returns:
- the sign location, or
nullif not set
-
setWelcomeSign
Set the welcome sign location.- Parameters:
welcomeSign- the sign location, ornullto 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 thePlayerFlag.PASSTHROUGHandPlayerFlag.TELEPORT_SPAWNflags are enabled for global players.- Returns:
trueif the region is public
-