@zikeji/hypixel
Advanced tools
Comparing version 1.16.0 to 1.17.0
@@ -6,2 +6,37 @@ # Changelog | ||
## [1.17.0](https://github.com/zikeji/node-hypixel/compare/v1.16.0...v1.17.0) (2020-11-17) | ||
### Features | ||
* **api:** completely explore and type out /player endpoint and update testing to validate ([9e674bd](https://github.com/zikeji/node-hypixel/commit/9e674bdf9167cf0f3997f92445bcd734a0472e64)) | ||
* **api:** expand typing to the player.stats.Bedwars object ([4a469af](https://github.com/zikeji/node-hypixel/commit/4a469af75a4124a9bf352e2558c6067b3a832d9b)) | ||
* **api:** update player schema to include more social links ([2d43066](https://github.com/zikeji/node-hypixel/commit/2d430667ef3a8dc1652384609764784b345fc404)) | ||
* **helpers:** add Bedwars helper for level / prestige info ([485c010](https://github.com/zikeji/node-hypixel/commit/485c0105503e8fd2072772beb1ba4c56e9ff7310)) | ||
* **helpers:** add NetworkLevel helper and add licensing information for the work ([21e2342](https://github.com/zikeji/node-hypixel/commit/21e2342aad614b806a15a536d5ca1c0aef38d77c)) | ||
* **helpers:** revise skyblock item data into minecraft item data and added usage example for pit ([398f3a9](https://github.com/zikeji/node-hypixel/commit/398f3a9029d91e2ff28fcc9a1117bd3fef721d33)) | ||
### Bug Fixes | ||
* **helpers:** add rank and plus color as they are separate ([c61aba0](https://github.com/zikeji/node-hypixel/commit/c61aba0c1ec0b2becb019d366d86045182f18b25)) | ||
* **package:** removed redundant line ([f21ef7f](https://github.com/zikeji/node-hypixel/commit/f21ef7fa4a636ade7af17ab644d4fd5b105af274)) | ||
### Code Refactoring | ||
* **helpers:** remove NonNullable due to earlier changes making it redundant ([648e476](https://github.com/zikeji/node-hypixel/commit/648e476814fe18cc4248514a9023d61ddcffcb5e)) | ||
### Documentation | ||
* **helpers:** add description for network level helper. ([e1508a7](https://github.com/zikeji/node-hypixel/commit/e1508a785394ad0603058dde0dd80fb37cc8a814)) | ||
* **helpers:** add documentation for Bedwars helper ([90f0408](https://github.com/zikeji/node-hypixel/commit/90f0408c72a355572654b95e5efea32cebda7af1)) | ||
* **helpers:** add documentation for network level ([c9f2cdd](https://github.com/zikeji/node-hypixel/commit/c9f2cdd50b0d7fdb0f929026d4e0642d3b9a9132)) | ||
### Tests | ||
* **helpers:** add bedwarslevelinfo test and trim fat ([2883d57](https://github.com/zikeji/node-hypixel/commit/2883d57b2bb5f2701d2c83725e06cb43b2994dd0)) | ||
## [1.16.0](https://github.com/zikeji/node-hypixel/compare/v1.15.0...v1.16.0) (2020-11-14) | ||
@@ -8,0 +43,0 @@ |
@@ -46,11 +46,20 @@ import { Components } from "../types/api"; | ||
/** | ||
* If they have a custom color for their profile. | ||
* If they have a custom color for their rank. | ||
* **Note:** this can be set when the player isn't MVP++. If you want to use this value, be sure to check if the rank is SUPERSTAR (MVP++). | ||
*/ | ||
customColor?: MinecraftFormatting; | ||
customRankColor?: MinecraftFormatting; | ||
/** | ||
* Same as customColor, but the hex version of the color. | ||
* Same as customRankColor, but the hex version of the color. | ||
*/ | ||
customColorHex?: MinecraftColorAsHex; | ||
customRankColorHex?: MinecraftColorAsHex; | ||
/** | ||
* If they have a custom color for the pluses in their rank (++). | ||
* **Note:** this can be set when the player isn't MVP++. If you want to use this value, be sure to check if the rank is SUPERSTAR (MVP++). | ||
*/ | ||
customPlusColor?: MinecraftFormatting; | ||
/** | ||
* Same as customPlusColor, but the hex version of the color. | ||
*/ | ||
customPlusColorHex?: MinecraftColorAsHex; | ||
/** | ||
* Whether or not this is a staff only rank. | ||
@@ -57,0 +66,0 @@ */ |
@@ -193,12 +193,18 @@ "use strict"; | ||
} | ||
if (player.rankPlusColor) { | ||
const customColor = MinecraftFormatting_1.MinecraftFormatting[player.rankPlusColor]; | ||
if (customColor) { | ||
out.customColor = customColor; | ||
out.customColorHex = | ||
MinecraftFormatting_1.MinecraftColorAsHex[customColor]; | ||
if (out.priority === PlayerRanks.SUPERSTAR) { | ||
out.prefix = `§6[MVP${customColor}++§6]`; | ||
} | ||
if (player.monthlyRankColor || player.rankPlusColor) { | ||
const customRankColor = MinecraftFormatting_1.MinecraftFormatting[player.monthlyRankColor]; | ||
const customPlusColor = MinecraftFormatting_1.MinecraftFormatting[player.rankPlusColor]; | ||
if (customRankColor) { | ||
out.customRankColor = customRankColor; | ||
out.customRankColorHex = | ||
MinecraftFormatting_1.MinecraftColorAsHex[customRankColor]; | ||
} | ||
if (customPlusColor) { | ||
out.customPlusColor = customPlusColor; | ||
out.customPlusColorHex = | ||
MinecraftFormatting_1.MinecraftColorAsHex[customPlusColor]; | ||
} | ||
if (out.priority === PlayerRanks.SUPERSTAR) { | ||
out.prefix = `${customRankColor !== null && customRankColor !== void 0 ? customRankColor : "§6"}[MVP${customPlusColor !== null && customPlusColor !== void 0 ? customPlusColor : "§c"}++${customRankColor !== null && customRankColor !== void 0 ? customRankColor : "§6"}]`; | ||
} | ||
} | ||
@@ -205,0 +211,0 @@ return out; |
@@ -1,112 +0,3 @@ | ||
/// <reference types="node" /> | ||
import { Components } from "../types/api"; | ||
/** | ||
* Array of inventory slots. If that slot is empty it will be null, otherwise it will be an object containing the data. | ||
*/ | ||
export declare type NBTInventory = (NBTInventoryItem | null)[]; | ||
export interface NBTInventoryItem { | ||
/** Minecraft Item ID of this item. */ | ||
id: number; | ||
/** Amount of items in this inventory slot. */ | ||
Count: number; | ||
Damage: number; | ||
/** NBT tag data for this item. */ | ||
tag: NBTTag; | ||
} | ||
export interface NBTTag { | ||
Unbreakable?: number; | ||
HideFlags: number; | ||
display: NBTDisplay; | ||
ExtraAttributes?: NBTExtraAttributes; | ||
ench?: NBTEnch[]; | ||
SkullOwner?: NBTSkullOwner; | ||
CustomPotionEffects?: NBTCustomPotionEffect[]; | ||
} | ||
export interface NBTDisplay { | ||
Lore: string[]; | ||
Name: string; | ||
color?: number; | ||
} | ||
export interface NBTExtraAttributes { | ||
[key: string]: string | number | number[] | { | ||
[name: string]: number; | ||
} | NBTExtraAttributesPotionEffect[] | NBTInventory | undefined; | ||
id: string; | ||
uuid?: string; | ||
timestamp?: string; | ||
originTag?: string; | ||
modifier?: string; | ||
color?: string; | ||
anvil_uses?: number; | ||
/** | ||
* Each key is an enchantment type and the level. e.g. "telekinesis" or "impaling" | ||
*/ | ||
enchantments: { | ||
[name: string]: number; | ||
}; | ||
hot_potato_count?: number; | ||
rarity_upgrades?: number; | ||
dungeon_item_level?: number; | ||
backpack_color?: string; | ||
runes?: { | ||
[name: string]: number; | ||
}; | ||
potion_level?: number; | ||
potion?: string; | ||
effects?: NBTExtraAttributesPotionEffect[]; | ||
potion_type?: string; | ||
splash?: number; | ||
potion_name?: string; | ||
/** The contents of the backpack. */ | ||
small_backpack_data?: NBTInventory; | ||
/** The contents of the backpack. */ | ||
medium_backpack_data?: NBTInventory; | ||
/** The contents of the backpack. */ | ||
large_backpack_data?: NBTInventory; | ||
/** The contents of the backpack. */ | ||
greater_backpack_data?: NBTInventory; | ||
/** The contents of the backpack. */ | ||
jumbo_backpack_data?: NBTInventory; | ||
/** The contents of the cake bag. */ | ||
new_year_cake_bag_data?: NBTInventory; | ||
} | ||
export interface NBTExtraAttributesPotionEffect { | ||
level: number; | ||
effect: string; | ||
duration_ticks: number; | ||
} | ||
export interface NBTEnch { | ||
id: number; | ||
lvl: number; | ||
} | ||
export interface NBTSkullOwner { | ||
Id: string; | ||
Properties: { | ||
timestamp?: number; | ||
profileId?: number; | ||
profileName?: number; | ||
signatureRequired?: boolean; | ||
textures: { | ||
SKIN: { | ||
/** Minecraft CDN link to the texture. */ | ||
url: string; | ||
}; | ||
}; | ||
} | null; | ||
/** | ||
* If the original textures array had more than 1 element, the first will appear under Properties and the remainder will appear in this array below. | ||
*/ | ||
ExtraProperties?: NonNullable<NBTSkullOwner["Properties"]>[]; | ||
} | ||
export interface NBTCustomPotionEffect { | ||
Ambient: number; | ||
Duration: number; | ||
Id: number; | ||
Amplifier: number; | ||
} | ||
/** | ||
* This helper will transform NBT data into a typed object using prismarine-nbt. It will also transform any backpacks/bags with item data so you can explore those as well. | ||
* @param value A Base64 item data string, NBT byte array, or buffer. | ||
*/ | ||
export declare function transformSkyBlockItemData(value: number[] | string | Buffer): Promise<NBTInventory>; | ||
import { NBTInventory } from "./TransformItemData"; | ||
export interface SkyBlockProfileTransformedInventories { | ||
@@ -113,0 +4,0 @@ inv_armor: NBTInventory; |
"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; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -31,67 +12,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transformSkyBlockProfileMemberInventories = exports.transformSkyBlockItemData = void 0; | ||
/** | ||
* This helper will transform NBT data into a typed object using prismarine-nbt. It will also transform any backpacks/bags with item data so you can explore those as well. | ||
* @param value A Base64 item data string, NBT byte array, or buffer. | ||
*/ | ||
function transformSkyBlockItemData(value) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let nbt; | ||
try { | ||
nbt = yield Promise.resolve().then(() => __importStar(require("prismarine-nbt"))); | ||
} | ||
catch (e) { | ||
/* istanbul ignore next */ | ||
throw new Error("prismarine-nbt must be installed to use this helper"); | ||
} | ||
let buffer; | ||
if (Buffer.isBuffer(value)) { | ||
buffer = value; | ||
} | ||
else { | ||
buffer = Array.isArray(value) | ||
? Buffer.from(value) | ||
: Buffer.from(value, "base64"); | ||
} | ||
const rawNBT = yield new Promise((resolve, reject) => nbt.parse(buffer, (err, nbtData) => { | ||
/* istanbul ignore if */ | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(nbtData); | ||
})); | ||
const data = nbt.simplify(rawNBT.value.i); | ||
return Promise.all(data.map((item) => __awaiter(this, void 0, void 0, function* () { | ||
if (Object.entries(item).length === 0 || !item.tag.ExtraAttributes) { | ||
return null; | ||
} | ||
/* istanbul ignore else */ | ||
if (item.tag.SkullOwner) { | ||
const skullOwner = item.tag.SkullOwner; | ||
const propertiesData = skullOwner.Properties.textures.shift(); | ||
/* istanbul ignore else */ | ||
if (propertiesData) { | ||
item.tag.SkullOwner.Properties = JSON.parse(Buffer.from(propertiesData.Value, "base64").toString()); | ||
/* istanbul ignore if */ | ||
if (skullOwner.Properties.textures.length > 0) { | ||
item.tag.SkullOwner.ExtraProperties = skullOwner.Properties.textures.map(({ Value }) => JSON.parse(Buffer.from(Value, "base64").toString())); | ||
} | ||
} | ||
else { | ||
item.tag.SkullOwner.Properties = null; | ||
} | ||
} | ||
yield Promise.all(Object.keys(item.tag.ExtraAttributes).map((key) => __awaiter(this, void 0, void 0, function* () { | ||
/* istanbul ignore if */ | ||
if (!item.tag.ExtraAttributes) | ||
return; | ||
if (key.endsWith("_backpack_data") || key.endsWith("_bag_data")) { | ||
item.tag.ExtraAttributes[key] = yield transformSkyBlockItemData(item.tag.ExtraAttributes[key]); | ||
} | ||
}))); | ||
return item; | ||
}))); | ||
}); | ||
} | ||
exports.transformSkyBlockItemData = transformSkyBlockItemData; | ||
exports.transformSkyBlockProfileMemberInventories = void 0; | ||
const TransformItemData_1 = require("./TransformItemData"); | ||
const SKYBLOCK_INVENTORIES = [ | ||
@@ -118,3 +36,3 @@ "inv_armor", | ||
if (inventoryData && inventoryData.data) { | ||
transformedMember[key] = yield transformSkyBlockItemData(inventoryData.data); | ||
transformedMember[key] = yield TransformItemData_1.transformItemData(inventoryData.data); | ||
} | ||
@@ -121,0 +39,0 @@ }))); |
@@ -5,5 +5,8 @@ export * from "./Client"; | ||
export * from "./errors/RateLimitError"; | ||
export * from "./helpers/BedwarsLevelInfo"; | ||
export * from "./helpers/MinecraftFormatting"; | ||
export * from "./helpers/NetworkLevel"; | ||
export * from "./helpers/PlayerRank"; | ||
export * from "./helpers/TransformItemData"; | ||
export * from "./helpers/TransformSkyBlockItemData"; | ||
export * from "./types/api"; |
@@ -17,6 +17,9 @@ "use strict"; | ||
__exportStar(require("./errors/RateLimitError"), exports); | ||
__exportStar(require("./helpers/BedwarsLevelInfo"), exports); | ||
__exportStar(require("./helpers/MinecraftFormatting"), exports); | ||
__exportStar(require("./helpers/NetworkLevel"), exports); | ||
__exportStar(require("./helpers/PlayerRank"), exports); | ||
__exportStar(require("./helpers/TransformItemData"), exports); | ||
__exportStar(require("./helpers/TransformSkyBlockItemData"), exports); | ||
__exportStar(require("./types/api"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@zikeji/hypixel", | ||
"version": "1.16.0", | ||
"version": "1.17.0", | ||
"description": "An unopinionated async/await API wrapper for Hypixel's Public API developed in TypeScript complete with documentation, OpenAPI 3.0 spec, intellisense, typed interfaces for all API responses, rate-limit handling, a few helpers, and support for undocumented endpoints.", | ||
@@ -215,3 +215,3 @@ "main": "dist/index.js", | ||
"@mdi/svg": "^5.8.55", | ||
"@mr-hope/vuepress-types": "^1.5.5", | ||
"@mr-hope/vuepress-types": "^1.5.7", | ||
"@semantic-release/changelog": "^5.0.1", | ||
@@ -225,4 +225,4 @@ "@semantic-release/git": "^9.0.0", | ||
"@types/yargs-parser": "^15.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.7.0", | ||
"@typescript-eslint/parser": "^4.7.0", | ||
"@typescript-eslint/eslint-plugin": "^4.8.0", | ||
"@typescript-eslint/parser": "^4.8.0", | ||
"chai": "^4.2.0", | ||
@@ -235,3 +235,3 @@ "chai-as-promised": "^7.1.1", | ||
"eslint": "^7.13.0", | ||
"eslint-config-airbnb-typescript-prettier": "^3.1.0", | ||
"eslint-config-airbnb-typescript-prettier": "^4.0.0", | ||
"esm": "^3.2.25", | ||
@@ -248,3 +248,3 @@ "mocha": "^8.2.1", | ||
"rimraf": "^3.0.2", | ||
"semantic-release": "^17.1.2", | ||
"semantic-release": "^17.2.3", | ||
"stylus-svg": "^1.2.0", | ||
@@ -256,6 +256,6 @@ "swagger-ui": "^3.36.2", | ||
"typedoc-plugin-no-inherit": "^1.2.0", | ||
"typescript": "^4.0.3", | ||
"typescript": "^4.0.5", | ||
"vuepress": "^1.7.1", | ||
"vuepress-plugin-typedoc": "^0.1.1", | ||
"vuepress-theme-hope": "^1.4.7", | ||
"vuepress-theme-hope": "^1.5.7", | ||
"yaml-loader": "^0.6.0" | ||
@@ -262,0 +262,0 @@ }, |
@@ -24,6 +24,2 @@ # @zikeji/hypixel | ||
## Project Status | ||
Working on adding more helpers to make your life easier, but all other features are implemented and ready to go. | ||
## Installation | ||
@@ -52,44 +48,2 @@ | ||
## Roadmap | ||
- [x] Add rate limiting support | ||
- [x] Add cache support | ||
- [x] Add method, typing, testing, and documentation for: | ||
- [x] Boosters | ||
- [x] Find Guild | ||
- [x] Friends | ||
- [x] Game Counts | ||
- [x] Guild | ||
- [x] Key | ||
- [x] Leaderboards | ||
- [x] Player | ||
- [x] Player Count | ||
- [x] Recent Games | ||
- [x] **Resources** | ||
- [x] Achievements | ||
- [x] Challenges | ||
- [x] Quests | ||
- [x] **Guilds** | ||
- [x] Achievements | ||
- [x] Permissions | ||
- [x] **SkyBlock** | ||
- [x] Collections | ||
- [x] Skills | ||
- [x] **SkyBlock** | ||
- [x] Auction | ||
- [x] Auctions | ||
- [x] Bazaar | ||
- [x] News | ||
- [x] Profile | ||
- [x] Profiles | ||
- [x] Status | ||
- [x] Watchdog Stats | ||
- [ ] Add extended documentation, and helpers for: | ||
- [ ] Player endpoint | ||
- [ ] XP to network level | ||
- [x] Rank info helper | ||
- [ ] SkyBlock Profile endpoint | ||
- [ ] collection amounts to collection tier | ||
- [ ] skill xp to skill level | ||
## Contributing | ||
@@ -100,3 +54,6 @@ If some API result isn't documented / typed out fully, please open an issue and I can add it ASAP. Otherwise, pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. | ||
## License | ||
[MIT](https://choosealicense.com/licenses/mit/) | ||
## Licenses | ||
This projected is licensed under the MIT license. For additional details see [LICENSE](LICENSE). | ||
This library contains derivative work based on classes from the [hypixel-php](https://github.com/Plancke/hypixel-php) library. Code that is derivative work of [hypixel-php](https://github.com/Plancke/hypixel-php) will be marked as such with a header comment. See [LICENSE-HYPIXEL-PHP.md](LICENSE-HYPIXEL-PHP.md) for additional details on the original license. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
490712
92
8677
56