MC-Machinations / PaperTweaks

A better-performance replacement for the popular VanillaTweaks datapack collection.
GNU General Public License v3.0
141 stars 13 forks source link

Unable to deserialize ComponentDataType on BlockDropItemEvent #68

Closed Prof-Bloodstone closed 2 years ago

Prof-Bloodstone commented 2 years ago

Expected behavior

No error :P

Observed/Actual behavior

Could not pass event BlockDropItemEvent to VanillaTweaks v0.2.0-SNAPSHOT
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 9 path $
    at com.google.gson.Gson.assertFullConsumption(Gson.java:939)
    at com.google.gson.Gson.fromJson(Gson.java:929)
    at com.google.gson.Gson.fromJson(Gson.java:877)
    at com.google.gson.Gson.fromJson(Gson.java:848)
    at VanillaTweaks.jar//me.machinemaker.vanillatweaks.pdc.types.ComponentDataType.fromPrimitive(ComponentDataType.java:52)
    at VanillaTweaks.jar//me.machinemaker.vanillatweaks.pdc.types.ComponentDataType.fromPrimitive(ComponentDataType.java:31)
    at org.bukkit.craftbukkit.v1_19_R1.persistence.CraftPersistentDataContainer.get(CraftPersistentDataContainer.java:67)
    at VanillaTweaks.jar//me.machinemaker.vanillatweaks.pdc.PDCKey.getFrom(PDCKey.java:66)
    at VanillaTweaks.jar//me.machinemaker.vanillatweaks.modules.other.persistentheads.BlockListener.onBlockDropItemEvent(BlockListener.java:97)
    at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:37)
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:664)
    at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.handleBlockDropItemEvent(CraftEventFactory.java:406)
    at net.minecraft.server.level.ServerPlayerGameMode.destroyBlock(ServerPlayerGameMode.java:444)
    at net.minecraft.server.level.ServerPlayerGameMode.destroyAndAck(ServerPlayerGameMode.java:332)
    at net.minecraft.server.level.ServerPlayerGameMode.handleBlockBreakAction(ServerPlayerGameMode.java:296)
    at net.minecraft.server.network.ServerGamePacketListenerImpl.handlePlayerAction(ServerGamePacketListenerImpl.java:1802)
    at net.minecraft.network.

Steps/models to reproduce

No clue - trying to track down the head which caused it.

Plugin and Datapack List

Plugins (28): ArmorStandEditor, BuycraftX, CapAFK, CarbonChat, Chunky, CoreProtect, DeathLog, DiscordSRV, dynmap, FirstJoinMessage, GFly, GSit, Hat, IsSlimeChunk, LuckPerms, OnePlayerSleep, OpenInv, PrometheusExporter, ServerUtils, spark, SpectatorMode, VanillaTweaks, VanishNoPacket, Vault, WanderfulAdditions, WorldBorder, WorldEdit, WorldGuard

There are 7 data packs enabled: [vanilla (built-in)], [file/bukkit (world)], [file/Anti_Ender-Grief_1.0 (world)], [file/NV (world)], [file/UniversalDyes (world)], [file/track_all_stats (world)], [file/BlazeAndCaveAdvancements (world)]

Server Version Info

This server is running Paper version git-Paper-58 (MC: 1.19) (Implementing API version 1.19-R0.1-SNAPSHOT) (Git: e294802) You are 3 version(s) behind Download the new version at: https://papermc.io/downloads Previous version: git-Paper-379 (MC: 1.18.2)

Plugin Version

0.2.0-SNAPSHOT (I'm on beta-22)

Other

No response

Machine-Maker commented 2 years ago

I think best I can do, until a specific reproduction is found, is add some debug logging if the json parsing fails.

Prof-Bloodstone commented 2 years ago

@Machine-Maker I think I found the cause - VT used to serialize the name to legacy formatting (or more probably the MobHeads module used to use legacy formatting):

PublicBukkitValues: {"vanillatweaks:head_name": "§eSlime's Head"}

Would it be acceptable to add a backwards-compatible deserializer - if it can't deserialize a component, it could try deserializing legacy name?

Machine-Maker commented 2 years ago

yeah, that makes sense. Surprised this didn't come up before. Its been a while since it switched to using json instead of legacy.