#[Citizen-API] despawning NPC is not saved in saves.yml

13 messages · Page 1 of 1 (latest)

neon apex
#

Hi,

I am currently trying to write a plugin that uses the Citizen API to create NPCs.
I want to be able to despawn a NPC without destroying it. At the moment I use the despawn function and then call the saveToStore() function of the registry that holds the NPC data.

    public static void despawnNPC(NPC npc){
        npc.despawn();
        npc.getOwningRegistry().saveToStore();
    }

Sadyly it does not seem to write this into the saves.yml so after a server restart the NPC will spawn again.
Is it possible to persist the despawning?

Thank you for your help.

vital yewBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

candid loom
#

There’s a trait called Spawned

#

Had api for this @neon apex

#

Alternatively you can specify a despawn reason which I think will do the same thing

neon apex
#

using

npc.getOrAddTrait(Spawned.class).setSpawned(false);

the spawning behavior is persistent after server restart. but using

npc.despawn(DespawnReason.PENDING_RESPAWN);

is still not persistent.

#

is this intended that it works that way?

candid loom
#

There’s several and I’m not at a a computer right now

neon apex
#

have tried multiple different despawn resons now, seems that it is same behaviour for all reasons

next currentBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@neon apex