-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
70 lines (58 loc) · 2.36 KB
/
index.js
File metadata and controls
70 lines (58 loc) · 2.36 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { parse, simplify } from 'https://raw.githubusercontent.com/mcbobby123/nbt-parser/master/index.ts';
const queue = [];
const seen = new Set();
const key = Deno.readTextFileSync('./key.txt');
const queueUp = uuid => {
if(seen.has(uuid)) return;
queue.push(uuid);
seen.add(uuid);
}
queueUp('6f01c975fe6f4b188fbbc128242d64e7');
let lastNew = Date.now();
const inventories = ['item_stash', 'inv_armor', 'inv_contents', 'inv_enderchest', 'mystic_well_item','mystic_well_pants'];
const rate = 2; // players per second
const result = {};
const save = () => Deno.writeTextFileSync('./mystics.json', JSON.stringify(result, null, 2));
const saveLoop = setInterval(save, 60e3);
const processInv = inv => {
if(!inv) return;
const items = simplify(parse(new Uint8Array(inv.data))).i;
for(const item of items){
const enchantLores = item?.tag?.display?.Lore?.join('\n')?.split('\n\n')?.map(l => l.split('\n'))?.slice(1);
const enchants = item?.tag?.ExtraAttributes?.CustomEnchants;
if(!enchantLores || !enchants) continue;
for(let i = 0; i < enchants.length; i++){
const level = enchants[i].Level;
const version = enchants[i].Version || 0;
const key = enchants[i].Key;
if(result[key]?.[version]?.[level]) continue;
const description = enchantLores[i];
if(!result[key]) result[key] = {};
if(!result[key][version]) result[key][version] = {};
result[key][version][level] = description;
lastNew = Date.now();
console.log(`Found ${key} tier: ${level} version: ${version}`)
}
}
}
while(lastNew + 300e5 > Date.now()){
if(queue.length) {
(async()=>{
const current = queue.pop();
console.log(`searching ${current}`)
const { success, player } = await fetch(`https://api.hypixel.net/player?key=${key}&uuid=${current}`).then(r => r.json());
if(!success) return;
const pit = player?.stats?.Pit?.profile;
if(!pit) return;
inventories.forEach(inv => processInv(pit[inv]));
if(pit.prestiges?.length >= 10){
const { success, records } = await fetch(`https://api.hypixel.net/friends?key=${key}&uuid=${current}`).then(r => r.json());
if(!success) return;
records.map(r => r.uuidReceiver !== current ? r.uuidReceiver : r.uuidSender).forEach(queueUp);
}
})();
}
await new Promise(r => setTimeout(r, 1e3 / rate))
}
clearInterval(saveLoop);
save();