Class LavalinkNode
-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable,reactor.core.Disposable
public final class LavalinkNode implements Disposable, Closeable
-
-
Field Summary
Fields Modifier and Type Field Description private final StringbaseUriprivate final StringsessionIdprivate final Flux<ClientEvent<?>>fluxprivate final LavalinkSocketwsprivate final Penaltiespenaltiesprivate final Statsstatsprivate final Booleanavailableprivate final Stringnameprivate final Stringpasswordprivate final IRegionFilterregionFilterprivate final LavalinkClientlavalink
-
Constructor Summary
Constructors Constructor Description LavalinkNode(String name, URI serverUri, String password, IRegionFilter regionFilter, LavalinkClient lavalink)
-
Method Summary
Modifier and Type Method Description final StringgetBaseUri()final StringgetSessionId()final Flux<ClientEvent<?>>getFlux()final LavalinkSocketgetWs()final PenaltiesgetPenalties()final StatsgetStats()final BooleangetAvailable()final StringgetName()final StringgetPassword()final IRegionFiltergetRegionFilter()final LavalinkClientgetLavalink()Unitdispose()Unitclose()final <T extends ClientEvent<?>> Flux<T>on(Class<T> type)final <T extends ClientEvent<?>> Flux<T>on()final Mono<List<LavalinkPlayer>>getPlayers()Retrieves a list of all players from the lavalink node. final Mono<LavalinkPlayer>getPlayer(Long guildId)Gets the player from the guild id. final Mono<LavalinkPlayer>updatePlayer(Long guildId, Consumer<PlayerUpdateBuilder> updateConsumer)final PlayerUpdateBuildercreateOrUpdatePlayer(Long guildId)Creates or updates a player. final Mono<Unit>destroyPlayer(Long guildId)Destroy a guild's player. final Mono<LoadResult>loadItem(String identifier)Load an item for the player. final Mono<Track>decodeTrack(String encoded)Uses the node to decode a base64 encoded track. final Mono<Tracks>decodeTracks(List<String> encoded)Uses the node to decode a list of base64 encoded tracks. final Mono<Info>getNodeInfo()Get information about the node. final Mono<Response>customRequest(UnaryOperator<HttpBuilder> builderFn)Send a custom request to the lavalink node. final <T extends Any> Mono<T>customJsonRequest(UnaryOperator<HttpBuilder> builderFn)Send a custom request to the lavalink node. final <T extends Any> Mono<T>customJsonRequest(DeserializationStrategy<T> deserializer, UnaryOperator<HttpBuilder> builderFn)Send a custom request to the lavalink node. Booleanequals(Object other)IntegerhashCode()-
-
Constructor Detail
-
LavalinkNode
LavalinkNode(String name, URI serverUri, String password, IRegionFilter regionFilter, LavalinkClient lavalink)
-
-
Method Detail
-
getBaseUri
final String getBaseUri()
-
getSessionId
final String getSessionId()
-
getFlux
final Flux<ClientEvent<?>> getFlux()
-
getWs
final LavalinkSocket getWs()
-
getPenalties
final Penalties getPenalties()
-
getStats
final Stats getStats()
-
getAvailable
final Boolean getAvailable()
-
getPassword
final String getPassword()
-
getRegionFilter
final IRegionFilter getRegionFilter()
-
getLavalink
final LavalinkClient getLavalink()
-
on
final <T extends ClientEvent<?>> Flux<T> on(Class<T> type)
-
on
final <T extends ClientEvent<?>> Flux<T> on()
-
getPlayers
final Mono<List<LavalinkPlayer>> getPlayers()
Retrieves a list of all players from the lavalink node.
- Returns:
A list of all players from the node.
-
getPlayer
final Mono<LavalinkPlayer> getPlayer(Long guildId)
Gets the player from the guild id. If the player is not cached, it will be retrieved from the server.
- Parameters:
guildId- The guild id of the player.
-
updatePlayer
final Mono<LavalinkPlayer> updatePlayer(Long guildId, Consumer<PlayerUpdateBuilder> updateConsumer)
-
createOrUpdatePlayer
final PlayerUpdateBuilder createOrUpdatePlayer(Long guildId)
Creates or updates a player.
- Parameters:
guildId- The guild id that you want to create or update the player for.- Returns:
The newly created or updated player.
-
destroyPlayer
final Mono<Unit> destroyPlayer(Long guildId)
Destroy a guild's player.
- Parameters:
guildId- The guild id of the player to destroy.
-
loadItem
final Mono<LoadResult> loadItem(String identifier)
Load an item for the player.
- Parameters:
identifier- The identifier (E.G.- Returns:
The LoadResult of whatever you tried to load.
-
decodeTrack
final Mono<Track> decodeTrack(String encoded)
Uses the node to decode a base64 encoded track.
- Parameters:
encoded- The base64 encoded track to decode.- Returns:
The decoded track.
-
decodeTracks
final Mono<Tracks> decodeTracks(List<String> encoded)
Uses the node to decode a list of base64 encoded tracks.
- Parameters:
encoded- The base64 encoded tracks to decode.- Returns:
The decoded tracks.
-
getNodeInfo
final Mono<Info> getNodeInfo()
Get information about the node.
-
customRequest
final Mono<Response> customRequest(UnaryOperator<HttpBuilder> builderFn)
Send a custom request to the lavalink node. Any host and port you set will be replaced with the node host automatically. The scheme must match your node's scheme, however.
It is recommended to use the path setter instead of the url setter when defining a url, like this:
<pre>{@code customRequest((builder) -> { return builder.path("/some/plugin/path") .get(); }).subscribe(System.out::println); }</pre>- Parameters:
builderFn- The request builder function, defaults such as the Authorization header have already been applied- Returns:
The Http response from the node, may error with an IllegalStateException when the node is not available.
-
customJsonRequest
final <T extends Any> Mono<T> customJsonRequest(UnaryOperator<HttpBuilder> builderFn)
Send a custom request to the lavalink node. Any host and port you set will be replaced with the node host automatically. The scheme must match your node's scheme, however. The response body will be deserialized using the provided deserializer.
It is recommended to use the path setter instead of the url setter when defining a url, like this:
<pre>{@code customJsonRequest<SomeType>{ it.path("/some/plugin/path") .get(); }.doOnSuccess { if (it == null) { println("http 204"); } println(it); }.subscribe(); }</pre>- Parameters:
builderFn- The request builder function, defaults such as the Authorization header have already been applied- Returns:
The Json object from the response body, may error with an IllegalStateException when the node is not available or the response is not successful.
-
customJsonRequest
final <T extends Any> Mono<T> customJsonRequest(DeserializationStrategy<T> deserializer, UnaryOperator<HttpBuilder> builderFn)
Send a custom request to the lavalink node. Any host and port you set will be replaced with the node host automatically. The scheme must match your node's scheme, however. The response body will be deserialized using the provided deserializer.
It is recommended to use the path setter instead of the url setter when defining a url, like this:
<pre>{@code customJsonRequest(SomeType.Serializer.INSTANCE, (builder) -> { return builder.path("/some/plugin/path") .get(); }).doOnSuccess((result) -> { if (result == null) { println("http 204"); } println(result); }).subscribe(); }</pre>- Parameters:
deserializer- The deserializer to use for the response body (E.G.builderFn- The request builder function, defaults such as the Authorization header have already been applied- Returns:
The Json object from the response body, may error with an IllegalStateException when the node is not available or the response is not successful.
-
-
-
-