Athena.systems.inventory.manager ​
Interfaces ​
Type Aliases ​
ComplexSwap ​
Ƭ ComplexSwap: Object
Type declaration ​
Name | Type |
---|---|
data | player [] |
size | InventoryType | number |
slot | number |
type | InventoryType |
Defined in ​
server/systems/inventory/manager.ts:28
ComplexSwapReturn ​
Ƭ ComplexSwapReturn: Object
Type declaration ​
Name | Type |
---|---|
from | player [] |
to | player [] |
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 ​
Name | Type |
---|---|
CustomData | {} |
Parameters ​
Name | Type | Default value | Description |
---|---|---|---|
item | Omit <StoredItem <CustomData >, "slot" > | undefined | - |
data | StoredItem <CustomData >[] | undefined | |
size | number | InventoryType | 256 | The 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 ​
Name | Type |
---|---|
item | any |
amount | number |
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 ​
Name | Type |
---|---|
CustomData | {} |
Parameters ​
Name | Type |
---|---|
baseItem | BaseItem |
storedItem | StoredItem <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 ​
Name | Type |
---|---|
item | any |
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 ​
Name | Type |
---|---|
CustomData | {} |
Parameters ​
Name | Type |
---|---|
fromSlot | number |
toSlot | number |
data | StoredItem <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 ​
Name | Type |
---|---|
from | ComplexSwap |
to | ComplexSwap |
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 ​
Name | Type |
---|---|
firstItem | StoredItem |
secondItem | StoredItem |
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 ​
Name | Type |
---|---|
CustomData | {} |
Parameters ​
Name | Type |
---|---|
data | StoredItem <CustomData >[] |
Returns ​
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 ​
Name | Type | Default value |
---|---|---|
dataSet | StoredItem [] | undefined |
dbName | string | undefined |
quantity | number | undefined |
version? | number | undefined |
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 ​
Name | Type | Default value |
---|---|---|
item | any | undefined |
amount | number | undefined |
isRemoving? | boolean | false |
Returns ​
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Name | Type |
---|---|
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 ​
Remove all items with zero quantity.
Parameters ​
Name | Type |
---|---|
items | any [] |
Returns ​
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 ​
Name | Type |
---|---|
DataType | {} |
Parameters ​
Name | Type |
---|---|
item | any |
data | DataType |
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 ​
Name | Type |
---|---|
CustomData | {} |
Parameters ​
Name | Type |
---|---|
slot | number |
data | StoredItem <CustomData >[] |
splitCount | number |
dataSize | number | 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 ​
Name | Type |
---|---|
CustomData | {} |
Parameters ​
Name | Type |
---|---|
item | Omit <StoredItem <CustomData >, "slot" | "data" > |
data | StoredItem [] |
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 ​
Name | Type |
---|---|
item | any |
amount | number |
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 ​
Name | Type |
---|---|
fromSlot | number |
toSlot | number |
data | StoredItem [] |
dataSize | number | 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 ​
Name | Type |
---|---|
from | ComplexSwap |
to | ComplexSwap |
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 ​
Name | Type | Description |
---|---|---|
player | Player | An alt:V Player Entity |
slot | number | |
type | InventoryType | - |
Returns ​
Promise
<boolean
>
Defined in ​
server/systems/inventory/manager.ts:854
upsertData ​
Usage
Athena.systems.inventory.manager.upsertData<DataType
>(item
, data
): any
Type parameters ​
Name | Type |
---|---|
DataType | {} |
Parameters ​
Name | Type |
---|---|
item | any |
data | DataType |
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 ​
Name | Type | Default value | Description |
---|---|---|---|
player | Player | undefined | An alt:V Player Entity |
slot | number | undefined | |
type? | "inventory" | "toolbar" | 'toolbar' | |
eventToCall | string | string [] | undefined | - |
Returns ​
any