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

Issue updating stats #26

Closed tsiedsma closed 5 years ago

tsiedsma commented 5 years ago

Running v2 on 1.13, getting the following error. If I re-run the script over and over, it fails at different usernames in different orders and generates the same error.

failed to update skin for [redacted player name]
Traceback (most recent call last):
  File "update.py", line 239, in <module>
    'last': player['last'],
KeyError: 'last'
pdinklag commented 5 years ago

Thanks for the bug report!

Looks like the first line (failed to update skin) and the second error are unrelated, but we have to find out. Are there any messages along the lines of "no player data available for xyz"?

Since I cannot spot any immediate issue in the code, could you please try the following version of update.py? I added some more extensive debug output that maybe helps me find out what's wrong.

https://raw.githubusercontent.com/pdinklag/MinecraftStats/2bc0a4cdf50c72114a13dc11149b63d2a7e4db45/update.py

tsiedsma commented 5 years ago

Ok ,that helped.

The issue was my usercache.json had player data from fake players as a result of a misconfig with bungeecord prior to the launch of the current server. So your script failed when it tried to process a fake uuid. You should add some failure detection where it just logs users it can't process and the reason and then continues processing.

I removed the failed users from the usercache.json manually, re-ran the script and it worked great.

pdinklag commented 5 years ago

Just so I get this right, you somehow configured fake users into your user cache that don't have an actual player data file? If that's the case, good to know everything is "allright".

I agree on the failure messages and will be sure to improve on them.

tsiedsma commented 5 years ago

I think it was related to citizens from before I migrated to 1.13 and no longer use that plugin. I could be wrong. It generates a UUID and player name in the usercache, but they never actually login so there isn't a stats json file.

tsiedsma commented 5 years ago

Ok, it's doing it again which is odd because those players do not have a stats/*.json file and I removed them from the usercache.json.

no player data available for BaZar_Crystcal(68839d7b-e320-30f9-9446-083ba638ccbc)
no player data available for Dark(1593d46c-9149-4521-942f-2758cd72872c)
no player data available for Anonymous(640a5372-780b-4c2a-b7e7-8359d2f9a6a8)
no player data available for Admin Shop(c796b66c-a367-3137-a9dc-55f2befab2b9)
WARNING: no "last played" info available for player:
{'name': 'BaZar_Crystcal'}
WARNING: no "last played" info available for player:
{'name': 'Dark'}
WARNING: no "last played" info available for player:
{'name': 'Anonymous'}
WARNING: no "last played" info available for player:
{'name': 'Admin Shop'}

Those players do not exist or have never played on this server.

tsiedsma commented 5 years ago

Sorry for so many updates... I can't find any references to the other players, but Admin Shop exists as a ChestShop shop for the server to sell / buy items from players. That's the only mention of Admin Shop when I grep "Admin Shop" in the server files ...

pdinklag commented 5 years ago

Thanks for the research - I believe that nails it pretty well already. The script expects every entry in the usercache to be an actual player and attempts to get his info (skin, data) - but that isn't the case here. So I think I know what needs fixing and I'll address it soon.

I suppose the stats work fine for real players, or is everything breaking due to this?

tsiedsma commented 5 years ago

It seems to still be working.

I'd like to see a blacklist option, maybe a simple text or json formatted file where we can specify users to exclude or blacklist from processing. Then I could exclude the Admin Shop user which shows in the players list but if you click, it doesn't load anything.

I can add an Issue for that as a feature request if you like.

coldcode69 commented 5 years ago

I have made a fix for this as I was having the same issue. See my pull request.

JMDirksen commented 5 years ago

coldcode69's pull request worked for me as i had the same error on a new setup of MinecraftStats on an existing minecraft server.

pdinklag commented 5 years ago

Wasn't sure if just skipping those players was a nice solution, but no clue why it shouldn't be this easy after all. Thanks for the merge request and sorry for the delayed merge!