Shopkeepers

Shopkeepers

2M Downloads

Citizens shopkeeper issue

EvilPandaMan opened this issue ยท 4 comments

commented

Preliminaries:

  • Shopkeepers version: Shopkeepers-2.13.1.jar
  • Spigot version: paper_1.17

The issue:

I understand that everything is in a transitional process, so I'm just dropping this here for awareness. All my citizens shopkeepers keep disappearing and it only prompt one little warn/error on console.

Screenshot 2021-06-29 120506

commented

Despite what it says (there are no npcs...) Previously I didn't have to create an npc beforehand, the npc shopkeeper would automatically create them.

commented

Are you using the latest Citizens build? I.e. build 2333 as of right now

keep disappearing

When exactly are they disappearing? Do they appear in-game when you spawn a new NPC shopkeeper? DO they show up inside Citizens save.yml file? Do they disappear once your restart the server? Maybe it's an issue with the NPC not getting saved to the Citizens save file for some reason (maybe I need to explicitly trigger a save now. Though, this wasn't required in the past if I remember correctly.).

commented

I cannot reproduce any issues with Citizens NPCs disappearing, unless the server crashes before Citizens was able to save the NPC data. Make sure that you are using the latest version of Citizens. I tested with Citizens-2.0.28-b2335.

However, I added a new setting for the next version of shopkeepers: save-citizen-npcs-instantly (disabled by default) that triggers a save of the Citizens NPCs whenever the Shopkeeper plugins modifies a Citizens NPC.
Since there is no API yet to trigger an asynchronous save, I trigger these saves by executing the /citizens save -a command in the console. However, as a side effect, this will print command feedback messages to the console whenever the Citizens NPCs are saved this way.

Enabling this setting comes with a small performance hit whenever you create or edit a new Citizens shopkeeper, but should make it less likely (but still possible) to run into the warning message you posted.
Alternatively, you can also tweak Citizens periodic save interval in the Citizens plugin config. By default this only triggers a save once every hour.

Or you just either manually cleanup the inconsistent Citizen shopkeepers whenever the plugin detects them, or automatcially by enabling the delete-invalid-citizen-shopkeepers setting as mentioned by the warning.

commented

I have tested both on 1.16.5 and 1.17 and can not see a behavioral difference. However, one has to note that on both versions of Citizens and the Shopkeepers plugin, the shopkeeper Citizen NPCs are not saved to the Citizens saves files immediately, but rather on shutdown of the Citizens plugin, or periodically depending on your Citizens config settings. This is similar to when you manually create a new Citizens NPC and then not immediately invoke the /citizen save command.

The error message you get is new on v2.13.0+: It informs you about shopkeepers for which the corresponding Citizens NPC is not found. This can for example occur if the server crashes without Citizens performing its saves during shutdown. Or if you forcefully clear the Citizens saves file, or delete Citizens NPCs while the shopkeepers plugin is not running. But as far as I can tell, nothing has changed between 1.16.5 and 1.17 in regards to when Citizen NPC are saved or not saved, or deleted.

However, I could consider triggering an immediate Citizens save whenever a new Citizens shopkeeper is created.