Compare commits

...

3 Commits

12 changed files with 32 additions and 32 deletions

View File

@ -8,10 +8,8 @@ package moe.nekojimi.chords;
import com.amihaiemil.eoyaml.Yaml;
import com.amihaiemil.eoyaml.YamlMapping;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.neovisionaries.ws.client.WebSocketFactory;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.net.*;
import java.nio.file.Files;
@ -22,8 +20,6 @@ import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import javax.security.auth.login.LoginException;
import moe.nekojimi.chords.commands.*;
import moe.nekojimi.musicsearcher.providers.MetaSearcher;
@ -40,10 +36,11 @@ import net.dv8tion.jda.api.utils.Compression;
import net.dv8tion.jda.api.utils.cache.CacheFlag;
/**
* The Chords music Discord bot.
*
* @author jimj316
* @author Nekojimi
*/
public final class Main extends ListenerAdapter
public final class Chords extends ListenerAdapter
{
private static final CommandOptions options = new CommandOptions();
@ -99,7 +96,7 @@ public final class Main extends ListenerAdapter
// Set activity (like "playing Something")
builder.setActivity(Activity.playing("music!"));
final Main listener = new Main();
final Chords listener = new Chords();
builder.addEventListeners(listener);
builder.setAutoReconnect(true);
@ -120,7 +117,7 @@ public final class Main extends ListenerAdapter
private final BiConsumer<SongRequest, Exception> downloaderMessageHandler = new DownloaderMessageHandler();
public Main() throws IOException
public Chords() throws IOException
{
log("INFO", "Starting up...");
@ -362,7 +359,7 @@ public final class Main extends ListenerAdapter
playlists.put(playlist.getName(), playlist);
} catch (IOException ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

View File

@ -112,7 +112,7 @@ public class MusicHandler implements AudioSendHandler, Closeable
return true;
} catch (UnsupportedAudioFileException | IOException ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
} finally
{
}
@ -215,7 +215,7 @@ public class MusicHandler implements AudioSendHandler, Closeable
// audioBuffer.add(bytes, 0, read);
// } catch (IOException ex)
// {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
// Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
// return false;
// } catch (ArrayIndexOutOfBoundsException ex)
// {
@ -223,7 +223,7 @@ public class MusicHandler implements AudioSendHandler, Closeable
// arrayErr = true;
// else
// {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
// Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
// return false;
// }
// }

View File

@ -42,8 +42,11 @@ public class QueueManager implements Consumer<Song>
{
jukeboxQueue.add(t);
if (!handler.isPlaying())
if (!handler.isPlaying() || handler.getCurrentSong() == null)
handler.playNext();
if (handler.isPlaying() != (handler.getCurrentSong() == null))
System.err.println("WARNING: handler isPlaying violates contract! Something dumb going on!");
}
/**

View File

@ -5,7 +5,7 @@
*/
package moe.nekojimi.chords.commands;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
/**
*
@ -14,11 +14,11 @@ import moe.nekojimi.chords.Main;
public abstract class Command
{
protected final Main bot;
protected final Chords bot;
protected final String keyword;
protected String documentation;
public Command(Main bot, String keyword)
public Command(Chords bot, String keyword)
{
this.bot = bot;
this.keyword = keyword;

View File

@ -16,12 +16,12 @@
*/
package moe.nekojimi.chords.commands;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
public class HelpCommand extends Command
{
public HelpCommand(Main bot)
public HelpCommand(Chords bot)
{
super(bot, "help");
}

View File

@ -6,14 +6,14 @@
package moe.nekojimi.chords.commands;
import java.util.List;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
public class JoinCommand extends Command
{
public JoinCommand(Main bot)
public JoinCommand(Chords bot)
{
super(bot, "join");
}

View File

@ -6,13 +6,13 @@
package moe.nekojimi.chords.commands;
import java.util.List;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
public class LeaveCommand extends Command
{
public LeaveCommand(Main bot)
public LeaveCommand(Chords bot)
{
super(bot, "leave");
}

View File

@ -21,7 +21,7 @@ import java.net.URL;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
import moe.nekojimi.chords.SongRequest;
import moe.nekojimi.musicsearcher.Query;
import moe.nekojimi.musicsearcher.Result;
@ -37,7 +37,7 @@ public class PlayCommand extends Command
// private List<Result> lastSearchResults;
public PlayCommand(Main main)
public PlayCommand(Chords main)
{
super(main, "play");
}

View File

@ -19,13 +19,13 @@ package moe.nekojimi.chords.commands;
import java.util.List;
import java.util.Queue;
import moe.nekojimi.chords.Downloader;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
import moe.nekojimi.chords.Song;
public class QueueCommand extends Command
{
public QueueCommand(Main bot)
public QueueCommand(Chords bot)
{
super(bot, "queue");
}

View File

@ -16,12 +16,12 @@
*/
package moe.nekojimi.chords.commands;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
public class RemoveCommand extends Command
{
public RemoveCommand(Main bot)
public RemoveCommand(Chords bot)
{
super(bot, "remove");
}

View File

@ -16,12 +16,12 @@
*/
package moe.nekojimi.chords.commands;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
public class RestartCommand extends Command
{
public RestartCommand(Main bot)
public RestartCommand(Chords bot)
{
super(bot, "restart");
}

View File

@ -16,12 +16,12 @@
*/
package moe.nekojimi.chords.commands;
import moe.nekojimi.chords.Main;
import moe.nekojimi.chords.Chords;
public class SkipCommand extends Command
{
public SkipCommand(Main bot)
public SkipCommand(Chords bot)
{
super(bot, "skip");
}