Package Exports
- skyhelper-networth
- skyhelper-networth/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (skyhelper-networth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
SkyHelper-Networth
SkyHelper's Networth Calculation as a Node.js module to calculate a player's SkyBlock networth by using their profile data provided by the Hypixel API.
Installation
npm install skyhelper-networth
Core Concepts
📦 Key Classes
ProfileNetworthCalculator
: Handles networth calculation for player's profile.GenericItemNetworthCalculator
: Calculates networth for individual items.NetworthManager
: Central class for managing networth calculations (singleton).UpdateManager
: Manages periodic updates for items, prices and the networth package itself (singleton).
📄 Core Interfaces
NetworthOptions
: Configuration for networth calculationsNetworthResult
: Result structure for networth calculationsItem
: Detailed representation of an in-game item
Quick Start
import { ProfileNetworthCalculator } from 'skyhelper-networth';
// Prepare input data
const profile = // https://api.hypixel.net/#tag/SkyBlock/paths/~1v2~1skyblock~1profile/get - profile.members[uuid]
const museumData = // https://api.hypixel.net/v2/skyblock/museum - museum.members[uuid]
const bankBalance = profile.banking.balance;
const profileData = profile.members[uid];
// Initialize the NetworthManager
const networthManager = new ProfileNetworthCalculator(profileData, museumData, bankBalance);
// Calculate profile networth
const networth = await networthManager.getNetworth();
console.log(networth);
The data structure of the output from getNetworth
can be found at Type Definitions section.
Class Documentation
📊 ProfileNetworthCalculator
Handles player profile calculations
Creation
new ProfileNetworthCalculator(profileData: object, museumData?: object, bankBalance?: number)
fromPreParsed(profileData: object, items: Items, bankBalance: number): ProfileNetworthCalculator;
Calculation Methods
getNetworth(options?: NetworthOptions): Promise<NetworthResult>
getNonCosmeticNetworth(options?: NetworthOptions): Promise<NetworthResult>
Example Usage
const networthManager = new ProfileNetworthCalculator(profileData, museumData, bankBalance);
const networth = await networthManager.getNonCosmeticNetworth({ prices: customPrices });
console.log(networth.types.inventory.total); // Total value of player's inventory
const nonCosmeticNetworth = await networthManager.getNonCosmeticNetworth();
console.log(nonCosmeticNetworth.networth); // Total value of player's non-cosmetic items
🔍 ItemNetworthCalculator
Item-specific calculation
Constructor
new ItemNetworthCalculator(item: object)
Methods
getNetworth(options?: NetworthOptions): Promise<Item>
getNonCosmeticNetworth(options?: NetworthOptions): Promise<Item>
Example
const itemCalculator = new ItemNetworthCalculator(item);
const itemValue = await itemCalculator.getNetworth({ prices: newPrices });
console.log(itemValue.price); // Item's calculated value
🧰 NetworthManager
Manages global configuration and item caching
Constructor
new NetworthManager(options?: NetworthManagerOptions)
Configuration Options
Each option can be set and obtained using the corresponding set
and get
methods.
Method | Property | Type | Default | Description |
---|---|---|---|---|
setCachePrices() |
cachePrices |
boolean |
true |
Whether to cache the prices for time after fetching them or fetch them every time. |
setPricesRetries() |
cachePricesTime |
number |
300000 (5m) |
The amount of time to cache the prices in milliseconds. |
setCachePricesTime() |
pricesRetries |
number |
3 |
The amount of retries to fetch the prices when failing to fetch them. |
setItemsRetries() |
itemsRetries |
number |
3 |
The amount of retries to fetch the items when failing to fetch them. |
setItemsInterval() |
itemsInterval |
number |
43200000 (12h) |
The interval to fetch the items from the Hypixel API in milliseconds. |
setOnlyNetworth() |
onlyNetworth |
boolean |
false |
Whether to only return the total networth or the items as well. |
setSortItems() |
sortItems |
boolean |
true |
Whether to sort items by price. |
setStackItems() |
stackItems |
boolean |
true |
Whether to stack items with the same name and price. |
setIncludeItemData() |
includeItemData |
boolean |
false |
Whether to include the item data as a property in the item object. |
Additional Features
Price Management
import { getPrices } from 'skyhelper-networth';
// Get latest prices with caching
const prices = await getPrices(true);
// Manual cache refresh
networthManager.setCachePrices(false);
Update Management
const updateManager = new UpdateManager();
updateManager.setInterval(300000); // Check updates every 5m
updateManager.disable(); // Stop automatic checks
Type Definitions
📜 NetworthOptions
Property | Type | Default | Description |
---|---|---|---|
prices |
object |
Prices |
A prices object that includes item prices. |
cachePrices |
boolean |
true |
Whether to cache the prices for time after fetching them or fetch them every time. |
pricesRetries |
number |
3 |
The amount of retries to fetch the prices when failing to fetch them. |
onlyNetworth |
boolean |
false |
Whether to only return the total networth or the items as well. |
includeItemData |
boolean |
false |
Whether to include the item data as a property in the item object. |
sortItems |
boolean |
true |
Whether to sort items by price. |
stackItems |
boolean |
true |
Whether to stack items with the same name and price. |
📜 NetworthResult
interface NetworthResult {
networth: number;
unsoulboundNetworth: number;
noInventory: boolean;
isNonCosmetic: boolean;
personalBank: number;
purse: number;
bank: number;
types: Record<InventoryType, Inventory>;
}
type InventoryType = 'armor' | 'equipment' | 'wardrobe' | ...;
type Inventory = {
total: number;
unsoulboundTotal: number;
items: Array<Item>;
};
📦 Item Structure
interface Item {
name: string;
price: number;
soulbound: boolean;
cosmetic: boolean;
calculation: Calculation[];
// ... additional properties
}
Contribution
Contributions welcome! Please follow the project's code style and add tests for new features.
git clone https://github.com/Altpapier/SkyHelper-Networth.git
npm install
npm test