Package net.essentialsx.api.v2.services
Interface BalanceTop
- All Known Implementing Classes:
BalanceTopImpl
public interface BalanceTop
A class which provides numerous methods to interact with Essentials' balance top calculations.
Note: Implementations of this class should be thread-safe and thus do not need to be called from the server thread.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
This class represents a user's name/balance in the balancetop cache. -
Method Summary
Modifier and TypeMethodDescriptionRe-calculates the balance top cache asynchronously.Gets the balance top cache or an empty list if one has not been calculated yet.Gets the total amount of money in the economy at the point of the last balance top cache calculation or returns zero if no baltop calculation has been made as of yet.long
Gets the epoch time (in mills.) that the baltop cache was last updated at.boolean
Checks to see ifcalculateBalanceTopMapAsync()
is still in the process of calculating the map.
-
Method Details
-
calculateBalanceTopMapAsync
CompletableFuture<Void> calculateBalanceTopMapAsync()Re-calculates the balance top cache asynchronously.This method will return a
CompletableFuture<Void>
which will be completed upon the recalculation of the balance top map. After which you should rungetBalanceTopCache()
to get the newly updated cache- Returns:
- A future which completes after the balance top cache has been calculated.
-
getBalanceTopCache
Map<UUID,BalanceTop.Entry> getBalanceTopCache()Gets the balance top cache or an empty list if one has not been calculated yet. The balance top cache is aMap
which maps the UUID of the player to aBalanceTop.Entry
object which stores the user's display name and balance. The returned map is sorted by greatest to least wealth.There is no guarantee the returned cache is up to date. The balancetop command is directly responsible for updating this cache and does so every two minutes (if executed). See
calculateBalanceTopMapAsync()
to manually update this cache yourself.- Returns:
- The balance top cache.
- See Also:
-
getCacheAge
long getCacheAge()Gets the epoch time (in mills.) that the baltop cache was last updated at. A value of zero indicates the cache has not been calculated yet at all.- Returns:
- The epoch time (in mills.) since last cache update or zero.
-
getBalanceTopTotal
BigDecimal getBalanceTopTotal()Gets the total amount of money in the economy at the point of the last balance top cache calculation or returns zero if no baltop calculation has been made as of yet.- Returns:
- The total amount of money in the economy or zero.
- See Also:
-
isCacheLocked
boolean isCacheLocked()Checks to see ifcalculateBalanceTopMapAsync()
is still in the process of calculating the map.- Returns:
- true if the balance top cache is still in the process of being calculated, otherwise false.
-