diff --git a/src/main/java/com/bbn/hadder/Hadder.java b/src/main/java/com/bbn/hadder/Hadder.java index 2dd1812..917328f 100644 --- a/src/main/java/com/bbn/hadder/Hadder.java +++ b/src/main/java/com/bbn/hadder/Hadder.java @@ -16,7 +16,6 @@ import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder; import net.dv8tion.jda.api.sharding.ShardManager; -import javax.security.auth.login.LoginException; import java.util.List; public class Hadder { diff --git a/src/main/java/com/bbn/hadder/audio/AudioManager.java b/src/main/java/com/bbn/hadder/audio/AudioManager.java index 4e7b730..c40002a 100644 --- a/src/main/java/com/bbn/hadder/audio/AudioManager.java +++ b/src/main/java/com/bbn/hadder/audio/AudioManager.java @@ -53,7 +53,7 @@ public class AudioManager { public AudioPlayer createPlayer(Guild guild) { AudioPlayer nPlayer = myManager.createPlayer(); - TrackManager manager = new TrackManager(nPlayer); + TrackManager manager = new TrackManager(nPlayer, this); nPlayer.addListener(manager); guild.getAudioManager().setSendingHandler(new AudioPlayerSendHandler(nPlayer)); players.put(guild.getId(), new AbstractMap.SimpleEntry<>(nPlayer, manager)); diff --git a/src/main/java/com/bbn/hadder/audio/TrackManager.java b/src/main/java/com/bbn/hadder/audio/TrackManager.java index 5154b80..c5710fe 100644 --- a/src/main/java/com/bbn/hadder/audio/TrackManager.java +++ b/src/main/java/com/bbn/hadder/audio/TrackManager.java @@ -18,10 +18,12 @@ import java.util.concurrent.LinkedBlockingQueue; public class TrackManager extends AudioEventAdapter { private final AudioPlayer player; + private final AudioManager manager; private final Queue queue; private boolean loop = false; - public TrackManager(AudioPlayer player) { + public TrackManager(AudioPlayer player, AudioManager manager) { + this.manager = manager; this.player = player; this.queue = new LinkedBlockingQueue<>(); } @@ -48,13 +50,16 @@ public class TrackManager extends AudioEventAdapter { @Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { + Guild g = queue.poll().getAuthor().getGuild(); if (loop) { player.playTrack(track.makeClone()); } else if (queue.isEmpty()) { - Guild g = queue.poll().getAuthor().getGuild(); + manager.players.remove(g.getId()); + manager.getPlayer(g).destroy(); + manager.getTrackManager(g).purgeQueue(); g.getAudioManager().closeAudioConnection(); } else { - player.playTrack(queue.element().getTrack().makeClone()); + player.playTrack(queue.element().getTrack()); } } diff --git a/src/main/resources/Translations/Translations_de.properties b/src/main/resources/Translations/Translations_de.properties index d1aaab0..41eee21 100644 --- a/src/main/resources/Translations/Translations_de.properties +++ b/src/main/resources/Translations/Translations_de.properties @@ -174,9 +174,6 @@ commands.moderation.editrules.success.title = Successfully changed commands.moderation.editrules.success.description = I successfully changed the rules commands.moderation.editrules.help.description = Edits the rules message. -commands.music.bass.error.connected.title = No channel -commands.music.bass.error.connected.description = You have to be in the same voice channel as the bot to change the bass level. -commands.music.bass.help.description = Change the bass for the song which is played at the moment. commands.music.join.success.title = Successfully connected commands.music.join.success.description = Ich habe mich erfolgreich mit %extra% verbunden. commands.music.join.error.connecting.already.title = Already connected diff --git a/src/main/resources/Translations/Translations_es.properties b/src/main/resources/Translations/Translations_es.properties index 5ca0715..9167e2d 100644 --- a/src/main/resources/Translations/Translations_es.properties +++ b/src/main/resources/Translations/Translations_es.properties @@ -174,9 +174,6 @@ commands.moderation.editrules.success.title = Successfully changed commands.moderation.editrules.success.description = I successfully changed the rules commands.moderation.editrules.help.description = Edits the rules message. -commands.music.bass.error.connected.title = No channel -commands.music.bass.error.connected.description = You have to be in the same voice channel as the bot to change the bass level. -commands.music.bass.help.description = Change the bass for the song which is played at the moment. commands.music.join.success.title = Successfully connected commands.music.join.success.description = I successfully connected to %extra%. commands.music.join.error.connecting.already.title = Already connected diff --git a/src/main/resources/Translations/Translations_fr.properties b/src/main/resources/Translations/Translations_fr.properties index 5ca0715..9167e2d 100644 --- a/src/main/resources/Translations/Translations_fr.properties +++ b/src/main/resources/Translations/Translations_fr.properties @@ -174,9 +174,6 @@ commands.moderation.editrules.success.title = Successfully changed commands.moderation.editrules.success.description = I successfully changed the rules commands.moderation.editrules.help.description = Edits the rules message. -commands.music.bass.error.connected.title = No channel -commands.music.bass.error.connected.description = You have to be in the same voice channel as the bot to change the bass level. -commands.music.bass.help.description = Change the bass for the song which is played at the moment. commands.music.join.success.title = Successfully connected commands.music.join.success.description = I successfully connected to %extra%. commands.music.join.error.connecting.already.title = Already connected diff --git a/src/main/resources/Translations/Translations_ru.properties b/src/main/resources/Translations/Translations_ru.properties index 5ca0715..9167e2d 100644 --- a/src/main/resources/Translations/Translations_ru.properties +++ b/src/main/resources/Translations/Translations_ru.properties @@ -174,9 +174,6 @@ commands.moderation.editrules.success.title = Successfully changed commands.moderation.editrules.success.description = I successfully changed the rules commands.moderation.editrules.help.description = Edits the rules message. -commands.music.bass.error.connected.title = No channel -commands.music.bass.error.connected.description = You have to be in the same voice channel as the bot to change the bass level. -commands.music.bass.help.description = Change the bass for the song which is played at the moment. commands.music.join.success.title = Successfully connected commands.music.join.success.description = I successfully connected to %extra%. commands.music.join.error.connecting.already.title = Already connected diff --git a/src/main/resources/Translations/Translations_tr.properties b/src/main/resources/Translations/Translations_tr.properties index 5ca0715..9167e2d 100644 --- a/src/main/resources/Translations/Translations_tr.properties +++ b/src/main/resources/Translations/Translations_tr.properties @@ -174,9 +174,6 @@ commands.moderation.editrules.success.title = Successfully changed commands.moderation.editrules.success.description = I successfully changed the rules commands.moderation.editrules.help.description = Edits the rules message. -commands.music.bass.error.connected.title = No channel -commands.music.bass.error.connected.description = You have to be in the same voice channel as the bot to change the bass level. -commands.music.bass.help.description = Change the bass for the song which is played at the moment. commands.music.join.success.title = Successfully connected commands.music.join.success.description = I successfully connected to %extra%. commands.music.join.error.connecting.already.title = Already connected diff --git a/src/main/resources/Translations/Translations_zh.properties b/src/main/resources/Translations/Translations_zh.properties index 5ca0715..9167e2d 100644 --- a/src/main/resources/Translations/Translations_zh.properties +++ b/src/main/resources/Translations/Translations_zh.properties @@ -174,9 +174,6 @@ commands.moderation.editrules.success.title = Successfully changed commands.moderation.editrules.success.description = I successfully changed the rules commands.moderation.editrules.help.description = Edits the rules message. -commands.music.bass.error.connected.title = No channel -commands.music.bass.error.connected.description = You have to be in the same voice channel as the bot to change the bass level. -commands.music.bass.help.description = Change the bass for the song which is played at the moment. commands.music.join.success.title = Successfully connected commands.music.join.success.description = I successfully connected to %extra%. commands.music.join.error.connecting.already.title = Already connected