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

[Bug Report] player_statistic not persisted over server restarts #32

Closed
aSemy opened this issue Mar 23, 2020 · 2 comments
Closed

[Bug Report] player_statistic not persisted over server restarts #32

aSemy opened this issue Mar 23, 2020 · 2 comments
Labels
bug good-first-issue Good for first-time contributors help wanted Contributions are welcome
Milestone

Comments

@aSemy
Copy link
Contributor

aSemy commented Mar 23, 2020

I've noticed that after server restarts the player_statistic will no longer report anything. When a player logs on, only that player will be reported under player_statistic (even if that player then logs off).

This graph shows the total PLAY_ONE_MINUTE for all players. It decreases when the server restarts, and then increases vertically as a new player logs on to the restarted server.

image

It seems this is a limitation with Minecraft/bukkit. I wasn't able to dig into the code to investigate the root cause. Because Player is an interface, and I can't see what player.getStatistic(statistic) does.

Suggestion: PlayerStatistics saves a file with the most recent values. If player.getStatistic(statistic) returns null, then fetch the value from the file. This isn't a great idea...

@sladkoff
Copy link
Owner

Yeah, I've also noticed this before. Thanks for opening an issue for this.

Basically those stats will only show players that have been seen during the current server uptime. I think you're right that this is simply because of the way the Bukkit API works here.

Writing such a save file would be an option but I agree that it doesn't feel like the best approach - we could do that as a last resort.

Maybe we could also look into the Bukkit internals for more information on this. I was hoping maybe there's a way to work around this by emitting some kind of Bukkit event during startup so that all those offline player stats are loaded initially. Even if that works I'm not sure if that's a better idea than the save file 😄

@sladkoff sladkoff added bug help wanted Contributions are welcome labels Mar 24, 2020
@aSemy
Copy link
Contributor Author

aSemy commented Mar 24, 2020

I had a bit more of a look. I still can't see in the source code where the statistics are loaded, but I have found where they are stored: data/world/stats/<player UUID>.json. As a work-around, these files could be read on server-startup and return when player.getStatistic(statistic) returns null.

@sladkoff sladkoff added the good-first-issue Good for first-time contributors label May 6, 2020
@sladkoff sladkoff added this to the 2.3.0 milestone Mar 7, 2021
@sladkoff sladkoff closed this as completed Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good-first-issue Good for first-time contributors help wanted Contributions are welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants