Shopkeepers

Shopkeepers

2M Downloads

Internal Attribute Issues

PR099 opened this issue ยท 3 comments

commented

Preliminaries:

  • Shopkeepers version: 2.9.3
  • Spigot version: This server is running Paper version git-Paper-299 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)

  • I have checked that my issue/question does not get answered by:
  • I have checked all open and closed issues, but none seems to fit my issue/question.

Reproduction on a fresh and up-to-date Spigot server:

I was able to reproduce my issue on a freshly setup and up-to-date Spigot server (currently Paper version git-Paper-299) with the latest version of Shopkeepers (currently 2.9.3), with no other plugins and with no kinds of other server or client mods.

The issue:

Provide a detailed description of your problem and add as much information as possible which could help reproducing the issue.

Hello,

I am trying to use the UltimateDrugs plugin with your Shopkeepers plugin. I was trying to set up a villager shop where the player will exchange 2 stacks of cactus for a drug which is a player head (comes from the UltimateDrugs plugin). At first, the shops functions as expected and the drugs work after trading. However, upon a server restart, the majority of the shops no longer work as intended. The shops all still give player heads drugs that look like the ones that would be obtained by UltimateDrugs (/drug give [player] [drug] [amount]), but only 4 of the drugs actually work. If the shops are edited and the drugs obtained from the command above are placed into the shop again, it will function as intended until after another server restart. The internal attribute in the save.yml file does not change after replacing the drug with the working one. Below is a link to my save.yml file. If there is anything else that you need from me, please let me know!

save.yml file

https://paste.helpch.at/gewoduzula.bash

commented

I was able to narrow it down to the color code (specifically to the lore attribute of the drugs and the names of the drugs). Turns out that the &0 color code does not play nicely with Shopkeepers on a server restart. Thank you for your suggestions and insight. I was just able to swap it out for another color code, I'm not sure if the error is in how the UltimateDrugs plugin creates the item with the &0 color code. If you wish, I can send you a schematic of such item in a chest.

commented

These kinds of issues with the trades no longer working after a plugin/server reload/restart usually hint at an issue with the de/serialization of the involved items (i.e. the item saved into the save.yml file and the item loaded from the save.yml file do not match).

Shopkeepers uses a piece of Spigot's API for saving and loading items to and from the save.yml file. There are a few common reasons for Spigot (and therefore Shopkeepers) not being able to correctly persist the data of certain items. To figure out what the exact issue here is I need to know the internal nbt data of the original items (what gets actually saved to the save.yml file might not match what the plugin was trying to save).
One way to display the internal nbt data of an item is to use minecraft's build-in /data command. Another option is to use an external program like NBTExplorer.

Since this UltimateDrugs plugin offers configuration options for configuring these 'drug items', please try to narrow the issue down by testing with different configurations and thereby reducing the issue to a specific portion of item data that is causing this. For example, try without display name and lore, try without color/formatting codes, try without custom skull texture, try a different item type, etc. Ideally you should end up with a minimal item that is able to reproduce this.

Ideally I would need to be able to reproduce the issue to further debug it once you have narrowed it down. For that I need to be able to create this item in exactly the same way as you (i.e. the UltimateDrugs plugin) is creating it. This might be tricky to do since UltimateDrugs seems to be behind a paywall, so if it does anything special internally in how it creates its items I might not be able to reproduce this. An option could be that you create a schematic with WorldEdit containing a chest with this problematic item and send that to me so that I can load it on my testing server.

In the end these kinds of issues are often either caused by an issue with how the items are created (in which case this would be something for UltimateDrugs to fix), or they are caused by an issue/limitation of Spigot's item serialization (the piece of API which the Shopkeepers plugin uses for saving and loading items), in which case this would be something for Spigot to fix. Usually the 'solution' ends up either fixing how the item is created, or avoiding the specific type of item data (i.e. the plugin feature responsible for it) that causes this issue.

commented

Okay, thanks for narrowing the issue down. This seems to be specific to how Spigot treats the black color code (it assumes this to be the default color in a few places and therefore decides to omit it). I therefore assume that this is a Spigot issue and not specific to the UltimateDrugs plugin. There already is a relevant issue to keep track of this here: #617
Relevant Spigot issues: https://hub.spigotmc.org/jira/browse/SPIGOT-4441, https://hub.spigotmc.org/jira/browse/SPIGOT-4373

As you figured out a workaround is to use a different color code at the front.