Skip to content
On this page

Athena.systems.inventory.manager

Interfaces

Type Aliases

ComplexSwap

Ƭ ComplexSwap: Object

Type declaration

NameType
dataplayer[]
sizeInventoryType | number
slotnumber
typeInventoryType

Defined in

server/systems/inventory/manager.ts:28


ComplexSwapReturn

Ƭ ComplexSwapReturn: Object

Type declaration

NameType
fromplayer[]
toplayer[]

Defined in

server/systems/inventory/manager.ts:29


InventoryType

Ƭ InventoryType: "inventory" | "toolbar" | "custom"

Defined in

server/systems/inventory/manager.ts:27

Functions

add

Usage

Athena.systems.inventory.manager.add<CustomData>(item, data, size?): player<CustomData>[] | undefined

Adds or stacks an item based on the quantity passed. Requires the basic version of a stored item to be added to a user. Returns undefined if the data set could not be modified to include the quantity of items necessary.

Type parameters

NameType
CustomData{}

Parameters

NameTypeDefault valueDescription
itemOmit<StoredItem<CustomData>, "slot">undefined-
dataStoredItem<CustomData>[]undefined
sizenumber | InventoryType256The maximum slot size for this item group.

Returns

player<CustomData>[] | undefined

Returns undefined or the new array of added items.

Defined in

server/systems/inventory/manager.ts:317


addQuantity

Usage

Athena.systems.inventory.manager.addQuantity(item, amount): ItemQuantityChange | undefined

Adds a quantity to a specified item. Utilizes the base item to determine maximum stack. Will return the remaining amount that was not added if a max stack size is present. Will return undefined if the base item does not exist, or if the item simply cannot have quantity changed. Recalculated weight on item if baseItem has weight present.

If you wish to modify a full item use add<Item>(...)

Parameters

NameType
itemany
amountnumber

Returns

ItemQuantityChange | undefined

Defined in

server/systems/inventory/manager.ts:161


calculateItemWeight

Usage

Athena.systems.inventory.manager.calculateItemWeight<CustomData>(baseItem, storedItem): player<CustomData>

Calculate the total weight of the item, and return the modified item with total weight.

Type parameters

NameType
CustomData{}

Parameters

NameType
baseItemBaseItem
storedItemStoredItem<CustomData>

Returns

player<CustomData>

Defined in

server/systems/inventory/manager.ts:38


clearData

Usage

Athena.systems.inventory.manager.clearData(item): any

Clears the data field of the item. Sets it to an empty object. Always returns a new item with the modified contents.

Parameters

NameType
itemany

Returns

any

Defined in

server/systems/inventory/manager.ts:273


combineAt

Usage

Athena.systems.inventory.manager.combineAt<CustomData>(fromSlot, toSlot, data): player<CustomData>[] | undefined

Combines items from two different slots into a single slot. It's like a stack method.

Type parameters

NameType
CustomData{}

Parameters

NameType
fromSlotnumber
toSlotnumber
dataStoredItem<CustomData>[]

Returns

player<CustomData>[] | undefined

Defined in

server/systems/inventory/manager.ts:541


combineAtComplex

Usage

Athena.systems.inventory.manager.combineAtComplex(from, to): ComplexSwapReturn | undefined

Parameters

NameType
fromComplexSwap
toComplexSwap

Returns

ComplexSwapReturn | undefined

Defined in

server/systems/inventory/manager.ts:593


compare

Usage

Athena.systems.inventory.manager.compare(firstItem, secondItem): boolean

Compare two items to check if they are the same version.

Parameters

NameType
firstItemStoredItem
secondItemStoredItem

Returns

boolean

Defined in

server/systems/inventory/manager.ts:929


convertFromStored

Usage

Athena.systems.inventory.manager.convertFromStored<CustomData>(data): player<player, CustomData>[]

Convert an array of stored items into full items

Type parameters

NameType
CustomData{}

Parameters

NameType
dataStoredItem<CustomData>[]

Returns

player<player, CustomData>[]

Defined in

