Class ClaimLease
- All Implemented Interfaces:
Transaction
,org.bukkit.configuration.serialization.ConfigurationSerializable
A ClaimLease handles the process of leasing a claim by a player, including updating the sign with lease details, processing payments, and transferring claim ownership when the lease expires.
-
Field Summary
FieldsModifier and TypeFieldDescriptionint
The frequency (in days) at which lease payments are due.The time when the last lease payment was made.int
The number of remaining lease payments.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
ConstructorsConstructorDescriptionClaimLease
(Map<String, Object> map) Constructs a ClaimLease transaction from a serialized map.ClaimLease
(IClaim claim, org.bukkit.entity.Player player, double price, org.bukkit.Location sign, int frequency, int paymentsLeft) Constructs a new ClaimLease transaction. -
Method Summary
Modifier and TypeMethodDescriptionint
Retrieves the frequency of lease payments.int
Retrieves the number of remaining lease payments.void
interact
(org.bukkit.entity.Player player) Processes player interaction with the lease sign.void
msgInfo
(org.bukkit.command.CommandSender cs) Sends a one-line information message about the lease transaction to a CommandSender.void
preview
(org.bukkit.entity.Player player) Sends a preview message to the player with lease details.Serializes the ClaimLease transaction to a Map.boolean
tryCancelTransaction
(org.bukkit.entity.Player p, boolean force) Attempts to cancel the lease transaction.boolean
update()
Updates 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
-
lastPayment
The time when the last lease payment was made. -
frequency
public int frequencyThe frequency (in days) at which lease payments are due. -
paymentsLeft
public int paymentsLeftThe number of remaining lease payments.
-
-
Constructor Details
-
ClaimLease
-
ClaimLease
public ClaimLease(IClaim claim, org.bukkit.entity.Player player, double price, org.bukkit.Location sign, int frequency, int paymentsLeft) Constructs a new ClaimLease transaction.- Parameters:
claim
- the claim being leasedplayer
- the player leasing the claimprice
- the price per payment periodsign
- the location of the lease signfrequency
- the number of days between lease paymentspaymentsLeft
- the total number of lease payments required
-
-
Method Details
-
serialize
Serializes the ClaimLease transaction to a Map.- Specified by:
serialize
in interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable
- Overrides:
serialize
in classBoughtTransaction
- Returns:
- a Map containing all the relevant data for this lease transaction
-
update
public boolean update()Updates the lease transaction.If no buyer is assigned, it updates the lease sign with payment information. If a buyer exists, it checks if the lease period has expired and processes a payment.
- Returns:
true
if the transaction is finished and should be removed;false
otherwise.
-
tryCancelTransaction
public boolean tryCancelTransaction(org.bukkit.entity.Player p, boolean force) Attempts to cancel the lease transaction.If the player has administrative privileges or the cancellation is forced, the lease is cancelled; otherwise, an error message is sent.
- Parameters:
p
- the player attempting to cancel the leaseforce
- whether cancellation is forced- Returns:
true
if the transaction was successfully cancelled,false
otherwise
-
interact
public void interact(org.bukkit.entity.Player player) Processes player interaction with the lease sign.Handles lease purchase by validating the player's permissions, ensuring the claim is valid, and processing the payment.
- Parameters:
player
- the player interacting with the lease sign
-
preview
public void preview(org.bukkit.entity.Player player) Sends a preview message to the player with lease details.This method constructs and sends a multi-line message to the player showing the lease header, lease details (number of payments, price, duration), and the current owner information.
- Parameters:
player
- the player receiving the preview message
-
msgInfo
public void msgInfo(org.bukkit.command.CommandSender cs) Sends a one-line information message about the lease transaction to a CommandSender.- Parameters:
cs
- the CommandSender to send the information message to
-
getFrequency
public int getFrequency()Retrieves the frequency of lease payments.- Returns:
- the number of days between lease payments
-
getPaymentsLeft
public int getPaymentsLeft()Retrieves the number of remaining lease payments.- Returns:
- the number of payments left
-