Permalink
Browse files

more detailed player inspect + list multiple

List all the main player information:
position, dimension, spawnposition
health, foodLevel, Level. XP, gametype

If a players directory is given, all players in there are listed.

If a file is given, list only this player.

You can also give a directory and a player name:

python playerInspect.py [ file | dir [playername] ]
  • Loading branch information...
1 parent 8dd5495 commit d6b2cf3a0dda4c3489109288a353697cc9a87929 @JonnyJD JonnyJD committed Mar 26, 2012
Showing with 40 additions and 10 deletions.
  1. +40 −10 contrib/playerInspect.py
@@ -11,14 +11,44 @@
from overviewer_core.nbt import load
from overviewer_core import items
-print "Inspecting %s" % sys.argv[1]
-
-data = load(sys.argv[1])[1]
-
-
-print "Position: %r" % data['Pos']
-print "Health: %s" % data['Health']
-print "Inventory: %d items" % len(data['Inventory'])
-for item in data['Inventory']:
- print " %-3d %s" % (item['Count'], items.id2item(item['id']))
+def print_player(data, sub_entry=False):
+
+ indent = ""
+ if sub_entry:
+ indent = "\t"
+ print "%sPosition:\t%i, %i, %i\t(dim: %i)" % (indent,
+ data['Pos'][0], data['Pos'][1], data['Pos'][2], data['Dimension'])
+ try:
+ print "%sSpawn:\t\t%i, %i, %i" % (indent,
+ data['SpawnX'], data['SpawnY'], data['SpawnZ'])
+ except KeyError:
+ pass
+ print "%sHealth:\t%i\tLevel:\t\t%i\t\tGameType:\t%i" % (indent,
+ data['Health'], data['XpLevel'], data['playerGameType'])
+ print "%sFood:\t%i\tTotal XP:\t%i" % (indent,
+ data['foodLevel'], data['XpTotal'])
+ print "%sInventory: %d items" % (indent, len(data['Inventory']))
+ if not sub_entry:
+ for item in data['Inventory']:
+ print " %-3d %s" % (item['Count'], items.id2item(item['id']))
+
+if __name__ == '__main__':
+ print "Inspecting %s" % sys.argv[1]
+
+ if os.path.isdir(sys.argv[1]):
+ directory = sys.argv[1]
+ if len(sys.argv) > 2:
+ selected_player = sys.argv[2]
+ else:
+ selected_player = None
+ for player_file in os.listdir(directory):
+ player = player_file.split(".")[0]
+ if selected_player in [None, player]:
+ print
+ print player
+ data = load(os.path.join(directory, player_file))[1]
+ print_player(data, sub_entry=(selected_player is None))
+ else:
+ data = load(sys.argv[1])[1]
+ print_player(data)

0 comments on commit d6b2cf3

Please sign in to comment.