Skip to content

Commit

Permalink
Merge pull request #964 from lavalink-devs/dev
Browse files Browse the repository at this point in the history
release 4.0.0-beta.4
  • Loading branch information
topi314 authored Sep 27, 2023
2 parents 16ca93f + 839db58 commit 2cec7bd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Each release usually includes various fixes and improvements.
The most noteworthy of these, as well as any features and breaking changes, are listed here.

## 4.0.0-beta.4
* Update lavaplayer to [`2.0.2`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.0.2) - Support MPEG 2.5 and fixed some requests not timing out
* Add `Omissible#isPresent` & `Omissible#isOmitted` to the `protocol` module
* Fix null pointer when a playlist has no selected track

## 4.0.0-beta.3
* Update lavaplayer to [`2.0.0`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.0.0) - Fixed YouTube 403 errors & YouTube access token errors

Expand Down
2 changes: 1 addition & 1 deletion LavalinkServer/src/main/java/lavalink/server/util/util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fun AudioTrack.toInfo(): TrackInfo {
}

fun AudioPlaylist.toPlaylistInfo(): PlaylistInfo {
return PlaylistInfo(this.name, this.tracks.indexOf(this.selectedTrack))
return PlaylistInfo(this.name, if (this.selectedTrack == null) -1 else this.tracks.indexOf(this.selectedTrack))
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import kotlinx.serialization.SerializationException
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import kotlin.jvm.JvmInline

@Serializable(with = OmissableSerializer::class)
Expand Down Expand Up @@ -70,6 +72,22 @@ class OmissableSerializer<T>(private val childSerializer: KSerializer<T>) : KSer
}
}

@OptIn(ExperimentalContracts::class)
fun <T : Any> Omissible<T>.isPresent(): Boolean {
contract {
returns(true) implies (this@isPresent is Omissible.Present<T>)
}
return this is Omissible.Present
}

@OptIn(ExperimentalContracts::class)
fun <T : Any> Omissible<T>.isOmitted(): Boolean {
contract {
returns(true) implies (this@isOmitted is Omissible.Omitted<T>)
}
return this is Omissible.Omitted
}

fun <T : Any?> Omissible<T>.takeIfPresent(predicate: (T) -> Boolean = { true }) =
if (this is Omissible.Present) value.takeIf(predicate) else null

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fun VersionCatalogBuilder.spring() {
}

fun VersionCatalogBuilder.voice() {
version("lavaplayer", "2.0.0")
version("lavaplayer", "2.0.2")

library("lavaplayer", "dev.arbjerg", "lavaplayer").versionRef("lavaplayer")
library("lavaplayer-ip-rotator", "dev.arbjerg", "lavaplayer-ext-youtube-rotator").versionRef("lavaplayer")
Expand Down

0 comments on commit 2cec7bd

Please sign in to comment.