Class SeRent
java.lang.Object
me.tayebyassine.homestead.models.serialize.SeRent
Serializable representation of rental data for a region or sub-area.
Stores the renter, duration, timestamps, security deposit, price, and optional notice-to-vacate. Can be serialized to and deserialized from a comma-separated string for persistence.
-
Constructor Summary
ConstructorsConstructorDescriptionSeRent()Create a default rent with values from the regions configuration.SeRent(UUID renterId, long duration, long startedAt, long untilAt, double securityDeposit, double price) Create a rent with the given parameters.SeRent(org.bukkit.OfflinePlayer renter, long duration, long startedAt, long untilAt, double securityDeposit, double price) Create a rent with the given parameters from an offline player. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear renter-specific fields while preserving owner configuration (price, duration, deposit).static SeRentdeserialize(@NotNull String serialized) Deserialize a rent from its comma-separated string form.booleanlongGet the rental duration in milliseconds.@Nullable SeNoticeToVacateGet the notice-to-vacate, if any.doublegetPrice()Get the rental price.@Nullable org.bukkit.OfflinePlayerGet the renter as an offline player.Get the renter's UUID.Get the renter's display name safely.doubleGet the security deposit amount.longGet the timestamp when the rental started.longGet the timestamp when the rental ends.inthashCode()booleanWhether a notice-to-vacate has been issued.booleanWhether this rent currently has a renter.booleanWhether the rental has expired.booleanWhether this is a permanent (non-expiring) rental.booleanisRenterer(UUID renterId) Check whether the given UUID is the current renter.booleanisRenterer(org.bukkit.OfflinePlayer player) Check whether the given player is the current renter.Serialize the rent to a comma-separated string.voidsetDuration(long duration) Set the rental duration in milliseconds.voidsetNoticeToVacate(@Nullable SeNoticeToVacate noticeToVacate) Set the notice-to-vacate.voidsetPrice(double price) Set the rental price.voidsetRenterId(UUID renterId) Set the renter's UUID.voidsetSecurityDeposit(double securityDeposit) Set the security deposit amount.voidsetStartedAt(long startedAt) Set the timestamp when the rental started.voidsetUntilAt(long untilAt) Set the timestamp when the rental ends.toString()
-
Constructor Details
-
SeRent
public SeRent()Create a default rent with values from the regions configuration. -
SeRent
public SeRent(UUID renterId, long duration, long startedAt, long untilAt, double securityDeposit, double price) Create a rent with the given parameters.- Parameters:
renterId- the renter's UUID, ornullfor no renterduration- the rental duration in millisecondsstartedAt- the timestamp when the rental starteduntilAt- the timestamp when the rental ends, or-1for permanentsecurityDeposit- the security deposit amountprice- the rental price
-
SeRent
public SeRent(org.bukkit.OfflinePlayer renter, long duration, long startedAt, long untilAt, double securityDeposit, double price) Create a rent with the given parameters from an offline player.- Parameters:
renter- the renterduration- the rental duration in millisecondsstartedAt- the timestamp when the rental starteduntilAt- the timestamp when the rental endssecurityDeposit- the security deposit amountprice- the rental price
-
-
Method Details
-
deserialize
-
getRenterId
-
setRenterId
Set the renter's UUID.- Parameters:
renterId- the new renter UUID
-
clearRenter
public void clearRenter()Clear renter-specific fields while preserving owner configuration (price, duration, deposit). Called when rent expires or is cancelled. -
isRenterer
public boolean isRenterer(org.bukkit.OfflinePlayer player) Check whether the given player is the current renter.- Parameters:
player- the player to check- Returns:
trueif the player is the renter
-
isRenterer
Check whether the given UUID is the current renter.- Parameters:
renterId- the UUID to check- Returns:
trueif the UUID matches the renter
-
getRenter
@Nullable public @Nullable org.bukkit.OfflinePlayer getRenter()Get the renter as an offline player.- Returns:
- the renter, or
nullif no renter or not found
-
getRenterName
Get the renter's display name safely.- Returns:
- the renter's name, or
"?"if not found
-
hasRenter
public boolean hasRenter()Whether this rent currently has a renter.- Returns:
trueif a renter is assigned
-
getDuration
public long getDuration()Get the rental duration in milliseconds.- Returns:
- the duration, or
-1for permanent
-
setDuration
public void setDuration(long duration) Set the rental duration in milliseconds.- Parameters:
duration- the new duration
-
isPermanent
public boolean isPermanent()Whether this is a permanent (non-expiring) rental.- Returns:
trueif the duration is-1
-
getStartedAt
public long getStartedAt()Get the timestamp when the rental started.- Returns:
- the start timestamp in milliseconds
-
setStartedAt
public void setStartedAt(long startedAt) Set the timestamp when the rental started.- Parameters:
startedAt- the start timestamp in milliseconds
-
getUntilAt
public long getUntilAt()Get the timestamp when the rental ends.- Returns:
- the end timestamp, or
-1for permanent
-
setUntilAt
public void setUntilAt(long untilAt) Set the timestamp when the rental ends.- Parameters:
untilAt- the end timestamp, or-1for permanent
-
isExpired
public boolean isExpired()Whether the rental has expired.- Returns:
trueif the current time is past the end timestamp
-
getNoticeToVacate
Get the notice-to-vacate, if any.- Returns:
- the notice, or
null
-
setNoticeToVacate
Set the notice-to-vacate.- Parameters:
noticeToVacate- the notice, ornullto clear
-
hasNoticeToVacate
public boolean hasNoticeToVacate()Whether a notice-to-vacate has been issued.- Returns:
trueif a notice is active
-
getSecurityDeposit
public double getSecurityDeposit()Get the security deposit amount.- Returns:
- the deposit amount
-
setSecurityDeposit
public void setSecurityDeposit(double securityDeposit) Set the security deposit amount.- Parameters:
securityDeposit- the new deposit amount
-
getPrice
public double getPrice()Get the rental price.- Returns:
- the price
-
setPrice
public void setPrice(double price) Set the rental price.- Parameters:
price- the new price
-
serialize
Serialize the rent to a comma-separated string.- Returns:
- the encoded string
-
toString
-
equals
-
hashCode
-