lavalink-devs / lavalink-client

Lavalink client for lavalink v4
https://lavalink.dev/
MIT License
16 stars 5 forks source link

Allow user only set user data independently in PlayerUpdateBuilder/Player #18

Closed zvyap closed 10 months ago

zvyap commented 10 months ago

In some cases, users may only want to set their user data instead of having to create the entire Track object. Lavalink only requires the user to provide an encodedTrack to be able to play music.

Creating the Track object is annoying because it requires dev.arbjerg.lavalink.protocol.v4.Track, which includes many Kotlin elements that are not user-friendly for Java developers.

Moreover, while the identifier can be modified independently, why there isn't a similar option for user data?

Edit: What I mean for not user-friendly, my current solution image

duncte123 commented 10 months ago

As I replied in your other issue, I'll add a bulder for track updates.

duncte123 commented 10 months ago

Would you mind trying version e740a7293e99557ec81830e30d4f4538adf5efa5-SNAPSHOT with the new TrackUpdateBuilder class? It should do what you want.

You can get this version by adding the following repository

repositories {
    maven("https://maven.lavalink.dev/snapshots")
}
zvyap commented 10 months ago

First, idk why it got such weird thing in Java (Decompiled source not accurate) image

But updateTrack function looks good overall, receive user data from Lavalink server not tested image

duncte123 commented 10 months ago

Your first thing, that is exactly how I wrote it, the builder returns the PlayerUpdateTrack object.

Second, do not send both the encoded AND the identifier. Sending the identifier causes more latency because lavalink will have to look up the track again. The encoded object is the entire track including the identifier. Please have a look at the examples provided and the documentation on the builder.

Example: https://github.com/lavalink-devs/lavalink-client/blob/main/testbot/src/main/java/me/duncte123/testbot/AudioLoader.java#L22-L27 Documentation (also available if you press ctrl+q while with your mouse on a method): https://main.lavalink-client.pages.dev/lavalink-client/dev.arbjerg.lavalink.client.protocol/-track-update-builder/#-896813142%2FFunctions%2F769193423

zvyap commented 10 months ago

Your first thing, that is exactly how I wrote it, the builder returns the PlayerUpdateTrack object.

Second, do not send both the encoded AND the identifier. Sending the identifier causes more latency because lavalink will have to look up the track again. The encoded object is the entire track including the identifier. Please have a look at the examples provided and the documentation on the builder.

Example: https://github.com/lavalink-devs/lavalink-client/blob/main/testbot/src/main/java/me/duncte123/testbot/AudioLoader.java#L22-L27 Documentation (also available if you press ctrl+q while with your mouse on a method): https://main.lavalink-client.pages.dev/lavalink-client/dev.arbjerg.lavalink.client.protocol/-track-update-builder/#-896813142%2FFunctions%2F769193423

First, okay. I just miss the 'interface' method in IUpdatablePlayer

Second, roger that.

duncte123 commented 10 months ago

Resolved in version 2.3.0