Class QuestGiverNPCTrait
- All Implemented Interfaces:
Runnable
,org.bukkit.event.Listener
Only NPCs which have quests attached to them should have this trait. There are several methods in the plugin which remove the trait from NPCs which do not have Quests stored on them - for example that cleanup runs when the plugin restarts.
Note: TODO: The available Quests are not stored in the NPC directly. Instead, each quest object stores the NPC. Because of this, it has to loop through. This should be improved in the future for better performance.
-
Field Summary
Fields inherited from class net.citizensnpcs.api.trait.Trait
npc
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
click
(net.citizensnpcs.api.event.NPCRightClickEvent event) Called when a player clicks on the NPC.void
load
(net.citizensnpcs.api.util.DataKey key) void
onAttach()
Run code when your trait is attached to a NPC.void
void
onRemove()
Run code when the NPC is removed.void
onSpawn()
void
run()
Called every tick.void
save
(net.citizensnpcs.api.util.DataKey key) Methods inherited from class net.citizensnpcs.api.trait.Trait
getName, getNPC, isRunImplemented, linkToNPC, onCopy, onPreSpawn
-
Constructor Details
-
QuestGiverNPCTrait
public QuestGiverNPCTrait()
-
-
Method Details
-
load
public void load(net.citizensnpcs.api.util.DataKey key) - Overrides:
load
in classnet.citizensnpcs.api.trait.Trait
-
save
public void save(net.citizensnpcs.api.util.DataKey key) - Overrides:
save
in classnet.citizensnpcs.api.trait.Trait
-
click
public void click(net.citizensnpcs.api.event.NPCRightClickEvent event) Called when a player clicks on the NPC. This will send the quest preview GUI / Text to the player, which lists all available Quests for this NPC.The available Quests are not stored in the NPC directly. Instead, each quest object stores the NPC. Because of this, it has to loop through. This should be improved in the future for better performance.
-
run
public void run()Called every tick. This spawns a particle above an NPCs head which has this Trait, showcasing to the player that they have Quests and can be clicked. -
onAttach
public void onAttach()Run code when your trait is attached to a NPC. This is called BEFORE onSpawn, so npc.getEntity() will return null This will just splurt out a debug message, so we know when the trait has been attached to the NPC.- Overrides:
onAttach
in classnet.citizensnpcs.api.trait.Trait
-
onDespawn
public void onDespawn()- Overrides:
onDespawn
in classnet.citizensnpcs.api.trait.Trait
-
onSpawn
public void onSpawn()- Overrides:
onSpawn
in classnet.citizensnpcs.api.trait.Trait
-
onRemove
public void onRemove()Run code when the NPC is removed. This will also remove from the Quest object that the NPC is attached to it - since the NPC does not exist anymore. Otherwise, the plugin would try giving a non-existent NPC the NPC trait.This method is not called when the NPC is just despawned, but when it's completely removed and thus won't exist anymore.
- Overrides:
onRemove
in classnet.citizensnpcs.api.trait.Trait
-