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 TypeFieldDescriptionintThe frequency (in days) at which lease payments are due.The time when the last lease payment was made.intThe number of remaining lease payments.Fields inherited from class me.EtienneDx.RealEstate.Transactions.BoughtTransaction
buyer, destroyedSign, exitOfferFields 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 TypeMethodDescriptionintRetrieves the frequency of lease payments.intRetrieves the number of remaining lease payments.voidinteract(org.bukkit.entity.Player player) Processes player interaction with the lease sign.voidmsgInfo(org.bukkit.command.CommandSender cs) Sends a one-line information message about the lease transaction to a CommandSender.voidpreview(org.bukkit.entity.Player player) Sends a preview message to the player with lease details.Serializes the ClaimLease transaction to a Map.booleantryCancelTransaction(org.bukkit.entity.Player p, boolean force) Attempts to cancel the lease transaction.booleanupdate()Updates the lease transaction.Methods inherited from class me.EtienneDx.RealEstate.Transactions.BoughtTransaction
destroySign, getBuyerMethods 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:
serializein interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable- Overrides:
serializein 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:
trueif the transaction is finished and should be removed;falseotherwise.
-
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:
trueif the transaction was successfully cancelled,falseotherwise
-
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
-