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. Config: Code (YAML): #PlayerName: #bank: 0 Ardno: bank: 35 MinerFriggo: bank: 2 How from this type code of YAML file I can create a top 10 players? (There will be more players in config)
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.
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.
I believe Essentials eco calculates baltop asynchronously and then caches the result for a few minutes.