2025-08-28 13:49:55 +08:00
|
|
|
package com.coloryr.allmusic.server.core.command.sub;
|
2024-07-09 11:06:38 +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-07-09 11:06:38 +08:00
|
|
|
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
|
|
|
|
|
|
|
|
|
public class CommandTest extends ACommand {
|
|
|
|
|
@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-07-09 11:06:38 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-02-26 20:18:57 +08:00
|
|
|
|
|
|
|
|
String musicID = null;
|
|
|
|
|
IMusicApi api = null;
|
|
|
|
|
|
|
|
|
|
if (args.length == 2) {
|
|
|
|
|
api = AllMusic.MUSIC_APIS.get(AllMusic.getConfig().defaultApi);
|
|
|
|
|
musicID = args[1];
|
|
|
|
|
} 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (api.checkId(musicID)) {
|
2024-07-09 11:06:38 +08:00
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2正在测试解析" + args[1]);
|
|
|
|
|
try {
|
2026-02-26 20:18:57 +08:00
|
|
|
SongInfoObj info = api.getMusic(args[1], "test", false);
|
2024-07-09 11:06:38 +08:00
|
|
|
if (info == null) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2测试解析失败");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2音乐名称 " + info.getName());
|
|
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2音乐作者 " + info.getAuthor());
|
2026-02-26 20:18:57 +08:00
|
|
|
String url = api.getPlayUrl(args[1]);
|
2024-07-09 11:06:38 +08:00
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2播放地址 " + url);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2测试解析错误");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|