parent
c08b7c955f
commit
a451369c92
@ -0,0 +1,66 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2022 jimj316 |
||||||
|
* |
||||||
|
* This program is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* This program is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package moe.nekojimi.chords.commands.playlists; |
||||||
|
|
||||||
|
import java.net.MalformedURLException; |
||||||
|
import java.net.URL; |
||||||
|
import java.util.logging.Level; |
||||||
|
import java.util.logging.Logger; |
||||||
|
import moe.nekojimi.chords.Main; |
||||||
|
import moe.nekojimi.chords.Playlist; |
||||||
|
import moe.nekojimi.chords.SongRequest; |
||||||
|
import moe.nekojimi.chords.commands.Command; |
||||||
|
import moe.nekojimi.chords.commands.Invocation; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @author jimj316 |
||||||
|
*/ |
||||||
|
public class AddToPlaylistCommand extends Command |
||||||
|
{ |
||||||
|
|
||||||
|
public AddToPlaylistCommand(Main bot) |
||||||
|
{ |
||||||
|
super(bot, "addlist"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void call(Invocation invocation) |
||||||
|
{ |
||||||
|
String playlistName = invocation.getArgs().get(0); |
||||||
|
Playlist playlist = bot.getPlaylists().get(playlistName); |
||||||
|
if (playlist == null) |
||||||
|
{ |
||||||
|
invocation.respond("There's no playlist named \"" + playlistName + "\"!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
URL url = new URL(invocation.getArgs().get(1)); |
||||||
|
final SongRequest request = new SongRequest(); |
||||||
|
request.setInvocation(invocation); |
||||||
|
request.setUrl(url); |
||||||
|
bot.queueDownload(request, playlist); |
||||||
|
} catch (MalformedURLException ex) |
||||||
|
{ |
||||||
|
invocation.respond("That's not a valid URL!"); |
||||||
|
Logger.getLogger(AddToPlaylistCommand.class.getName()).log(Level.SEVERE, null, ex); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2022 jimj316 |
||||||
|
* |
||||||
|
* This program is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* This program is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package moe.nekojimi.chords.commands.playlists; |
||||||
|
|
||||||
|
import moe.nekojimi.chords.Main; |
||||||
|
import moe.nekojimi.chords.Playlist; |
||||||
|
import moe.nekojimi.chords.commands.Command; |
||||||
|
import moe.nekojimi.chords.commands.Invocation; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @author jimj316 |
||||||
|
*/ |
||||||
|
public class MakePlaylistCommand extends Command |
||||||
|
{ |
||||||
|
|
||||||
|
public MakePlaylistCommand(Main bot) |
||||||
|
{ |
||||||
|
super(bot, "makelist"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void call(Invocation invocation) |
||||||
|
{ |
||||||
|
String name = invocation.getArgs().get(0); |
||||||
|
if (bot.getPlaylists().containsKey(name)) |
||||||
|
{ |
||||||
|
invocation.respond("There's already a playlist named \"" + name + "\"!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
Playlist list = new Playlist(name); |
||||||
|
bot.addPlaylist(list); |
||||||
|
|
||||||
|
invocation.respond("Playlist created!"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2022 jimj316 |
||||||
|
* |
||||||
|
* This program is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* This program is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package moe.nekojimi.chords.commands.playlists; |
||||||
|
|
||||||
|
import moe.nekojimi.chords.Main; |
||||||
|
import moe.nekojimi.chords.Playlist; |
||||||
|
import moe.nekojimi.chords.commands.Command; |
||||||
|
import moe.nekojimi.chords.commands.Invocation; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @author jimj316 |
||||||
|
*/ |
||||||
|
public class PlaylistCommand extends Command |
||||||
|
{ |
||||||
|
|
||||||
|
public PlaylistCommand(Main bot) |
||||||
|
{ |
||||||
|
super(bot, "playlist"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void call(Invocation invocation) |
||||||
|
{ |
||||||
|
String name = invocation.getArgs().get(0); |
||||||
|
Playlist list = bot.getPlaylists().get(name); |
||||||
|
if (list == null) |
||||||
|
{ |
||||||
|
invocation.respond("There's no playlist named \"" + name + "\"!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
bot.getQueueManager().setPlaylist(list); |
||||||
|
invocation.respond("Playing from list \"" + name + "\"!"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2022 jimj316 |
||||||
|
* |
||||||
|
* This program is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* This program is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package moe.nekojimi.chords.commands.playlists; |
||||||
|
|
||||||
|
import moe.nekojimi.chords.Main; |
||||||
|
import moe.nekojimi.chords.commands.Command; |
||||||
|
import moe.nekojimi.chords.commands.Invocation; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @author jimj316 |
||||||
|
*/ |
||||||
|
public class StopPlaylistCommand extends Command |
||||||
|
{ |
||||||
|
|
||||||
|
public StopPlaylistCommand(Main bot) |
||||||
|
{ |
||||||
|
super(bot, "stoplist"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void call(Invocation invocation) |
||||||
|
{ |
||||||
|
if (bot.getQueueManager().getPlaylist() == null) |
||||||
|
{ |
||||||
|
invocation.respond("There's no playlist running!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
bot.getQueueManager().setPlaylist(null); |
||||||
|
invocation.respond("Playlist stopped!"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue