Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

total amount of all mined blocks #136

Open
IZeeXeS opened this issue May 2, 2023 · 4 comments
Open

total amount of all mined blocks #136

IZeeXeS opened this issue May 2, 2023 · 4 comments
Labels
future Feature will be implemented in the future

Comments

@IZeeXeS
Copy link

IZeeXeS commented May 2, 2023

mine_block all

@Artemis-the-gr8
Copy link
Contributor

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 Artemis-the-gr8 added the future Feature will be implemented in the future label May 9, 2023
@Hikki8
Copy link

Hikki8 commented May 10, 2023

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!

@Artemis-the-gr8
Copy link
Contributor

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.

@DreiFxn
Copy link

DreiFxn commented Jul 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
future Feature will be implemented in the future
Projects
None yet
Development

No branches or pull requests

4 participants