-
Notifications
You must be signed in to change notification settings - Fork 0
/
fourints.py
executable file
·50 lines (42 loc) · 1.22 KB
/
fourints.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
46
47
48
49
50
#!/usr/bin/python3 -i
from glob import glob
from nbt import nbt
import struct
spigdir = 'spigot'
datadir = spigdir + '/worlds/world/playerdata/'
skriptdir = spigdir + '/plugins/Skript/scripts/'
def get_nbt():
players = {}
for player in glob(datadir + '*.dat'):
p = nbt.NBTFile(player, 'rb')
try:
name = p['bukkit']['lastKnownName'].value
except KeyError:
continue
uuid = player.replace(datadir, '').replace('.dat', '')
players[name] = uuid
return players
def four_ints(players):
f = ''
for player in players:
# if player != 'okarkalic': continue
uuid = players[player].replace('-', '')
ints = [uuid[i * 8 : (i + 1) * 8] for i in range(4)]
ints = [struct.unpack('>i', bytes.fromhex(i))[0] for i in ints]
array = (
'[I;'
+ str(ints[0])
+ ','
+ str(ints[1])
+ ','
+ str(ints[2])
+ ','
+ str(ints[3])
+ ']'
)
yaml = player + ': "' + array + '"'
f += yaml + '\n'
return f
if __name__ == '__main__':
with open(skriptdir + 'fourints.yml', 'w') as f:
f.write(four_ints(get_nbt()))