aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/cleaners/skyblock/inventory.js62
-rw-r--r--build/cleaners/skyblock/member.js4
-rw-r--r--package-lock.json106
-rw-r--r--package.json3
-rw-r--r--src/cleaners/skyblock/inventory.ts41
-rw-r--r--src/cleaners/skyblock/member.ts12
6 files changed, 221 insertions, 7 deletions
diff --git a/build/cleaners/skyblock/inventory.js b/build/cleaners/skyblock/inventory.js
new file mode 100644
index 0000000..1927add
--- /dev/null
+++ b/build/cleaners/skyblock/inventory.js
@@ -0,0 +1,62 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.cleanInventories = exports.INVENTORIES = exports.cleanInventory = void 0;
+const nbt = __importStar(require("prismarine-nbt"));
+function base64decode(base64) {
+ return Buffer.from(base64, 'base64');
+}
+function cleanInventory(encodedNbt) {
+ return new Promise(resolve => {
+ const base64Data = base64decode(encodedNbt);
+ nbt.parse(base64Data, false, (err, value) => {
+ const simplifiedNbt = nbt.simplify(value);
+ // .i because hypixel decided to do that
+ resolve(simplifiedNbt.i);
+ });
+ });
+}
+exports.cleanInventory = cleanInventory;
+exports.INVENTORIES = {
+ armor: 'inv_armor',
+ inventory: 'inv_contents',
+ ender_chest: 'ender_chest_contents',
+ talisman_bag: 'talisman_bag',
+ potion_bag: 'potion_bag',
+ fishing_bag: 'fishing_bag',
+ quiver: 'quiver',
+ trick_or_treat_bag: 'candy_inventory_contents',
+ wardrobe: 'wardrobe_contents'
+};
+async function cleanInventories(data) {
+ var _a;
+ const cleanInventories = {};
+ for (const cleanInventoryName in exports.INVENTORIES) {
+ const hypixelInventoryName = exports.INVENTORIES[cleanInventoryName];
+ const encodedInventoryContents = (_a = data[hypixelInventoryName]) === null || _a === void 0 ? void 0 : _a.data;
+ let inventoryContents;
+ if (encodedInventoryContents)
+ inventoryContents = await cleanInventory(encodedInventoryContents);
+ cleanInventories[cleanInventoryName] = inventoryContents;
+ }
+ return cleanInventories;
+}
+exports.cleanInventories = cleanInventories;
diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js
index 736593a..74da48a 100644
--- a/build/cleaners/skyblock/member.js
+++ b/build/cleaners/skyblock/member.js
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanSkyBlockProfileMemberResponse = void 0;
const cached = __importStar(require("../../hypixelCached"));
const fairysouls_1 = require("./fairysouls");
+const inventory_1 = require("./inventory");
const minions_1 = require("./minions");
const stats_1 = require("./stats");
/** Cleans up a member (from skyblock/profile) */
@@ -36,7 +37,8 @@ async function cleanSkyBlockProfileMemberResponse(member, included = null) {
// last_death: ??? idk how this is formatted,
stats: statsIncluded ? stats_1.cleanProfileStats(member === null || member === void 0 ? void 0 : member.stats) : undefined,
minions: statsIncluded ? minions_1.cleanMinions(member) : undefined,
- fairy_souls: statsIncluded ? fairysouls_1.cleanFairySouls(member) : undefined
+ fairy_souls: statsIncluded ? fairysouls_1.cleanFairySouls(member) : undefined,
+ inventories: statsIncluded ? await inventory_1.cleanInventories(member) : undefined,
};
}
exports.cleanSkyBlockProfileMemberResponse = cleanSkyBlockProfileMemberResponse;
diff --git a/package-lock.json b/package-lock.json
index acc2a15..437213a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,6 +13,17 @@
"negotiator": "0.6.2"
}
},
+ "ajv": {
+ "version": "6.12.6",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
+ "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
+ "requires": {
+ "fast-deep-equal": "^3.1.1",
+ "fast-json-stable-stringify": "^2.0.0",
+ "json-schema-traverse": "^0.4.1",
+ "uri-js": "^4.2.2"
+ }
+ },
"array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
@@ -149,6 +160,16 @@
"vary": "~1.1.2"
}
},
+ "fast-deep-equal": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
+ },
+ "fast-json-stable-stringify": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
+ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
+ },
"finalhandler": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
@@ -203,6 +224,21 @@
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
},
+ "json-schema-traverse": {
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
+ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
+ },
+ "lodash.get": {
+ "version": "4.4.2",
+ "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
+ "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
+ },
+ "lodash.reduce": {
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
+ "integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
+ },
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -277,6 +313,33 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
+ "prismarine-nbt": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-1.4.0.tgz",
+ "integrity": "sha512-CBv6I7rXN6E55AjCg5emA78kgssqWvZeTj1NdG24ZjhZ0YsAKIaopMLek81H8uv/rSz6BbhOSjuSMpHSv9ipyQ==",
+ "requires": {
+ "protodef": "^1.7.0"
+ }
+ },
+ "protodef": {
+ "version": "1.9.0",
+ "resolved": "https://registry.npmjs.org/protodef/-/protodef-1.9.0.tgz",
+ "integrity": "sha512-RZZtHOT8Q8AaKEbKsPlndivoPOOjm+ddHFVwooBMNTw8XMN4cRo4tKTNCyXf12+IIkzkPDgbAwKjLHCJXYI3HQ==",
+ "requires": {
+ "lodash.get": "^4.4.2",
+ "lodash.reduce": "^4.6.0",
+ "protodef-validator": "^1.2.2",
+ "readable-stream": "^3.0.3"
+ }
+ },
+ "protodef-validator": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.2.3.tgz",
+ "integrity": "sha512-dMcSMYRh8s0z0iQN0PLVlXwJOgN8cgBuM1uWzhMjkLdpKCOASwp+h7wHnTigBTRVhGLywykcb3EKiGSsXX4vvA==",
+ "requires": {
+ "ajv": "^6.5.4"
+ }
+ },
"proxy-addr": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
@@ -286,6 +349,11 @@
"ipaddr.js": "1.9.1"
}
},
+ "punycode": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
+ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
+ },
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
@@ -307,6 +375,16 @@
"unpipe": "1.0.0"
}
},
+ "readable-stream": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
+ "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+ "requires": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ }
+ },
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
@@ -365,6 +443,21 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
},
+ "string_decoder": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
+ "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
+ "requires": {
+ "safe-buffer": "~5.2.0"
+ },
+ "dependencies": {
+ "safe-buffer": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
+ }
+ }
+ },
"toidentifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
@@ -384,6 +477,19 @@
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
},
+ "uri-js": {
+ "version": "4.4.1",
+ "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
+ "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
+ "requires": {
+ "punycode": "^2.1.0"
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ },
"utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
diff --git a/package.json b/package.json
index fa8155a..c39cfea 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,8 @@
"dependencies": {
"express": "^4.17.1",
"node-cache": "^5.1.2",
- "node-fetch": "^2.6.1"
+ "node-fetch": "^2.6.1",
+ "prismarine-nbt": "^1.4.0"
},
"devDependencies": {
"dotenv": "^8.2.0"
diff --git a/src/cleaners/skyblock/inventory.ts b/src/cleaners/skyblock/inventory.ts
new file mode 100644
index 0000000..ac36d88
--- /dev/null
+++ b/src/cleaners/skyblock/inventory.ts
@@ -0,0 +1,41 @@
+import * as nbt from 'prismarine-nbt'
+
+function base64decode(base64: string): Buffer {
+ return Buffer.from(base64, 'base64')
+}
+
+export function cleanInventory(encodedNbt: string): Promise<any> {
+ return new Promise(resolve => {
+ const base64Data = base64decode(encodedNbt)
+ nbt.parse(base64Data, false, (err, value) => {
+ const simplifiedNbt = nbt.simplify(value)
+ // .i because hypixel decided to do that
+ resolve(simplifiedNbt.i)
+ })
+ })
+}
+
+export const INVENTORIES = {
+ armor: 'inv_armor',
+ inventory: 'inv_contents',
+ ender_chest: 'ender_chest_contents',
+ talisman_bag: 'talisman_bag',
+ potion_bag: 'potion_bag',
+ fishing_bag: 'fishing_bag',
+ quiver: 'quiver',
+ trick_or_treat_bag: 'candy_inventory_contents',
+ wardrobe: 'wardrobe_contents'
+}
+
+export async function cleanInventories(data: any): Promise<typeof INVENTORIES> {
+ const cleanInventories: any = {}
+ for (const cleanInventoryName in INVENTORIES) {
+ const hypixelInventoryName = INVENTORIES[cleanInventoryName]
+ const encodedInventoryContents = data[hypixelInventoryName]?.data
+ let inventoryContents
+ if (encodedInventoryContents)
+ inventoryContents = await cleanInventory(encodedInventoryContents)
+ cleanInventories[cleanInventoryName] = inventoryContents
+ }
+ return cleanInventories
+} \ No newline at end of file
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index 8695b3f..febb9c2 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -1,9 +1,11 @@
import { Included } from '../../hypixel'
import * as cached from '../../hypixelCached'
import { CleanPlayer } from '../player'
-import { Bank, cleanBank } from './bank'
+import { Bank } from './bank'
import { cleanFairySouls, FairySouls } from './fairysouls'
+import { cleanInventories, INVENTORIES } from './inventory'
import { CleanMinion, cleanMinions } from './minions'
+import { CleanFullProfile } from './profile'
import { CleanProfileStats, cleanProfileStats } from './stats'
export interface CleanBasicMember {
@@ -18,6 +20,7 @@ export interface CleanMember extends CleanBasicMember {
minions?: CleanMinion[]
bank?: Bank
fairy_souls?: FairySouls
+ inventories: typeof INVENTORIES
}
@@ -33,7 +36,8 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu
// last_death: ??? idk how this is formatted,
stats: statsIncluded ? cleanProfileStats(member?.stats) : undefined,
minions: statsIncluded ? cleanMinions(member) : undefined,
- fairy_souls: statsIncluded ? cleanFairySouls(member) : undefined
+ fairy_souls: statsIncluded ? cleanFairySouls(member) : undefined,
+ inventories: statsIncluded ? await cleanInventories(member) : undefined,
}
}
@@ -48,7 +52,5 @@ export interface CleanMemberProfilePlayer extends CleanPlayer {
export interface CleanMemberProfile {
member: CleanMemberProfilePlayer
- profile: {
-
- }
+ profile: CleanFullProfile
}