Skip to content

Commit 6c2afbf

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents 68d81b9 + cf09a34 commit 6c2afbf

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

LavalinkClient/src/main/java/lavalink/client/io/Lavalink.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
import net.dv8tion.jda.core.entities.Guild;
2929
import net.dv8tion.jda.core.entities.VoiceChannel;
3030
import net.dv8tion.jda.core.entities.impl.JDAImpl;
31+
import net.dv8tion.jda.core.events.DisconnectEvent;
3132
import net.dv8tion.jda.core.events.ReadyEvent;
3233
import net.dv8tion.jda.core.events.ReconnectedEvent;
3334
import net.dv8tion.jda.core.events.ResumedEvent;
35+
import net.dv8tion.jda.core.events.ShutdownEvent;
3436
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceJoinEvent;
3537
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent;
3638
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceMoveEvent;
@@ -200,6 +202,16 @@ public void onReady(ReadyEvent event) {
200202
.put("VOICE_SERVER_UPDATE", new VoiceServerUpdateInterceptor(this, (JDAImpl) event.getJDA()));
201203
}
202204

205+
@Override
206+
public void onDisconnect(DisconnectEvent event) {
207+
disconnectVoiceConnection(event.getJDA());
208+
}
209+
210+
@Override
211+
public void onShutdown(ShutdownEvent event) {
212+
disconnectVoiceConnection(event.getJDA());
213+
}
214+
203215
@Override
204216
public void onReconnect(ReconnectedEvent event) {
205217
reconnectVoiceConnections(event.getJDA());
@@ -249,4 +261,17 @@ private void reconnectVoiceConnections(JDA jda) {
249261
});
250262
}
251263
}
264+
265+
private void disconnectVoiceConnection(JDA jda) {
266+
links.forEach((guildId, link) -> {
267+
try {
268+
if (jda.getGuildById(guildId) != null) {
269+
link.disconnect();
270+
}
271+
} catch (Exception e) {
272+
log.error("Caught exception while trying to disconnect link " + link, e);
273+
}
274+
});
275+
}
276+
252277
}

LavalinkClient/src/main/java/lavalink/client/player/LavalinkPlayer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public boolean isPaused() {
130130
@Override
131131
public long getTrackPosition() {
132132
if (getPlayingTrack() == null) throw new IllegalStateException("Not currently playing anything");
133-
if (getPlayingTrack().getInfo().isStream) return Long.MAX_VALUE;
134133

135134
if (!paused) {
136135
// Account for the time since our last update
@@ -145,7 +144,7 @@ public long getTrackPosition() {
145144
@Override
146145
public void seekTo(long position) {
147146
if (getPlayingTrack() == null) throw new IllegalStateException("Not currently playing anything");
148-
if (getPlayingTrack().getInfo().isStream) throw new IllegalStateException("Can't seek in a stream");
147+
if (!getPlayingTrack().isSeekable()) throw new IllegalStateException("Track cannot be seeked");
149148

150149
JSONObject json = new JSONObject();
151150
json.put("op", "seek");

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Being used in production by FredBoat and Dyno.
1919
* [JDA client](https://github.com/Frederikam/Lavalink/tree/master/LavalinkClient) (JDA, Java)
2020
* [eris-lavalink](https://github.com/briantanner/eris-lavalink) (Eris, JavaScript)
2121
* [lava-d.js](https://github.com/untocodes/lava-d.js) (discord.js, JavaScript)
22-
* [discord.js-lavalink](https://github.com/MrJacz/discord.js-lavalink) (discord.js, JavaScript)
22+
* [lavalink.js](https://github.com/briantanner/lavalink.js) (discord.js, JavaScript)
2323
* Or [create your own](https://github.com/Frederikam/Lavalink/blob/master/IMPLEMENTATION.md)
2424

2525
## Server configuration

0 commit comments

Comments
 (0)