PrismarineJS / node-mojangson

A mojangson parser written in node.js
17 stars 9 forks source link

Issue Parsing Items #9

Closed dlaunikitis closed 4 years ago

dlaunikitis commented 4 years ago

The Error:

Error parsing text '{id:299,Damage:0,tag:{display:{Name:§f§d§l\§f§lSayMums§d§l\,Lore:[§7Protection IV,§7Projectile Protection II,§7Unbreaking III,§dMega Heavy V,§dInfinite Luck V,§dGhostly Ghost III,§dSoul Hardened III,§dGodly Overload III,§dDivine Enlighted III,§dPaladin Armored IV,§dReinforced Tank IV,§dVengeful Diminish VI,§dHeroic Enchant Reflect IX,§dPlanetary Deathbringer III,§eMarksman IV,§eAngelic V,§eValor V,§8A firey shroud that echoes absolute,§8power and domination. No mere human,§8would dare stand against its owner., ,§8§lKit Level| §c10 / 10,§0IID 109604253,§a§l14 Enchantment Slots§7 (Orb [§a+5§7]), ,§7+8 Armor Value,§71000 Durability,§4This armor is stronger than diamond.,§6§lArmor Crystal (§4§lSupreme§7 §c§lPhantom§7 §6§lEngineer§7 §5§lDimensional Traveler§7§6§l),§6§lAnti M-Kit Crystal (§2§lNecromancer§7 §9§lDeath Knight§7§6§l), ,§3§l+ AMULET [§8N/A§3§l],§6§l~§6ShooterMatty,§c§lCORRUPT (§7cannot be protected§c§l),§f§lPROTECTED]}}}'
{"extra":[{"color":"white","text":"\u003cInterstellar\u003e XQuakQuak: "},{"color":"white","hoverEvent":{"action":"show_item","value":"{id:299,Damage:0,tag:{display:{Name:\\SayMums\\,Lore:[Protection IV,Projectile Protection II,Unbreaking III,Mega Heavy V,Infinite Luck V,Ghostly Ghost III,Soul Hardened III,Godly Overload III,Divine Enlighted III,Paladin Armored IV,Reinforced Tank IV,Vengeful Diminish VI,Heroic Enchant Reflect IX,Planetary Deathbringer III,Marksman IV,Angelic V,Valor V,A firey shroud that echoes absolute,power and domination. No mere human,would dare stand against its owner., ,Kit Level| 10 / 10,IID 109604253,14 Enchantment Slots (Orb [+5]), ,+8 Armor Value,1000 Durability,This armor is stronger than diamond.,Armor Crystal (Supreme Phantom Engineer Dimensional Traveler),Anti M-Kit Crystal (Necromancer Death Knight), ,+ AMULET [N/A],~ShooterMatty,CORRUPT (cannot be protected),PROTECTED]}}}"},"text":"» \"SayMums\" (x1) «"},{"color":"white","text":" in ah"}],"text":""}

My code:

function listeners(bot){
    bot.on('message', (jsonMsg) => {
        console.log(jsonMsg.toString())
    })
}

Example of an Item: https://gyazo.com/8f9aecbd15201d2896dc37e1af01ddda

I was told me make an issue on here from the discord. My console is spammed with these error messages while running the bot but it does not cause my code to stop running

rom1504 commented 4 years ago

What's the full error

On Sun, Mar 29, 2020, 00:33 Daveed1022 notifications@github.com wrote:

