pdinklag / MinecraftStats

A Minecraft player statistics browser for the web - supports 1.13 and later!
https://discord.gg/brH5PGG8By
Other
227 stars 53 forks source link

Error updating #96

Closed Sky-Evil closed 4 years ago

Sky-Evil commented 4 years ago

Hello! Recently, I copied my statistics folder from the hosting to the computer.

After that, when you type python3 update.py -s / root / server / --server-name I started getting this error: Traceback (most recent call last):   File "update.py", line 498, in     json.dump (player ['stats'], dataFile) KeyError: 'stats'

I deleted the data folder, and generated it again. Moved the saved events folder, and updated everything using the same python3 command update.py -s / root / server / --server-name

But after that, part of the player names in certified events began to appear as a UUID code, and not a nickname.

I checked the folders playercache, playerdata, it turned out that only the files of the players that entered the game that day were created in them. Apparently because of this, the names of players who did not enter the game turned into a UUID. Сейчас это выглядит вот так https://stats.oldcraft-mc.ru/#event:LavaCreamHunter

After that, I downloaded the data file that I had on my PC, but I can’t update the statistics due to this error: Traceback (most recent call last):   File "update.py", line 498, in     json.dump (player ['stats'], dataFile) KeyError: 'stats'

What could be wrong? Sorry for the poor English, my native language is Russian, I use a translator. And you didn’t think about creating a Discord channel for supporting and communicating with your subscribers?

pdinklag commented 4 years ago

I just checked your page and saw that all skins are default, and then I tried putting some UUIDs into the Mojang API (e.g. your UUID). It seems those UUIDs are not linked to Mojang accounts.

So yeah, no judgement intended at all, but do you use cracked clients? If so, MinecraftStats can't get player names from Mojang and has to use the server's own user cache. The entries in there expire after a while, and that's why you only see people who recently joined the server and the rest remain UUIDs.

In that case, there's nothing I can really do. You'll have to find a way to make the entries in usercache.json permanent.

pdinklag commented 4 years ago

Concerning the KeyError, I'd assume that the JSON files in your world's stats directory are either not there for some players, or they're corrupt. It's a bit hard to tell without having a look at them. Make sure they're there for every player and that they begin with

{"stats"

What exactly did you delete and what didn't you delete? If you delete single folders out of MinecraftStats generated files, I can't guarantee anything to work, really.

pdinklag commented 4 years ago

Closing due to lack of feedback.

mercurialmusic commented 4 years ago

I'm getting the same error. New to using this and it was working well for a while but randomly decided not to. Tried running the command manually (otherwise it's running on a CRON every 15 minutes) and got:

Traceback (most recent call last):
  File "update.py", line 488, in <module>
    json.dump(player['stats'], dataFile)
KeyError: 'stats'

I have over 2500 player stat files so it's kinda impossible to go through them all, but random checks showed the {"stats" in each. It's a BungeeCord setup but I'm only using the stats for one world on the survival server, so while the server is in offline mode the Bungee is in online mode and validates the UUIDs (as evidenced by skins on our stats page).

Potentially relevant, I have a plugin that moves player stats files older than 9 months to an archive folder to keep the stats folder from getting insane. This check happens during startup.

One interesting thing that I noted, the last update time is stuck on June 7 at 4:30am, which is when the server restarts every night.

Our stats page: https://stats.badwolfmc.com/

Also interesting: I'm also seeing some players translated as UUIDs on some of the awards pages, like this one: https://stats.badwolfmc.com/#award:play . Checking the first UUID that shows up there, it's a valid UUID of a regular player and the stats file itself seems fine (converted to txt file to attach): 976676cd-97a6-488c-b571-727e962ca0d0.txt

Would definitely appreciate any assistance, and thanks for making this tool! We've enjoyed it quite a lot.

pdinklag commented 4 years ago

Potentially relevant, I have a plugin that moves player stats files older than 9 months to an archive folder to keep the stats folder from getting insane. This check happens during startup.

This could be the issue if your stats have been running for that time and mcstats is trying to update stats for a player that "no longer exists" (because the file is in a different folder). But I suppose that isn't the case for all those UUIDs that it failed for (any one counter-example would be enough)?

Thanks for attaching the file, I'll have a look at this!

EDIT: You're not getting any other error messages, right?

mercurialmusic commented 4 years ago

At least no other errors that I see, other than a few unsupported data version 0 for [UUID] and the update fails after the error above.

This could be the issue if your stats have been running for that time and mcstats is trying to update stats for a player that "no longer exists" (because the file is in a different folder). But I suppose that isn't the case for all those UUIDs that it failed for (any one counter-example would be enough)?

I've only been using this for slightly more than a couple weeks and it seems to have started failing about 10 days ago. I wonder if clearing all player data from the Minecraft Stats files before running the update would work? Is there an easy way to do that, e.g. adding it to the script before it runs the update command? Would that have any nasty effects?

pdinklag commented 4 years ago

I wonder if clearing all player data from the Minecraft Stats files before running the update would work? Is there an easy way to do that, e.g. adding it to the script before it runs the update command? Would that have any nasty effects?

You could delete (or rename) the data directory created by Minecraft Stats. If it doesn't exist, it practically does an update from scratch. The only nasty effect is that skins of active players have to be re-downloaded, which may take a while, and that any events are gone if you created any. Apart from that, all player data is always pulled from Minecraft, so nothing is gone per se.

Would be cool to know if that works. I suspect that things fail because something changed in the file system. I'll try to find a way to reproduce this once I find the time, but I'm a bit limited these days unfortunately.

mercurialmusic commented 4 years ago

Yes, thank you, that does seem to be working for now! I added rm -r data to the script and now run it only once an hour at a time that generally avoids restarts, and it's working well.