Shopkeepers

Shopkeepers

2M Downloads

Book copies

terafo opened this issue ยท 6 comments

commented
  • **Shopkeepers version: 2.9.1
  • **Spigot version: Paper-118, 1.15.2

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 Paper server with the latest version of Shopkeepers 2.9.1, with no other plugins and with no kinds of other server or client mods.

The issue:

Shop lots that contain copies of certain book doesn't work after server restart. This issue exists at least since 2.8.0.
Reproduction:
Create trading shop.
Put book copy in there and create trade with that copy.
Try buy/sell that book copy to Shopkeeper.
Restart server.
Try buy/sell that book copy to Shopkeeper.

commented

Issue with Spigot's item serialization: https://hub.spigotmc.org/jira/browse/SPIGOT-3206

Basically: The book saved by the Shopkeeper won't match the original book once the Shopkeeper is reloaded. Since the book items don't match, the trade no longer accepts the original book items. The fix would probably be for Spigot to save books in their original internal chat component format, instead of converting to legacy color codes (which cannot reliably be converted back to the original format)..

commented

Issue with Spigot's item serialization: https://hub.spigotmc.org/jira/browse/SPIGOT-3206

Basically: The book saved by the Shopkeeper won't match the original book once the Shopkeeper is reloaded. Since the book items don't match, the trade no longer accepts the original book items. The fix would probably be for Spigot to save books in their original internal chat component format, instead of converting to legacy color codes (which cannot reliably be converted back to the original format)..

As I understand, there is one static problem in pages part. Can it possible, to make a small parser that will be converting only written books in a proper way?

commented

It would be easier to fix the issue inside Spigot. However, right now I do not have the time to prepare a pull request for that.

commented

That is really bad. Can you please explain, what should be fixed, maybe we can help.

commented

See the linked issue and my comment over there: The issue is that Spigot converts the book's text from minecraft's chat component format ("text":, "color":, etc. ) to the legacy format ("&asome Text &b with color codes") when saving the item to a config file (such as Shopkeepers save.yml file). When converting from this legacy color codes format back to chat components, the newly created chat components don't match the original chat components.

A potential fix could be to store the original chat components in their stringified version ("text":, "color":, etc. ), and then load the chat components from that. The solution would also need to be able to deal with items that were already saved in the legacy color codes format, for example by taking the item's data version into account, having some sort of heuristic that detects whether the saved string is in the old or new format, or storing the new value with a different key.

commented

With the latest Spigot changes (https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/560b65c4f8a15619aaa4a1737c7040f21e725cce) this should be resolved.

I have briefly tested this and this seems to work fine. However, if you update your server make sure to create a backup of your save data, just in case something goes wrong.