QuickShop-Community / QuickShop-Hikari

QuickShop is a shop plugin that allows players to easily sell/buy any items from a chest without any commands. In fact, none of the commands that QuickShop provides are ever needed by a player.
https://modrinth.com/plugin/quickshop-hikari
GNU General Public License v3.0
84 stars 52 forks source link

[BUG] Chest shops before 1.21 remove custom NBT and sometimes throw an error #1714

Open Smudgge opened 1 month ago

Smudgge commented 1 month ago

Description

Chest shops that were created before 1.21 either remove custom NBT or throw the following.

[18:30:30 WARN]: [QuickShop-Hikari] Failed to processing purchase, rolling back...
java.lang.IllegalStateException: Failed to commit transaction! Economy Error Response:Failed to add 1x item:

Steps to reproduce

Expected Behaviour

Players should be able to sell items with custom NBT to older shops.

Screenshots

When using an AdvancedEnchants enchant

Client

[19:30:29] [Render thread/INFO]: [System] [CHAT] +---------------------------------------------------+
[19:30:29] [Render thread/INFO]: [System] [CHAT] | Shop Information:
[19:30:29] [Render thread/INFO]: [System] [CHAT] | Owner: <hidden>
[19:30:29] [Render thread/INFO]: [System] [CHAT] | Item: Chaos I   [Item Preview]
[19:30:29] [Render thread/INFO]: [System] [CHAT] | Space: 53
[19:30:29] [Render thread/INFO]: [System] [CHAT] | Price per Chaos I - $1
[19:30:29] [Render thread/INFO]: [System] [CHAT] | This shop is BUYING items.
[19:30:29] [Render thread/INFO]: [System] [CHAT] +---------------------------------------------------+
[19:30:29] [Render thread/INFO]: [System] [CHAT] Enter in chat, how much you wish to SELL. You can sell 1. Enter all in chat, to sell all.
[19:30:30] [Render thread/INFO]: [System] [CHAT] Sorry, but an internal error occurred while processing your purchase. The purchase has been cancelled and any other operations have been rolled back. Please contact the server administrators if this error persists.

Server

[18:30:30 WARN]: [QuickShop-Hikari] Failed to processing purchase, rolling back...
java.lang.IllegalStateException: Failed to commit transaction! Economy Error Response:Failed to add 1x item:
  ==: org.bukkit.inventory.ItemStack
  v: 3953
  type: BOOK
  meta:
    ==: ItemMeta
    meta-type: UNSPECIFIC
    display-name: '{"text":"","extra":[{"text":"Chaos I","obfuscated":false,"italic":false,"underlined":true,"strikethrough":false,"color":"light_purple","bold":true}]}'
    lore:
    - '{"text":"","extra":[{"text":"100% Success Rate","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"green","bold":false}]}'
    - '{"text":"","extra":[{"text":"0% Destroy Rate","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"red","bold":false}]}'
    - '{"text":"","extra":[{"text":"Chance to give your victims ","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"yellow","bold":false}]}'
    - '{"text":"","extra":[{"text":"Weakness and Wither.","italic":false,"color":"yellow"}]}'
    - '{"text":"","extra":[{"text":"Tridents Enchantment","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"gray","bold":false}]}'
    - '{"text":"","extra":[{"text":"Drag n'' drop onto item to enchant","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"gray","bold":false}]}'
    custom-model-data: 0
 to {"inventoryType":"org.bukkit.craftbukkit.inventory.CraftInventory","inventory":"org.bukkit.craftbukkit.inventory.CraftInventory@19b7b75e"}
        at QuickShop-Hikari 6.2.0.6.jar/com.ghostchu.quickshop.shop.ContainerShop.buy(ContainerShop.java:308) ~[QuickShop-Hikari 6.2.0.6.jar:?]
        at QuickShop-Hikari 6.2.0.6.jar/com.ghostchu.quickshop.shop.SimpleShopManager.actionBuying(SimpleShopManager.java:213) ~[QuickShop-Hikari 6.2.0.6.jar:?]
        at QuickShop-Hikari 6.2.0.6.jar/com.ghostchu.quickshop.shop.SimpleShopManager.actionTrade(SimpleShopManager.java:1128) ~[QuickShop-Hikari 6.2.0.6.jar:?]
        at QuickShop-Hikari 6.2.0.6.jar/com.ghostchu.quickshop.shop.SimpleShopManager.lambda$handleChat$2(SimpleShopManager.java:689) ~[QuickShop-Hikari 6.2.0.6.jar:?]
        at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:86) ~[purpur-1.21.jar:1.21-2280-930003b]
        at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:475) ~[purpur-1.21.jar:1.21-2280-930003b]
        at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1762) ~[purpur-1.21.jar:1.21-2280-930003b]
        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:509) ~[purpur-1.21.jar:1.21-2280-930003b]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1634) ~[purpur-1.21.jar:1.21-2280-930003b]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1334) ~[purpur-1.21.jar:1.21-2280-930003b]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:333) ~[purpur-1.21.jar:1.21-2280-930003b]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]

