Last active
December 20, 2015 18:29
-
-
Save schoentoon/6176047 to your computer and use it in GitHub Desktop.
Simple python script to receive death counts of a minecraft server in json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
print "Content-Type: application/json" | |
from nbt import * # https://github.com/twoolie/NBT | |
import json | |
nbtfile = nbt.NBTFile("/complete/path/to/world/data/scoreboard.dat", 'rb') | |
deaths=dict() | |
for tag in nbtfile["data"]["PlayerScores"]: | |
if str(tag["Objective"]) == "deaths": #Assuming the objective keeping track of the deaths is called "deaths" | |
deaths[str(tag["Name"])] = int(str(tag["Score"])) | |
deaths = sorted(deaths.items(), key=lambda x:x[1]) | |
deaths.reverse() | |
print json.dumps(deaths) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment