Class ClaimLease

All Implemented Interfaces:
Transaction, org.bukkit.configuration.serialization.ConfigurationSerializable

public class ClaimLease extends BoughtTransaction
Represents a lease transaction for a claim.

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 Details

    • lastPayment

      public LocalDateTime lastPayment
      The time when the last lease payment was made.
    • frequency

      public int frequency
      The frequency (in days) at which lease payments are due.
    • paymentsLeft

      public int paymentsLeft
      The number of remaining lease payments.
  • Constructor Details

    • ClaimLease

      public ClaimLease(Map<String,Object> map)
      Constructs a ClaimLease transaction from a serialized map.
      Parameters:
      map - the map containing serialized transaction data
    • 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 leased
      player - the player leasing the claim
      price - the price per payment period
      sign - the location of the lease sign
      frequency - the number of days between lease payments
      paymentsLeft - the total number of lease payments required
  • Method Details

    • serialize

      public Map<String,Object> serialize()
      Serializes the ClaimLease transaction to a Map.
      Specified by:
      serialize in interface org.bukkit.configuration.serialization.ConfigurationSerializable
      Overrides:
      serialize in class BoughtTransaction
      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 lease
      force - 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