server/systems/inventory/manager.ts:290


hasItem

Usage

Athena.systems.inventory.manager.hasItem(dataSet, dbName, quantity, version?): boolean

Check if the player has enough of an item in a given data set.

Parameters

NameTypeDefault value
dataSetStoredItem[]undefined
dbNamestringundefined
quantitynumberundefined
version?numberundefined

Returns

boolean

Defined in

server/systems/inventory/manager.ts:196


modifyItemQuantity

Usage

Athena.systems.inventory.manager.modifyItemQuantity(item, amount, isRemoving?): ItemQuantityChange

Modifies an item by adding or removing an amount.

The amount that did not get removed, or added is returned.

If the base item of the item is not found it will return undefined.

It will automatically re-calculate weight if the baseItem weight is present.

Parameters

NameTypeDefault value
itemanyundefined
amountnumberundefined
isRemoving?booleanfalse

Returns

ItemQuantityChange

Defined in

server/systems/inventory/manager.ts:69


override

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"add"
callback<CustomData>(item: Omit<StoredItem<CustomData>, "slot">, data: StoredItem<CustomData>[], size: number | InventoryType) => player<CustomData>[] | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:981

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"addQuantity"
callback(item: any, amount: number) => ItemQuantityChange | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:982

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"calculateItemWeight"
callback<CustomData>(baseItem: BaseItem, storedItem: StoredItem<CustomData>) => player<CustomData>

Returns

any

Defined in

server/systems/inventory/manager.ts:983

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"clearData"
callback(item: any) => any

Returns

any

Defined in

server/systems/inventory/manager.ts:984

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"combineAt"
callback<CustomData>(fromSlot: number, toSlot: number, data: StoredItem<CustomData>[]) => player<CustomData>[] | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:985

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"combineAtComplex"
callback(from: ComplexSwap, to: ComplexSwap) => ComplexSwapReturn | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:986

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"compare"
callback(firstItem: StoredItem, secondItem: StoredItem) => boolean

Returns

any

Defined in

server/systems/inventory/manager.ts:987

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"convertFromStored"
callback<CustomData>(data: StoredItem<CustomData>[]) => player<player, CustomData>[]

Returns

any

Defined in

server/systems/inventory/manager.ts:988

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"hasItem"
callback(dataSet: StoredItem[], dbName: string, quantity: number, version?: number) => boolean

Returns

any

Defined in

server/systems/inventory/manager.ts:989

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"modifyItemQuantity"
callback(item: any, amount: number, isRemoving?: boolean) => ItemQuantityChange

Returns

any

Defined in

server/systems/inventory/manager.ts:990

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"removeZeroQuantityItems"
callback(items: any[]) => (player | player)[]

Returns

any

Defined in

server/systems/inventory/manager.ts:991

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"setData"
callback<DataType>(item: any, data: DataType) => any

Returns

any

Defined in

server/systems/inventory/manager.ts:992

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"splitAt"
callback<CustomData>(slot: number, data: StoredItem<CustomData>[], splitCount: number, dataSize: number | InventoryType) => player<CustomData>[] | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:993

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"sub"
callback<CustomData>(item: Omit<StoredItem<CustomData>, "slot" | "data">, data: StoredItem[]) => player[] | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:994

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"subQuantity"
callback(item: any, amount: number) => ItemQuantityChange | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:995

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"swap"
callback(fromSlot: number, toSlot: number, data: StoredItem[], dataSize: number | InventoryType) => player[] | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:996

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"swapBetween"
callback(from: ComplexSwap, to: ComplexSwap) => ComplexSwapReturn | undefined

Returns

any

Defined in

server/systems/inventory/manager.ts:997

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"toggleItem"
callback(player: Player, slot: number, type: InventoryType) => Promise<boolean>

Returns

any

Defined in

server/systems/inventory/manager.ts:998

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"upsertData"
callback<DataType>(item: any, data: DataType) => any

Returns

any

Defined in

server/systems/inventory/manager.ts:999

Usage

Athena.systems.inventory.manager.override(functionName, callback): any

