Skip to content

Instantly share code, notes, and snippets.

@schoentoon
Last active December 20, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schoentoon/6176047 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python
print "Content-Type: application/json"
print
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