PluginBugs / Issues-EpicBackpacks

Repository used to keep track of issues of my plugin EpicBackpacks
1 stars 2 forks source link

Long NBT data not saved on personal backpacks in MySQL #104

Closed BakiDance closed 8 months ago

BakiDance commented 9 months ago

Describe the bug Backpack contents don't save over SQL.

To Reproduce Steps to reproduce the behavior:

  1. Fill your backpack with certain items containing a lot of NBT.
  2. Close your backpack. An exception will generate in console, but the player will not notice anything out of the usual.
  3. Closing and reopening the backpack while still logged in shows the backpack contents (cached?), but if the player switches servers, or the server restarts, their backpack will be reverted to a previous state (removing their new items).

Expected behavior The player retains their backpack contents.

Screenshots https://github.com/PluginBugs/Issues-EpicBackpacks/assets/43658058/c6f03950-bb13-4a1e-b3d7-67e8d69959d9 (An example of a backpack which didn't save)

Info (please complete the following information):

Additional context

[22:42:41 INFO]: [EpicBackpacks] Saving bb317801-c2c4-4e18-8e26-ee21e03f4c69 personal backpack to MySQL db
[22:42:41 WARN]: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'content' at row 1
[22:42:41 WARN]:        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104)
[22:42:41 WARN]:        at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916)
[22:42:41 WARN]:        at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061)
[22:42:41 WARN]:        at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1009)
[22:42:41 WARN]:        at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1320)
[22:42:41 WARN]:        at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:994)
[22:42:41 WARN]:        at EpicBackPacks_1.3.16-r5.jar//dev.lone.EpicBackpacks.main.y.run(SourceFile:128)
[22:42:41 WARN]:        at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:101)
[22:42:41 WARN]:        at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57)
[22:42:41 WARN]:        at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22)
[22:42:41 WARN]:        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[22:42:41 WARN]:        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[22:42:41 WARN]:        at java.base/java.lang.Thread.run(Thread.java:833)
[22:42:41 INFO]: [EpicBackpacks] [OK] Saved bb317801-c2c4-4e18-8e26-ee21e03f4c69 personal backpack to MySQL db

Here's an item with a lot of NBT. Items such as these seem to cause issues with the plugin. (generated from /paper dumpitem)

minecraft:leather_boots{AttributeModifiers:[{Amount:3.0d,AttributeName:"minecraft:generic.armor",Name:"generic.armor",Operation:0,Slot:"feet",UUID:[I;-12245,67344,133735,-134688]},{Amount:3.0d,AttributeName:"minecraft:generic.armor_toughness",Name:"generic.armor_toughness",Operation:0,Slot:"feet",UUID:[I;-12245,67444,133735,-134888]},{Amount:1.0d,AttributeName:"minecraft:generic.attack_damage",Name:"generic.attack_damage",Operation:0,Slot:"feet",UUID:[I;-12245,67544,133735,-135088]},{Amount:0.3d,AttributeName:"minecraft:generic.attack_speed",Name:"generic.attack_speed",Operation:0,Slot:"feet",UUID:[I;-12245,67644,133735,-135288]},{Amount:0.25d,AttributeName:"minecraft:generic.knockback_resistance",Name:"generic.knockback_resistance",Operation:0,Slot:"feet",UUID:[I;-12245,67744,133735,-135488]},{Amount:2.0d,AttributeName:"minecraft:generic.max_health",Name:"generic.max_health",Operation:0,Slot:"feet",UUID:[I;-12245,67844,133735,-135688]},{Amount:0.1d,AttributeName:"minecraft:generic.movement_speed",Name:"generic.movement_speed",Operation:1,Slot:"feet",UUID:[I;-12245,67944,133735,-135888]},{Amount:2.0d,AttributeName:"minecraft:generic.luck",Name:"generic.luck",Operation:0,Slot:"feet",UUID:[I;-12245,68044,133735,-136088]}],CustomModelData:163,Damage:0,Enchantments:[{id:"minecraft:blast_protection",lvl:5s},{id:"minecraft:fire_protection",lvl:5s},{id:"minecraft:mending",lvl:1s},{id:"minecraft:projectile_protection",lvl:5s},{id:"minecraft:protection",lvl:5s},{id:"minecraft:unbreaking",lvl:25s}],HideFlags:67,RepairCost:100,display:{Lore:['[{"text":"Description:","italic":false,"color":"#fcfcca"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Shards of Prism compose","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" • ","italic":false,"color":"#fcfcca","bold":true},{"text":"this armor, creating an","color":"white","bold":false},{"text":"","color":"dark_purple","bold":false}]','[{"text":" • ","italic":false,"color":"#fcfcca","bold":true},{"text":"incredible blend of power.","color":"white","bold":false},{"text":"","color":"dark_purple","bold":false}]','[{"text":"","italic":false,"color":"dark_purple"}]','[{"text":"Details:","italic":false,"color":"#fcfcca"},{"text":"","italic":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Armor +3","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Toughness +3","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Attack Damage +10%","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Attack Speed +10%","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Knockback Taken -10%","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Health +1","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Speed +1","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Luck +2","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Protection V","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Fire Protection V","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Blast Protection V","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Projectile Protection V","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Unbreaking VVX","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":" ","italic":false,"color":"#fcfcca","bold":true},{"text":"• "},{"text":"Mending","bold":false,"color":"white"},{"text":"","bold":false,"color":"dark_purple"}]','[{"text":"","italic":false,"color":"dark_purple"}]','[{"text":"ᴍɪx-ᴀɴᴅ-ᴍᴀᴛᴄʜ ᴡɪᴛʜ ᴏᴛʜᴇʀ ʀᴀɴᴋ","italic":true,"color":"gray"}]','[{"text":"ᴀʀᴍᴏʀ ᴛᴏ ᴄʀᴇᴀᴛᴇ ᴛʜᴇ ᴜʟᴛɪᴍᴀᴛᴇ ꜱᴇᴛ!","italic":true,"color":"gray"}]'],Name:'[{"text":"[","italic":false,"color":"#fb5454"},{"text":" "},{"text":"ᴘ","color":"#fb785f"},{"text":"ʀ","color":"#fc9d6a"},{"text":"ɪ","color":"#fcc175"},{"text":"ꜱ","color":"#fde680"},{"text":"ᴍ","color":"#f0f98a"},{"text":"-","color":"#d6fa94"},{"text":"ᴘ","color":"#bdfc9d"},{"text":"ʟ","color":"#a3fda7"},{"text":"ᴀ","color":"#89ffb1"},{"text":"ᴛ","color":"#89f4c2"},{"text":"ᴇ","color":"#8ae9d4"},{"text":"ᴅ","color":"#8adee5"},{"text":" ","color":"#8adee5"},{"text":"ʙ","color":"#8bd3f6"},{"text":"ᴏ","color":"#97c5fb"},{"text":"ᴏ","color":"#afb4f3"},{"text":"ᴛ","color":"#c6a2ec"},{"text":"ꜱ","color":"#de91e4"},{"text":" ","color":"#de91e4"},{"text":"]","color":"#f67fdc"}]',color:16720639}}

I'm able to put nine of these items into a backpack and it WILL save correctly. However, once I put any other items in after this, the exception appears and the backpack fails to save. The item itself isn't causing the problem, but the quantity of items with NBT. Unfortunately, there are a bunch of items on my server that have a lot of NBT applied to them (granted, not often as much as this), so the issue in people's backpacks being rolled back is a significant issue.

LoneDev6 commented 8 months ago

Seems your backpack NBT string is longer than 65.535 characters. I will update the plugin to support longer data. Thanks!