From 8fa6dd5d5013cbb2eb0d35be077048022f08c0eb Mon Sep 17 00:00:00 2001 From: Repulser Date: Thu, 21 Dec 2017 13:06:27 +0200 Subject: [PATCH 1/3] Fix shard disconnecting events (#44) --- .../java/lavalink/client/io/Lavalink.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/LavalinkClient/src/main/java/lavalink/client/io/Lavalink.java b/LavalinkClient/src/main/java/lavalink/client/io/Lavalink.java index ec2a2515c..553849d0c 100644 --- a/LavalinkClient/src/main/java/lavalink/client/io/Lavalink.java +++ b/LavalinkClient/src/main/java/lavalink/client/io/Lavalink.java @@ -28,9 +28,11 @@ import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.core.entities.impl.JDAImpl; +import net.dv8tion.jda.core.events.DisconnectEvent; import net.dv8tion.jda.core.events.ReadyEvent; import net.dv8tion.jda.core.events.ReconnectedEvent; import net.dv8tion.jda.core.events.ResumedEvent; +import net.dv8tion.jda.core.events.ShutdownEvent; import net.dv8tion.jda.core.events.guild.voice.GuildVoiceJoinEvent; import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; import net.dv8tion.jda.core.events.guild.voice.GuildVoiceMoveEvent; @@ -200,6 +202,16 @@ public void onReady(ReadyEvent event) { .put("VOICE_SERVER_UPDATE", new VoiceServerUpdateInterceptor(this, (JDAImpl) event.getJDA())); } + @Override + public void onDisconnect(DisconnectEvent event) { + disconnectVoiceConnection(event.getJDA()); + } + + @Override + public void onShutdown(ShutdownEvent event) { + disconnectVoiceConnection(event.getJDA()); + } + @Override public void onReconnect(ReconnectedEvent event) { reconnectVoiceConnections(event.getJDA()); @@ -249,4 +261,17 @@ private void reconnectVoiceConnections(JDA jda) { }); } } + + private void disconnectVoiceConnection(JDA jda) { + links.forEach((guildId, link) -> { + try { + if (jda.getGuildById(guildId) != null) { + link.disconnect(); + } + } catch (Exception e) { + log.error("Caught exception while trying to disconnect link " + link, e); + } + }); + } + } From 0d6904319c7c97d2190a7f193dc53ac2e5a17d1d Mon Sep 17 00:00:00 2001 From: Repulser Date: Thu, 21 Dec 2017 18:10:40 +0200 Subject: [PATCH 2/3] Fix position and use isSeekable (#48) --- .../src/main/java/lavalink/client/player/LavalinkPlayer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/LavalinkClient/src/main/java/lavalink/client/player/LavalinkPlayer.java b/LavalinkClient/src/main/java/lavalink/client/player/LavalinkPlayer.java index 5b4c7c7d3..61eb7ba96 100644 --- a/LavalinkClient/src/main/java/lavalink/client/player/LavalinkPlayer.java +++ b/LavalinkClient/src/main/java/lavalink/client/player/LavalinkPlayer.java @@ -130,7 +130,6 @@ public boolean isPaused() { @Override public long getTrackPosition() { if (getPlayingTrack() == null) throw new IllegalStateException("Not currently playing anything"); - if (getPlayingTrack().getInfo().isStream) return Long.MAX_VALUE; if (!paused) { // Account for the time since our last update @@ -145,7 +144,7 @@ public long getTrackPosition() { @Override public void seekTo(long position) { if (getPlayingTrack() == null) throw new IllegalStateException("Not currently playing anything"); - if (getPlayingTrack().getInfo().isStream) throw new IllegalStateException("Can't seek in a stream"); + if (!getPlayingTrack().isSeekable()) throw new IllegalStateException("Track cannot be seeked"); JSONObject json = new JSONObject(); json.put("op", "seek"); From cf09a34fa551332664bb1cbdb59b1b6755cccc0f Mon Sep 17 00:00:00 2001 From: Brian Tanner Date: Mon, 1 Jan 2018 06:05:19 -0500 Subject: [PATCH 3/3] add lavalink.js to readme (#50) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00bf5dc7f..b2441a958 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Being used in production by FredBoat and Dyno. * [JDA client](https://github.com/Frederikam/Lavalink/tree/master/LavalinkClient) (JDA, Java) * [eris-lavalink](https://github.com/briantanner/eris-lavalink) (Eris, JavaScript) * [lava-d.js](https://github.com/untocodes/lava-d.js) (discord.js, JavaScript) -* [discord.js-lavalink](https://github.com/MrJacz/discord.js-lavalink) (discord.js, JavaScript) +* [lavalink.js](https://github.com/briantanner/lavalink.js) (discord.js, JavaScript) * Or [create your own](https://github.com/Frederikam/Lavalink/blob/master/IMPLEMENTATION.md) ## Server configuration