Python script to parse player statistics from Minecraft's stats folder and generate a leaderboard.
- Reads
.jsonstat files from the specified directory. - Extracts a given statistic key (e.g.,
mined:stone). - Detects the value type (time, distance, etc.) and formats it.
- Maps each player's UUID to their username using
usercache.json. - Sorts players by their stat values in descending order.
- Outputs two files:
rating.json: list of players with results and ranking.total.json: total value across all players.
If you are unsure of the exact stat names, use the --list flag to scan your files and generate an available.json helper file:
python main.py --stats ./stats --usercache ./usercache.json --listGenerate leaderboards:
# Parse specific stats (use colon for path, comma for list)
python main.py --stats ./stats --usercache ./usercache.json --params "custom:jump,used:golden_carrot"
# Collect ALL discovered statistics from all players
python main.py --stats ./stats --usercache ./usercache.json --all --exclude-zeroCommand arguments:
| Parameter | Description | Example |
|---|---|---|
| --stats | Path the world stats/ directory | --stats ~/server/world/stats |
| --usercache | Path to usercache.json | --usercache ~/server/usercache.json |
| --params | Stats to collect | --params used:apple,custom:play_time |
| --exclude-zero | Exclude players with "result": 0 |
--exclude-zero |
| --list | Generate available.json and exit |
--list |
| --all | Process every available stat found in files | --all |
| --name | Custom name for the output folder (default: results) | --name my_leaderboard |
To specify the correct statistic path for the --params argument, follow these steps:
-
Run the script with --list
-
Open the generated
available.json. -
Locate the category and parameter. Example: If you see
"minecraft:used": ["minecraft:diamond_pickaxe"], your param is used:diamond_pickaxe.
- Python 3.10+