Error parsing text '{id:299,Damage:0,tag:{display:{Name:§f§d§l\§f§lSayMums§d§l,Lore:[§7Protection IV,§7Projectile Protection II,§7Unbreaking III,§dMega Heavy V,§dInfinite Luck V,§dGhostly Ghost III,§dSoul Hardened III,§dGodly Overload III,§dDivine Enlighted III,§dPaladin Armored IV,§dReinforced Tank IV,§dVengeful Diminish VI,§dHeroic Enchant Reflect IX,§dPlanetary Deathbringer III,§eMarksman IV,§eAngelic V,§eValor V,§8A firey shroud that echoes absolute,§8power and domination. No mere human,§8would dare stand against its owner., ,§8§lKit Level| §c10 / 10,§0IID 109604253,§a§l14 Enchantment Slots§7 (Orb [§a+5§7]), ,§7+8 Armor Value,§71000 Durability,§4This armor is stronger than diamond.,§6§lArmor Crystal (§4§lSupreme§7 §c§lPhantom§7 §6§lEngineer§7 §5§lDimensional Traveler§7§6§l),§6§lAnti M-Kit Crystal (§2§lNecromancer§7 §9§lDeath Knight§7§6§l), ,§3§l+ AMULET [§8N/A§3§l],§6§l~§6ShooterMatty,§c§lCORRUPT (§7cannot be protected§c§l),§f§lPROTECTED]}}}' {"extra":[{"color":"white","text":"\u003cInterstellar\u003e XQuakQuak: "},{"color":"white","hoverEvent":{"action":"show_item","value":"{id:299,Damage:0,tag:{display:{Name:\SayMums\,Lore:[Protection IV,Projectile Protection II,Unbreaking III,Mega Heavy V,Infinite Luck V,Ghostly Ghost III,Soul Hardened III,Godly Overload III,Divine Enlighted III,Paladin Armored IV,Reinforced Tank IV,Vengeful Diminish VI,Heroic Enchant Reflect IX,Planetary Deathbringer III,Marksman IV,Angelic V,Valor V,A firey shroud that echoes absolute,power and domination. No mere human,would dare stand against its owner., ,Kit Level| 10 / 10,IID 109604253,14 Enchantment Slots (Orb [+5]), ,+8 Armor Value,1000 Durability,This armor is stronger than diamond.,Armor Crystal (Supreme Phantom Engineer Dimensional Traveler),Anti M-Kit Crystal (Necromancer Death Knight), ,+ AMULET [N/A],~ShooterMatty,CORRUPT (cannot be protected),PROTECTED]}}}"},"text":"» "SayMums" (x1) «"},{"color":"white","text":" in ah"}],"text":""}

I was told me make an issue on here from the discord. My console is spammed with these error messages while running the bot but it does not cause my code to stop running

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rom1504/node-mojangson/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437QAWTO3Y2OGGFFF7TDRJ2CNJANCNFSM4LVYCRWQ .

dlaunikitis commented 4 years ago

https://gyazo.com/87aff0b1f402e7fb0a86312672e30660

Do i need to run something to get more detail?

rom1504 commented 4 years ago

Yeah copy that string and try to use it directly with node mojangson, you should get a better error

On Sun, Mar 29, 2020, 04:51 Daveed1022 notifications@github.com wrote:

https://gyazo.com/87aff0b1f402e7fb0a86312672e30660

Do i need to run something to get more detail?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rom1504/node-mojangson/issues/9#issuecomment-605550332, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437XK2MBA4WILXQHCS4DRJ2ZUJANCNFSM4LVYCRWQ .

dlaunikitis commented 4 years ago

https://gyazo.com/564f914985ab263a2f4ea624bfaf1abe

Hopefully, I did things correctly

rom1504 commented 4 years ago

you put here the code you executed and the full error you got, as text not screenshot

dlaunikitis commented 4 years ago

The Error:

Function {
  message: 'Parse error on line 1:\n' +
    '..."show_item","value":"{id:299,Damage:0,ta\n' +
    '-----------------------^\n' +
    "Expecting 'EOF', 'RIGHTC', 'DP', 'COMMA', 'RIGHTP', got 'STRINGWITHOUTQUOTE'",
  hash: {
    text: '',
    token: 'STRINGWITHOUTQUOTE',
    token_id: 141,
    line: 0,
    loc: {
      first_line: 1,
      last_line: 1,
      first_column: 124,
      last_column: 124
    },
    expected: [ "'EOF'", "'RIGHTC'", "'DP'", "'COMMA'", "'RIGHTP'" ],
    recoverable: false,
    state_stack: [
        0, 148,  14, 139,  18, 137,  25, 131,  15,
      128,  23, 138,  28, 148,  14, 139,  18, 137,
       25, 128,  29, 138,  32, 139,  18, 137,  25,
      148,  14, 139,  18, 137,  25, 128,  29, 138,
       32, 139,  18, 137,  25, 141,  13
    ]
  }
}

Code

