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;
|
2025-08-28 13:49:55 +08:00
|
|
|
import com.coloryr.allmusic.server.core.command.ACommand;
|
|
|
|
|
import com.coloryr.allmusic.server.core.command.CommandEX;
|
|
|
|
|
import com.coloryr.allmusic.server.core.command.PermissionList;
|
2025-09-24 22:16:24 +08:00
|
|
|
import com.coloryr.allmusic.server.core.objs.message.ARG;
|
2024-04-19 09:46:54 +08:00
|
|
|
import com.coloryr.allmusic.server.core.objs.music.SearchPageObj;
|
2025-03-24 18:20:45 +08:00
|
|
|
import com.coloryr.allmusic.server.core.sql.DataSql;
|
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
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class CommandSelect 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) {
|
2024-04-17 22:15:12 +08:00
|
|
|
if (AllMusic.getConfig().needPermission &&
|
2025-08-28 13:49:55 +08:00
|
|
|
!AllMusic.side.checkPermission(sender, PermissionList.PERMISSION_SEARCH)) {
|
2024-04-17 22:15:12 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().search.noPer);
|
2023-10-22 10:14:55 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SearchPageObj obj = AllMusic.getSearch(name);
|
|
|
|
|
if (obj == null) {
|
2024-04-17 22:15:12 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().search.emptySearch);
|
2023-10-22 10:14:55 +08:00
|
|
|
} else if (!args[1].isEmpty() && Function.isInteger(args[1])) {
|
|
|
|
|
int a = Integer.parseInt(args[1]);
|
|
|
|
|
if (a == 0) {
|
2024-04-17 22:15:12 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().search.errorNum);
|
2023-10-22 10:14:55 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String[] ID = new String[1];
|
|
|
|
|
ID[0] = obj.getSong((obj.getPage() * 10) + (a - 1));
|
|
|
|
|
AllMusic.side.sendMessage(sender,
|
2025-09-24 22:16:24 +08:00
|
|
|
AllMusic.getMessage().search.choice.replace(ARG.index, "" + a));
|
2025-03-24 18:20:45 +08:00
|
|
|
DataSql.task(() -> CommandEX.addMusic(sender, name, ID));
|
2023-10-22 10:14:55 +08:00
|
|
|
AllMusic.removeSearch(name);
|
|
|
|
|
} else {
|
2024-04-17 22:15:12 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().search.errorNum);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-09 21:24:18 +08:00
|
|
|
public List<String> tab(Object player, String name, String[] args, int index) {
|
2025-07-31 13:45:43 +08:00
|
|
|
if (args.length == 1 || (args.length == 2 )) {
|
2024-04-17 22:15:12 +08:00
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
SearchPageObj obj = AllMusic.getSearch(name);
|
|
|
|
|
if (obj != null) {
|
|
|
|
|
for (int a = 0; a < obj.getIndex(); a++) {
|
2025-07-31 13:45:43 +08:00
|
|
|
list.add(String.valueOf(a+1));
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
2023-10-22 10:14:55 +08:00
|
|
|
}
|
2024-04-17 22:15:12 +08:00
|
|
|
return Collections.emptyList();
|
2023-10-22 10:14:55 +08:00
|
|
|
}
|
|
|
|
|
}
|