Used to override inventory item manager functionality

Parameters

NameType
functionName"useItem"
callback(player: Player, slot: number, type?: "inventory" | "toolbar", eventToCall: string | string[]) => any

Returns

any

Defined in

server/systems/inventory/manager.ts:1000


removeZeroQuantityItems

Usage

Athena.systems.inventory.manager.removeZeroQuantityItems(items): (player | player)[]

Remove all items with zero quantity.

Parameters

NameType
itemsany[]

Returns

(player | player)[]

Defined in

server/systems/inventory/manager.ts:126


setData

Usage

Athena.systems.inventory.manager.setData<DataType>(item, data): any

Assign data to the data field.

Always returns a new item with the modified contents.

Type parameters

NameType
DataType{}

Parameters

NameType
itemany
dataDataType

Returns

any

Defined in

server/systems/inventory/manager.ts:249


splitAt

Usage

Athena.systems.inventory.manager.splitAt<CustomData>(slot, data, splitCount, dataSize?): player<CustomData>[] | undefined

Split an item into a new item given the slot number, and a split size.

Type parameters

NameType
CustomData{}

Parameters

NameType
slotnumber
dataStoredItem<CustomData>[]
splitCountnumber
dataSizenumber | InventoryType

Returns

player<CustomData>[] | undefined

Defined in

server/systems/inventory/manager.ts:475


sub

Usage

Athena.systems.inventory.manager.sub<CustomData>(item, data): player[] | undefined

Subtract an item quantity from a data set.

Type parameters

NameType
CustomData{}

Parameters

NameType
itemOmit<StoredItem<CustomData>, "slot" | "data">
dataStoredItem[]

Returns

player[] | undefined

Defined in

server/systems/inventory/manager.ts:416


subQuantity

Usage

Athena.systems.inventory.manager.subQuantity(item, amount): ItemQuantityChange | undefined

Removes a quantity from a specified item. Will return the remaining amount that was not removed if amount exceeds available in stack size. Will return undefined if the base item does not exist, or if the item simply cannot have quantity changed.

If you wish to modify a full item use remove<Item>(...)

Parameters

NameType
itemany
amountnumber

Returns

ItemQuantityChange | undefined

Defined in

server/systems/inventory/manager.ts:180


swap

Usage

Athena.systems.inventory.manager.swap(fromSlot, toSlot, data, dataSize?): player[] | undefined

Swaps slots between a single data set.

Parameters

NameType
fromSlotnumber
toSlotnumber
dataStoredItem[]
dataSizenumber | InventoryType

Returns

player[] | undefined

Defined in

server/systems/inventory/manager.ts:663


swapBetween

Usage

Athena.systems.inventory.manager.swapBetween(from, to): ComplexSwapReturn | undefined

Swap items between two different data sets; with a given size.

Parameters

NameType
fromComplexSwap
toComplexSwap

Returns

ComplexSwapReturn | undefined

Defined in

server/systems/inventory/manager.ts:711


toggleItem

Usage

Athena.systems.inventory.manager.toggleItem(player, slot, type): Promise<boolean>

Toggles the isEquipped boolean in a stored item. If the boolean is undefined; it will change to true. Automatically saves.

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity
slotnumber
typeInventoryType-

Returns

Promise<boolean>

Defined in

server/systems/inventory/manager.ts:854


upsertData

Usage

Athena.systems.inventory.manager.upsertData<DataType>(item, data): any

Type parameters

NameType
DataType{}

Parameters

NameType
itemany
dataDataType

Returns

any

Defined in

server/systems/inventory/manager.ts:222


useItem

Usage

Athena.systems.inventory.manager.useItem(player, slot, type?, eventToCall?): any

Invokes an item use effect

Parameters

NameTypeDefault valueDescription
playerPlayerundefinedAn alt:V Player Entity
slotnumberundefined
type?"inventory" | "toolbar"'toolbar'
eventToCallstring | string[]undefined-

Returns

any

Defined in

server/systems/inventory/manager.ts:787

Created by Stuyk | Est. 2020