Class BalanceTopImpl

java.lang.Object
com.earth2me.essentials.BalanceTopImpl
All Implemented Interfaces:
BalanceTop

public class BalanceTopImpl extends Object implements BalanceTop
  • Constructor Details

    • BalanceTopImpl

      public BalanceTopImpl(IEssentials ess)
  • Method Details

    • calculateBalanceTopMapAsync

      public CompletableFuture<Void> calculateBalanceTopMapAsync()
      Description copied from interface: BalanceTop
      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 run BalanceTop.getBalanceTopCache() to get the newly updated cache

      Specified by:
      calculateBalanceTopMapAsync in interface BalanceTop
      Returns:
      A future which completes after the balance top cache has been calculated.
    • getBalanceTopCache

      public Map<UUID,BalanceTop.Entry> getBalanceTopCache()
      Description copied from interface: BalanceTop
      Gets the balance top cache or an empty list if one has not been calculated yet. The balance top cache is a Map which maps the UUID of the player to a BalanceTop.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 BalanceTop.calculateBalanceTopMapAsync() to manually update this cache yourself.

      Specified by:
      getBalanceTopCache in interface BalanceTop
      Returns:
      The balance top cache.
      See Also:
    • getCacheAge

      public long getCacheAge()
      Description copied from interface: BalanceTop
      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.
      Specified by:
      getCacheAge in interface BalanceTop
      Returns:
      The epoch time (in mills.) since last cache update or zero.
    • getBalanceTopTotal

      public BigDecimal getBalanceTopTotal()
      Description copied from interface: BalanceTop
      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.
      Specified by:
      getBalanceTopTotal in interface BalanceTop
      Returns:
      The total amount of money in the economy or zero.
      See Also:
    • isCacheLocked

      public boolean isCacheLocked()
      Description copied from interface: BalanceTop
      Checks to see if BalanceTop.calculateBalanceTopMapAsync() is still in the process of calculating the map.
      Specified by:
      isCacheLocked in interface BalanceTop
      Returns:
      true if the balance top cache is still in the process of being calculated, otherwise false.