Package net.citizensnpcs.api.trait.trait
Class Inventory
java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.api.trait.trait.Inventory
Represents an NPC's inventory.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the contents of an NPC's inventory.void
Loads a trait.void
Called just before the attachedNPC
is despawned.void
onSpawn()
Called when anNPC
is spawned.void
openInventory
(Player sender) void
run()
Called every tick if overridden.void
Saves a trait.void
setContents
(ItemStack[] contents) Sets the contents of an NPC's inventory.void
toString()
-
Constructor Details
-
Inventory
public Inventory()
-
-
Method Details
-
getContents
Gets the contents of an NPC's inventory.- Returns:
- ItemStack array of an NPC's inventory contents
-
getInventoryView
-
load
Description copied from class:Trait
Loads a trait.- Overrides:
load
in classTrait
- Parameters:
key
- DataKey to load from- Throws:
NPCLoadException
- Thrown if this trait failed to load properly
-
onDespawn
public void onDespawn()Description copied from class:Trait
Called just before the attachedNPC
is despawned.NPC.getEntity()
will be non-null. -
onSpawn
public void onSpawn()Description copied from class:Trait
Called when anNPC
is spawned.NPC.getEntity()
will return null until this is called. This is also called onAttach when the NPC is already spawned. -
openInventory
-
run
public void run()Description copied from class:Trait
Called every tick if overridden. -
save
Description copied from class:Trait
Saves a trait. -
setContents
Sets the contents of an NPC's inventory.- Parameters:
contents
- ItemStack array to set as the contents of an NPC's inventory
-
setItem
-
toString
-