Refactored how the music handler was being referenced
Some checks failed
Locusworks Team/eight-track/pipeline/head There was a failure building this commit

This commit is contained in:
Isaac Parenteau
2020-01-06 21:22:54 -06:00
parent 4c68e6bf09
commit 2f89362a8b
25 changed files with 169 additions and 120 deletions

View File

@@ -53,7 +53,6 @@ import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.locusworks.discord.eighttrack.database.entities.DiscordGuild;
import net.locusworks.discord.eighttrack.events.main.AbstractMainEventHandler;
import net.locusworks.discord.eighttrack.services.ConfigurationService;
import net.locusworks.discord.eighttrack.services.GuildMusicService;
import net.locusworks.discord.eighttrack.services.RepositoryService;
import net.locusworks.logger.ApplicationLogger;
import net.locusworks.logger.ApplicationLoggerFactory;
@@ -153,21 +152,13 @@ public class DiscordEventHandler extends ListenerAdapter {
private void onGuildMessageReceivedHelper(GuildMessageReceivedEvent event) throws Exception {
if (!GuildMusicService.getMap().containsKey(event.getGuild().getIdLong())) {
GuildMusicService.getMap().put(event.getGuild().getIdLong(),
new GuildMusicHandler(event.getGuild().getIdLong(), guildSongRepoService));
}
GuildMusicHandler gmh = GuildMusicService.getMap().get(event.getGuild().getIdLong());
gmh.accept((id) -> GuildMusicService.getMap().remove(id));
List<String> commands = new ArrayList<String>(Arrays.asList(event.getMessage().getContentRaw().trim().toLowerCase().split(" ")));
String command = commands.remove(0);
AbstractMainEventHandler aeh = events.get(command.toLowerCase());
if (aeh != null) {
aeh.executeEvent(gmh, event, commands);
aeh.executeEvent(event, commands);
return;
}

View File

@@ -27,7 +27,6 @@
*/
package net.locusworks.discord.eighttrack.handlers;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Random;
@@ -68,7 +67,7 @@ public class GuildMusicHandler {
private TrackManager trackManager;
public GuildMusicHandler(long guildId, RepositoryService guildSongRepoService) throws IOException {
public GuildMusicHandler(long guildId, RepositoryService guildSongRepoService) {
this.logger = ApplicationLoggerFactory.getLogger(GuildMusicHandler.class);
this.playing = new AtomicBoolean(false);
this.lastPlayed = OffsetDateTime.now();