console.log(mojangson.parse(`{"extra":[{"color":"white","text":"\u003cInterstellar\u003e XQuakQuak: "},{"color":"white","hoverEvent":{"action":"show_item","value":"{id:299,Damage:0,tag:{display:{Name:\\SayMums\\,Lore:[Protection IV,Projectile Protection II,Unbreaking III,Mega Heavy V,Infinite Luck V,Ghostly Ghost III,Soul Hardened III,Godly Overload III,Divine Enlighted III,Paladin Armored IV,Reinforced Tank IV,Vengeful Diminish VI,Heroic Enchant Reflect IX,Planetary Deathbringer III,Marksman IV,Angelic V,Valor V,A firey shroud that echoes absolute,power and domination. No mere human,would dare stand against its owner., ,Kit Level| 10 / 10,IID 109604253,14 Enchantment Slots (Orb [+5]), ,+8 Armor Value,1000 Durability,This armor is stronger than diamond.,Armor Crystal (Supreme Phantom Engineer Dimensional Traveler),Anti M-Kit Crystal (Necromancer Death Knight), ,+ AMULET [N/A],~ShooterMatty,CORRUPT (cannot be protected),PROTECTED]}}}"},"text":"» \"SayMums\" (x1) «"},{"color":"white","text":" in ah"}],"text":""}`))
dlaunikitis commented 4 years ago
Error parsing text '{id:383,Damage:54,tag:{display:{Name:§2§lPlague Bloater,Lore:[§7This monster egg contains a,§c§ndangerous§7 warzone boss, ,§2§lLORE,§7§oThe host vessel of the most deadly,§7§oplague virus strain ever,§7§odiscovered. Wherever this,§7§oabomination goes death soon,§7§ofollows. , ,§2§lDIFFICULTY,§2Legendary+,§0IID 37288056]}}}'
Error parsing text '{id:383,Damage:51,tag:{display:{Name:§c§lUndead Assassin,Lore:[§7This monster egg contains a,§c§ndangerous§7 warzone boss, ,§c§lLORE,§7§oA legendary assassin that rides a,§7§oskeleton horse. Stories have told,§7§othat the reason this assassin,§7§ocannot be stopped is because he is,§7§oalready dead. , ,§c§lDIFFICULTY,§cLegendary,§0IID 37288058]}}}'
Error parsing text '{id:264,Damage:0,tag:{display:{Name:§f§lKIT \§6§b§k!!!§r§f§l§nHeroic§d§k!!!§r §f§lGrandmaster Kit§f§l\,Lore:[§7Right-click this gem to unlock ,§7the §b§k!!!§r§f§l§nHeroic§d§k!!!§r §f§lGrandmaster Kit§7 /gkit on this planet., ,§7If you already have this /gkit unlocked,§7you can redeem this gem to increase,§7the §e§lKit Tier§7 which will increase,§7the enchantment levels on the /gkit,§7items each time you claim it.,§0IID 37288060]}}}'
Error parsing text '{id:383,Damage:58,tag:{display:{Name:§6§lYijki the World Destroyer,Lore:[§7This monster egg contains a,§c§ndangerous§7 warzone boss, ,§6§lLORE,§7§oAn entity with powers on paar with,§7§othe god of destruction itself. No,§7§oheroes in recorded Cosmonaut,§7§ohistory have faced this absolute,§7§oevil and lived to tell the tale. , ,§6§lDIFFICULTY,§6Legendary++,§0IID 37288062]}}}'
Error parsing text '{id:383,Damage:52,tag:{display:{Name:§5§lBrood Mother,Lore:[§7This monster egg contains a,§c§ndangerous§7 warzone boss, ,§5§lLORE,§7§oThe mother of all spiders with the,§7§omost deadly venom in all the,§7§oCosmoverse. No one has survived a,§7§obite from the Brood Mother. , ,§5§lDIFFICULTY,§5Ultimate]}}}'
Error parsing text '{id:381,Damage:0,tag:{display:{Name:§6§lWeapon Enchantment Orb [§a§n12§6§l],Lore:[§a82% Success Rate, ,§6+1 Enchantment Slots,§612 Max Enchantment Slots, ,§eIncreases the # of enchantment,§eslots on a piece of weapon by 1,§eup to a maximum of 12.,§7Drag n' Drop onto weapon to apply.,§0IID 37288065]}}}'
Error parsing text '{id:312,Damage:0,tag:{display:{Name:§e§lScorched Leggings of Dragons§r §d[§b§l§n10§d],Lore:[§7Protection V,§7Unbreaking III,§6Clarity III,§6Armored III,§6Enlighted III,§eArrow Deflect IV,§eAngelic IV,§eValor V,§eTank II,§eObsidianshield I,§eLucky IX,§bCactus II,§e§oThe mythical leggings of a Slayer of Dragons., ,§e§lDRAGON SLAYER SET BONUS,§e§l* §e+15% PvP Damage,§e§l* §e-15% Incoming Damage,§e§l* §eImmune to Freezes,§e§l* §eMastery Enchant Reflect X,§e§l* §eNegate 75% of Enemy Silence,§e§l* §e25% Mastery Enchant Negation,§7(§7§oRequires all 4 dragon slayer items§7)]}}}'
Error parsing text '{id:120,Damage:0,tag:{display:{Name:§6§lRandom Multi-Mask Generator,Lore:[§7Unbreaking X,§f,§7§nRight-click§7 to reveal which §6§lMulti-Mask,§7from previous lootboxes will be yours!, ,§f§lRandom Loot (§71 item§f§l), §f§l* §f1x §f§lMulti-Mask (§r§3§lStronghold Mask §b§lOutpost Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§9§lDeath Knight §2§lNecromancer Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§5§lRift Mask §2§lNecromancer Mask §c§lLover Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§b§lZeus Mask §6§lDungeon Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§c§lBoss Mask §6§lDungeon Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§6§lDungeon Mask §c§lBoss Mask §b§lZeus Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§a§lReindeer §f§lAnti-Silence Mask §2§lNecromancer Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§b§lZeus Mask §a§lReindeer §8§lAnonymous Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§9§lDeath Knight §b§lMonopoly Mask§f§l), §f§l* §f1x §f§lMulti-Mask (§r§4§lTerminator Mask §b§lZeus Mask §b§lMonopoly Mask§f§l), §f§l* §f1x §4§lGodly Multi-Mask Lootbox,§0IID 37288068]}}}'
Error parsing text '{id:388,Damage:0,tag:{display:{Name:§b§lFaction §b§l§nXP§b§l Booster,Lore:[§7§7§7Multiplies XP gained by all faction,§7§7members from killing mobs while active., ,§7Right-Click to activate., ,§d§lMULTIPLIER,§75.0x, ,§d§lDURATION,§715m]}}}'
Error parsing text '{id:381,Damage:0,tag:{display:{Name:§6§lArmor Enchantment Orb [§a§n12§6§l],Lore:[§a90% Success Rate, ,§6+1 Enchantment Slots,§612 Max Enchantment Slots, ,§eIncreases the # of enchantment,§eslots on a piece of armor by 1,§eup to a maximum of 12.,§7Drag n' Drop onto armor to apply.]}}}'
Error parsing text '{id:339,Damage:0,tag:{display:{Name:§b§lTITLE \§f69cps§b§l\,Lore:[§7Right-click this item to unlock ,§7the 69cps title on this planet.]}}}'
Error parsing text '{id:54,Damage:0,tag:{display:{Name:§6§lMask Generator §7(Right Click),Lore:[ ,§7Click to generate one of,§7the following player masks|,§6§l * §7Purge Mask,§6§l * §7Scarecrow Mask,§6§l * §7Turkey Mask,§6§l * §7Pilgrim Mask,§6§l * §7Monopoly Mask,§6§l * §7Necromancer Mask,§6§l * §7Santa,§6§l * §7Reindeer,§6§l * §7Party Hat,§6§l * §7Death Knight,§6§l * §7Rift Mask,§6§l * §7Lover Mask,§6§l * §7Glitch Mask,§6§l * §7Zeus Mask,§6§l * §7Bunny Mask,§6§l * §7Joker Mask,§6§l * §7Dungeon Mask,§6§l * §7Outpost Mask,§6§l * §7Stronghold Mask,§6§l * §7Boss Mask]}}}'
Error parsing text '{id:54,Damage:0,tag:{display:{Name:§6§lGear Bundle (§e/vkit§6§l) [§eLVL 6§6§l],Lore:[§7Right-click to reveal a random,§7roll of equipment from a,§7randomly selected §e/vkit!]}}}'
dlaunikitis commented 4 years ago
Error parsing text '{id:130,Damage:0,tag:{display:{Name:§f§lCDC §9§lCare Package,Lore:[§7§nRight-Click§7 to reveal the supplies,§7the CDC has sent your way!, ,§f§lRandom Loot (§71 item§f§l), §f§l* §f1x §f§lItem Skin (§r§5§lAmulet of Destruction§f§l), §f§l* §f1x §f§lItem Skin (§r§5§lCorrupt Cosmonaut Visor§f§l), §f§l* §f1x §f§lItem Skin (§r§5§lCorrupt Greatsword§f§l), §f§l* §f1x §f§lItem Skin (§r§d§lChad Sunglasses§f§l), §f§l* §f1x §f§lItem Skin (§r§5§lUtility Belt§f§l), §f§l* §f1x §f§lItem Skin (§r§5§lPower Belt§f§l), §f§l* §f1x §f§lItem Skin (§r§5§lAmulet of Corruption§f§l), §f§l* §f1x §f§lItem Skin (§r§e§lFlaming §6§lHalo§e§l§f§l), §f§l* §f1x §f§lItem Skin (§r§d§lGucci Belt§f§l), §f§l* §f1x §f§lItem Skin (§r§d§lBunny Slippers§f§l), §f§l* §f1x §f§lItem Skin (§r§2§lHazmat Helmet§f§l), §f§l* §f1x §f§lItem Skin (§r§2§lN95 Mask§f§l), §f§l* §f1x §f§lItem Skin (§r§a§lStaff §e§lPass§f§l), §f§l* §f1x §f§lItem Skin (§r§2§lFirst Aid Fannypack§f§l), §f§l* §f1x §f§lItem Skin (§r§2§lHazmat Boots§f§l), §f§l* §f1x §f§lItem Skin (§r§a§lRainbow §e§lSlides§f§l), §f§l* §f1x §f§lItem Skin (§r§a§lRubber §e§lChicken§f§l), §f§l* §f1x §f§lItem Skin (§r§a§lSpiked §e§lBaseball Bat§f§l), §f§l* §f1x §f§lItem Skin (§r§a§lMulti-Colored §e§lPopsicle§f§l), §f§l* §f1x §f§lItem Skin (§r§2§lCorona Beer Bottle§f§l), ,§f§lBonus Loot (§71 item§f§l), §f§l* §f1x §6§lPlayer Emote (§eCORONA§6§l)]}}}'

