Class Utils
This class provides methods for processing economy transactions, formatting time durations, transferring claim blocks between players, and truncating strings for sign display.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringgetSignString(String str) Truncates a given string to a maximum length of 16 characters.static StringFormats a time duration as a human-readable string.static booleanmakePayment(UUID receiver, UUID giver, double amount, boolean msgReceiver, boolean msgGiver) Processes a payment transaction between two players.static voidtransferClaim(IClaim claim, UUID buyer, UUID seller) Transfers a claim from one owner to another.
- 
Constructor Details- 
Utilspublic Utils()Instantiates a new Utils object.
 
- 
- 
Method Details- 
makePaymentpublic static boolean makePayment(UUID receiver, UUID giver, double amount, boolean msgReceiver, boolean msgGiver) Processes a payment transaction between two players.The method attempts to withdraw a specified amount from the giver and deposit it to the receiver. If the giver does not have sufficient funds or if any transaction fails, an error message is sent (if enabled) and the transaction is aborted. - Parameters:
- receiver- the UUID of the player who will receive money (can be null for the server)
- giver- the UUID of the player from whom money is to be withdrawn
- amount- the amount of money to transfer
- msgReceiver- if- trueand the receiver is online, a message will be sent
- msgGiver- if- trueand the giver is online, a message will be sent
- Returns:
- trueif the payment was successful;- falseotherwise.
 
- 
getTimeFormats a time duration as a human-readable string.The method converts the given number of days and a Duration representing hours/minutes into a string such as "1 week 3 days 5 hours 30 mins". - Parameters:
- days- the number of days
- hours- a Duration representing additional hours and minutes; may be- null
- details- if- true, include hours and minutes even when days are present
- Returns:
- a formatted string representing the total time.
 
- 
transferClaimTransfers a claim from one owner to another.This method handles the transfer of claim blocks between the seller and buyer if claim blocks are being transferred, and then updates the claim's ownership using the claim API. - Parameters:
- claim- the claim to be transferred
- buyer- the UUID of the new owner
- seller- the UUID of the current owner (may be- nullfor admin claims)
 
- 
getSignStringTruncates a given string to a maximum length of 16 characters.This is used for ensuring that sign text does not exceed Minecraft's character limit. - Parameters:
- str- the input string
- Returns:
- the truncated string if its length exceeds 16 characters; otherwise, the original string.
 
 
-