2025-08-28 13:49:55 +08:00
|
|
|
package com.coloryr.allmusic.server.core.command.sub;
|
2023-10-22 10:14:55 +08:00
|
|
|
|
2024-04-19 09:46:54 +08:00
|
|
|
import com.coloryr.allmusic.server.core.AllMusic;
|
2026-02-26 20:18:57 +08:00
|
|
|
import com.coloryr.allmusic.server.core.IMusicApi;
|
2025-08-28 13:49:55 +08:00
|
|
|
import com.coloryr.allmusic.server.core.command.ACommand;
|
2024-04-19 09:46:54 +08:00
|
|
|
import com.coloryr.allmusic.server.core.utils.Function;
|
2023-10-22 10:14:55 +08:00
|
|
|
|
2024-04-17 22:15:12 +08:00
|
|
|
public class CommandAddList extends ACommand {
|
2023-10-22 10:14:55 +08:00
|
|
|
@Override
|
2025-01-19 22:51:01 +08:00
|
|
|
public void execute(Object sender, String name, String[] args) {
|
2026-02-26 20:18:57 +08:00
|
|
|
if (args.length < 2) {
|
2024-04-17 22:15:12 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
2023-10-22 10:14:55 +08:00
|
|
|
return;
|
|
|
|
|
}
|
2024-05-13 09:33:41 +08:00
|
|
|
|
2026-02-26 20:18:57 +08:00
|
|
|
String musicID = null;
|
|
|
|
|
IMusicApi api = null;
|
2024-05-13 09:33:41 +08:00
|
|
|
|
2026-02-26 20:18:57 +08:00
|
|
|
if (args.length == 2) {
|
|
|
|
|
api = AllMusic.MUSIC_APIS.get(AllMusic.getConfig().defaultApi);
|
2024-05-13 09:33:41 +08:00
|
|
|
musicID = args[1];
|
2026-02-26 20:18:57 +08:00
|
|
|
} else if (args.length == 3) {
|
|
|
|
|
api = AllMusic.MUSIC_APIS.get(args[1]);
|
|
|
|
|
musicID = args[2];
|
|
|
|
|
} else {
|
|
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2错误的指令");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (api == null) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().musicPlay.error2);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
musicID = api.getMusicId(musicID);
|
2024-05-13 09:33:41 +08:00
|
|
|
|
2026-02-26 20:18:57 +08:00
|
|
|
if (api.checkId(musicID)) {
|
|
|
|
|
api.setList(musicID, sender);
|
2024-05-13 09:33:41 +08:00
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2添加空闲音乐列表" + musicID);
|
2023-10-22 10:14:55 +08:00
|
|
|
} else {
|
2024-04-17 22:15:12 +08:00
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2请输入有效的音乐列表ID");
|
2023-10-22 10:14:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|