Class ClaimRent
- All Implemented Interfaces:
Transaction
,org.bukkit.configuration.serialization.ConfigurationSerializable
This transaction handles the leasing of claims by a renter. It supports auto-renewal, periodic lease payments, and updates the sign display with the current lease status.
-
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
If true, the lease is set to auto-renew once the duration expires.boolean
Indicates whether the lease grants building trust (if true) or container trust (if false).Fields inherited from class me.EtienneDx.RealEstate.Transactions.BoughtTransaction
buyer, destroyedSign, exitOffer
Fields inherited from class me.EtienneDx.RealEstate.Transactions.ClaimTransaction
claimId, owner, price, sign
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
interact
(org.bukkit.entity.Player player) Processes player interaction with the rent sign.void
msgInfo
(org.bukkit.command.CommandSender cs) Sends a one-line summary of the lease transaction to a command sender.void
preview
(org.bukkit.entity.Player player) Previews detailed lease information to a player.Serializes this ClaimRent transaction to a Map.boolean
tryCancelTransaction
(org.bukkit.entity.Player p, boolean force) Attempts to cancel this lease transaction.boolean
update()
Updates the state of the lease transaction.Methods inherited from class me.EtienneDx.RealEstate.Transactions.BoughtTransaction
destroySign, getBuyer
Methods inherited from class me.EtienneDx.RealEstate.Transactions.ClaimTransaction
getClaim, getHolder, getOwner, getOwnerUUID, getPrice, getSign, setOwner, tryCancelTransaction
-
Field Details
-
autoRenew
public boolean autoRenewIf true, the lease is set to auto-renew once the duration expires. -
buildTrust
public boolean buildTrustIndicates whether the lease grants building trust (if true) or container trust (if false).
-
-
Constructor Details
-
ClaimRent
-
ClaimRent
public ClaimRent(IClaim claim, org.bukkit.entity.Player player, double price, org.bukkit.Location sign, int duration, boolean buildTrust) Constructs a new ClaimRent transaction.- Parameters:
claim
- the claim being rentedplayer
- the player initiating the rentprice
- the rental price per periodsign
- the location of the sign representing the rentduration
- the lease period (in days)buildTrust
- if true, grants building permissions; if false, grants container trust only
-
-
Method Details
-
serialize
Serializes this ClaimRent transaction to a Map.- Specified by:
serialize
in interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable
- Overrides:
serialize
in classBoughtTransaction
- Returns:
- a Map representation of this lease transaction
-
update
public boolean update()Updates the state of the lease transaction.If no buyer is present, it updates the sign with rental information. Otherwise, it checks if the lease period has expired. If so, it processes a payment via
payRent()
. If the lease is ongoing, the sign is updated with the remaining time.- Returns:
- false to indicate the transaction remains active
-
tryCancelTransaction
public boolean tryCancelTransaction(org.bukkit.entity.Player p, boolean force) Attempts to cancel this lease transaction.If the player has admin permission or cancellation is forced, the lease is cancelled. Otherwise, an error message is sent.
- Parameters:
p
- the player attempting cancellationforce
- if true, forces cancellation regardless of other conditions- Returns:
- true if the transaction is cancelled; false otherwise
-
interact
public void interact(org.bukkit.entity.Player player) Processes player interaction with the rent sign.Validates the player's eligibility to rent the claim and, if payment succeeds, updates the claim permissions, logs the transaction, and destroys the sign.
- Parameters:
player
- the player interacting with the rent sign
-
preview
public void preview(org.bukkit.entity.Player player) Previews detailed lease information to a player.This includes the lease header, current renter (if any), remaining time, and owner information.
- Parameters:
player
- the player to receive the lease preview
-
msgInfo
public void msgInfo(org.bukkit.command.CommandSender cs) Sends a one-line summary of the lease transaction to a command sender.- Parameters:
cs
- the command sender (console or player) to receive the summary
-