Fix Lavalink sometimes not decoding tracks properly
Created by: uwx
Summary
Fixes DSharpPlus.Lavalink not being able to handle some tracks, triggering an exception on track finish.
Details
Lavaplayer (and thus Lavalink) encodes tracks with DataOutputStream, which is a Very Bad Idea\u0001
to \u007F
, so it went unnoticed. The solution was to implement my own decoder for Java's arcane UTF-8, since copying and pasting code from the JDK would be a licensing nightmare.
Changes proposed
- Rewrite LavalinkUtilities.DecodeTrack
- Create a JavaBinaryReader class designed to handle data from DataOutputStream
Notes
This was actually a pretty fun bug to fix. I've tested the decoding with normal strings, strings containing special characters, and the strings reported to cause issues by thegiggitybyte#8099 on Discord.