-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
45 lines (35 loc) · 1.58 KB
/
player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from os import listdir
from nbt.nbt import NBTFile
from Item import Item
def is_scan_item(args, _item):
for _id in args.id:
for idd in _id.split(','):
if str(idd) == str(_item.material):
return True
return False
class Player:
def __init__(self, args):
self.args = args
def scan(self):
for file in listdir(self.args.world + '/playerdata/'):
nbt = NBTFile(self.args.world + '/playerdata/' + file, 'rb')
inv_items = nbt['Inventory']
ec_items = nbt['EnderItems']
if self.args.inventory and len(inv_items) != 0:
for item in inv_items:
_item = Item(item['id'].value, item['Count'].value, item['Damage'].value)
if is_scan_item(self.args, _item) and _item.count >= self.args.count:
print('Found {0}*{1} in {2}\'s inventory !'.format(
_item.count,
_item.material,
file.replace('.dat', '')
))
if self.args.enderchest and len(ec_items) != 0:
for item in ec_items:
_item = Item(item['id'].value, item['Count'].value, item['Damage'].value)
if is_scan_item(self.args, _item) and _item.count > self.args.count:
print('Found {0}*{1} in {2}\'s enderchest !'.format(
_item.count,
_item.material,
file.replace('.dat', '')
))