PlayerStats icon indicating copy to clipboard operation
PlayerStats copied to clipboard

total amount of all mined blocks

Open IZeeXeS opened this issue 2 years ago • 4 comments

mine_block all

IZeeXeS avatar May 02 '23 19:05 IZeeXeS

I am working on this, but this will only be possible once PlayerStats can work with a database. Minecraft doesn't store statistics for total mined blocks, so I would have to look up all values for every single block (and in 1.19.4 there are 998 different blocks) and count them up manually. For one player, this might be doable, but for a top 10 or server total, this means I would have to check up to 998 values for every single player - and that would very quickly become an intense operation for the server to do.

Once I have database support implemented, it will be a lot less intense to look up this many values, and I am planning to add a feature for all blocks mined then.

Artemis-the-gr8 avatar May 09 '23 11:05 Artemis-the-gr8

Hello!

Spigot api has total amount of mined blocks statistic implementation: https://helpch.at/docs/1.13.1/org/bukkit/Statistic.html#MINE_BLOCK

Seems like you don't have to sum all ingame mined blocks if I am correct

image

Thank you for an awesome plugin!

Hikki8 avatar May 10 '23 13:05 Hikki8

Thanks for the compliment! :)

And the Spigot API is actually exactly what I am using - but you can't get a total value for mine_block that way. You can only get a value for mine_block if you also supply a specific block. Here you can see there are 3 methods to get a statistic value (all called getStatistic), one for entity-type statistics, one for material-types, and a general one: https://helpch.at/docs/1.13.1/org/bukkit/entity/Player.html

The general one throws an error if you try to use it for mine_block, so you have to use the one for material-types and supply a valid material (a block).

The screenshot you shared is from the statistic expansion for PlaceholderAPI, and I've looked into how they are doing it before. You can see their code here if you are curious: https://github.com/PlaceholderAPI/Statistics-Expansion/blob/master/src/main/java/com/extendedclip/papi/expansion/mcstatistics/StatisticsExpansion.java

They are also using the Spigot API, and they are calculating the total for mine_block by looping through every single block and getting the corresponding statistic value for the given player. And like I said, that works fine for a single player, but very quickly becomes a performance issue if you have to do it for every player that has ever played on the server (as is the case for a top 10 or server total).

Once PlayerStats can make use of a database, I can store all the values in there and get all mined blocks at once - so that's when I can safely implement a feature for total mined blocks.

Artemis-the-gr8 avatar May 10 '23 14:05 Artemis-the-gr8

I´m hyped for this.

By the way, a very cool plugin - since I installed it there is much more competition - especially who has eaten the most pieces of cake.

  • Drei

DreiFxn avatar Jul 23 '24 16:07 DreiFxn