1.14.4 Top10 balance

Discussion in 'Spigot Plugin Development' started by Ardno, Jan 27, 2020.

  1. Hello,
    I'm making a token bank plugin and I would like to add command /tokensbank top10 , what send me top 10 players which have got the most tokens. But I don't know how.
    Code (YAML):
      #bank: 0
    : 35
    : 2
    How from this type code of YAML file I can create a top 10 players? (There will be more players in config)
  2. Something like
    Code (Java):

    List<PlayerEntity> balances = getConfigFile().getKeys(false).stream().sort( ... ).collect( ... );
    balances.sublist(0, 10);
    This is just pseudo, you should think it of yourself.
    • Informative Informative x 1
  3. Keep in mind that running such a command quickly in succession could slow down (or potentially crash) a server with lots of players. Make sure to either put a cooldown on the command or run the code asynchronously.
    • Agree Agree x 1
  4. Or just keep the data cached.
    • Agree Agree x 1
  5. I believe Essentials eco calculates baltop asynchronously and then caches the result for a few minutes.
    • Agree Agree x 1