Other custom NBT Items

When selling simpler custom NBT items the NBT is just removed.

/quickshop paste URL

https://ghost-chu.github.io/quickshop-hikari-paste-viewer/?remote=https%3A%2F%2Fbytebin.lucko.me%2FAZtcMvf0Al

Additional Context

No response

Checklist

creatorfromhell commented 1 month ago

Is there still an error when recreating the shop? And what server software? Was already in the process of looking at how items are stored since paper/spigot and therefore any forks won't support their own serialization, issue being that if this is the cause of the problem any shops will have to be recreated anyways with a new system since they don't support it.

Smudgge commented 1 month ago

Is there still an error when recreating the shop? When players re-create the shop it works :3

And what server software? Purpur as seen in the /quickshop paste

It's just a bit strange because the items being sold to the shop work perfectly before the shop adds them to the chest. It's interesting as the chest shop doesn't think the items are different. Yet changes the item after being sold.

creatorfromhell commented 1 month ago

Is there still an error when recreating the shop? When players re-create the shop it works :3

And what server software? Purpur as seen in the /quickshop paste

It's just a bit strange because the items being sold to the shop work perfectly before the shop adds them to the chest. It's interesting as the chest shop doesn't think the items are different. Yet changes the item after being sold.

What is it removing? It sounds more and more like a serialization issue from the API side than in QuickShop

Smudgge commented 1 month ago

Item Before Using Shop

SelectedItem: {id: "minecraft:skeleton_spawn_egg", count: 64, components: {"minecraft:lore": 
['{"extra":[{"bold":false,"color":"aqua","italic":false,"obfuscated":false,"strikethrough":false,"text":
"Right click to spawn the boss!","underlined":false}],"text":""}'], "minecraft:custom_name":
'{"extra":[{"bold":true,"color":"#3A45FF","italic":false,"obfuscated":false,"strikethrough":false,"text":
"Lag Spike ","underlined":false},{"bold":true,"color":"gold","italic":false,"obfuscated":false,
"strikethrough":false,"text":"Boss ","underlined":false},{"bold":true,"color":"yellow",
"italic":false,"text":"Egg"}],"text":""}', "minecraft:enchantments": {show_in_tooltip: 
0b, levels: {"minecraft:unbreaking": 1}}, "minecraft:custom_data": 
{BossArenaTokenID: "SuperheroEgg"}, "minecraft:hide_additional_tooltip": {}}}

Enfesis on

"minecraft:custom_data": {BossArenaTokenID: "SuperheroEgg"}

Item After Using Old Shop

SelectedItem: {id: "minecraft:skeleton_spawn_egg", count: 1, components: {"minecraft:lore": 
['{"extra":[{"bold":false,"color":"aqua","italic":false,"obfuscated":false,"strikethrough":false,
"text":"Right click to spawn the boss!","underlined":false}],"text":""}'], "minecraft:enchantments": 
{show_in_tooltip: 0b, levels: {"minecraft:unbreaking": 1}}, "minecraft:custom_name": '{"extra":
[{"bold":true,"color":"#3A45FF","italic":false,"obfuscated":false,"strikethrough":false,"text":
"Lag Spike ","underlined":false},{"bold":true,"color":"gold","italic":false,"obfuscated":false,
"strikethrough":false,"text":"Boss ","underlined":false},{"bold":true,"color":"yellow","italic":false,"text":"Egg"}],"text":""}', 
"minecraft:hide_additional_tooltip": {}}}

The custom_data is now gone.

Smudgge commented 1 month ago

Also, where players can re-create their shops to fix it. Some players have loads and loads of shops they would have to re-create. Especially if this happens again next Minecraft update, it be nice if it was fixed by the plugin.

creatorfromhell commented 1 month ago

Also, where players can re-create their shops to fix it. Some players have loads and loads of shops they would have to re-create. Especially if this happens again next Minecraft update, it be nice if it was fixed by the plugin.

It would be nice indeed, unfortunately spigot and paper don't support their serializer anymore so it may not be possible.