This one likes crashing me but it may just be like .indexOf that does like it

rom1504 commented 4 years ago

can you please double check the vanilla client can handle this properly ? (post a screenshot with what get displayed in game) things like {a:something something [c,b],z:something else} are quite annoying to tokenize, if this is really part of the language, then I think we'll either have to move away from lex/bison and write a custom parser, or just declare we don't handle them.

rom1504 commented 4 years ago

I think we should probably have a pre-parser than does some dirty things to fix this and make it more reasonable first (most important is removing the unquoted strings)

rom1504 commented 4 years ago

I'm however quite tented to say we don't support the worst cases of this and that's it

dlaunikitis commented 4 years ago

Issue identified to a regex code: const match = stringMsg.match(pattern) stringMsg: {"extra":[{"color":"white","text":"[AC] ***Kekt Daveed_: "},{"color":"white","hoverEvent":{"action":"show_item","value":"{id:130,Damage:0,tag:{display:{Name:CDC Care Package,Lore:[Right-Click to reveal the supplies,the CDC has sent your way!, ,Random Loot (1 item), * 1x Item Skin (Amulet of Destruction), * 1x Item Skin (Corrupt Cosmonaut Visor), * 1x Item Skin (Corrupt Greatsword), * 1x Item Skin (Chad Sunglasses), * 1x Item Skin (Utility Belt), * 1x Item Skin (Power Belt), * 1x Item Skin (Amulet of Corruption), * 1x Item Skin (Flaming Halo), * 1x Item Skin (Gucci Belt), * 1x Item Skin (Bunny Slippers), * 1x Item Skin (Hazmat Helmet), * 1x Item Skin (N95 Mask), * 1x Item Skin (Staff Pass), * 1x Item Skin (First Aid Fannypack), * 1x Item Skin (Hazmat Boots), * 1x Item Skin (Rainbow Slides), * 1x Item Skin (Rubber Chicken), * 1x Item Skin (Spiked Baseball Bat), * 1x Item Skin (Multi-Colored Popsicle), * 1x Item Skin (Corona Beer Bottle), ,Bonus Loot (1 item), * 1x Player Emote (CORONA)]}}}"},"text":"» CDC Care Package «"},{"color":"white","text":""}],"text":""} pattern: /^(?:\(.+\)|\[.+\]|.)*?(\w+) whispers(?: to you)?:? (.*)$/

Found within chat.js

Karang commented 4 years ago

Changing the regex to: ^(?:\(.+\)|\[.*\]|.*)?(\w+) whispers(?: to you)?:? (.*)$ should solve the issue. https://regex101.com/r/IwJf1j/1 For the explanations: https://javascript.info/regexp-catastrophic-backtracking

dlaunikitis commented 4 years ago

Works! hopefully will be implemented into mineflayer soon I'm guessing? :)