Files
AllMusic/core/command/CommandHud.java
T

95 lines
3.2 KiB
Java
Raw Normal View History

2023-10-22 10:14:55 +08:00
package coloryr.allmusic.core.command;
import coloryr.allmusic.core.AllMusic;
2024-04-17 22:15:12 +08:00
import coloryr.allmusic.core.objs.enums.HudType;
import coloryr.allmusic.core.utils.HudUtils;
2023-10-22 10:14:55 +08:00
2024-04-17 22:15:12 +08:00
import java.util.*;
2023-10-22 10:14:55 +08:00
2024-04-17 22:15:12 +08:00
public class CommandHud extends ACommand {
private final Map<String, ICommand> commandList = new HashMap<>();
2023-10-22 10:14:55 +08:00
public CommandHud() {
2024-04-17 22:15:12 +08:00
commandList.put("enable", new HudEnable());
commandList.put("reset", new HudReset());
commandList.put("info", new CommandHudSet(HudType.INFO));
commandList.put("list", new CommandHudSet(HudType.LIST));
commandList.put("lyric", new CommandHudSet(HudType.LYRIC));
commandList.put("pic", new CommandHudSet(HudType.PIC));
2023-10-22 10:14:55 +08:00
}
2024-04-18 09:03:23 +08:00
public static class HudEnable extends ACommand {
2023-10-22 10:14:55 +08:00
@Override
public void ex(Object sender, String name, String[] args) {
2024-04-18 09:03:23 +08:00
if(args.length == 2 || args.length == 3) {
boolean temp = HudUtils.setHudEnable(name, null, args.length == 3 ? args[2] : null);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.state
.replace("%State%", temp ? "启用" : "关闭")
.replace("%Hud%", AllMusic.getMessage().hudList.getHud(null)));
return;
}
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
2023-10-22 10:14:55 +08:00
}
@Override
2024-04-18 09:03:23 +08:00
public List<String> tab(String name, String[] args, int index) {
if (args.length == index + 1) {
return tf;
}
2024-04-17 22:15:12 +08:00
return Collections.emptyList();
2023-10-22 10:14:55 +08:00
}
2024-04-18 09:03:23 +08:00
private static final List<String> tf = new ArrayList<String>() {{
this.add("true");
this.add("false");
}};
2023-10-22 10:14:55 +08:00
}
2024-04-18 09:03:23 +08:00
public static class HudReset extends ACommand {
2023-10-22 10:14:55 +08:00
@Override
public void ex(Object sender, String name, String[] args) {
2024-04-17 22:15:12 +08:00
HudUtils.reset(name);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.reset
.replace("%Hud%", AllMusic.getMessage().hudList.getHud(null)));
2023-10-22 10:14:55 +08:00
}
}
@Override
public void ex(Object sender, String name, String[] args) {
if (args.length == 1) {
2024-04-17 22:15:12 +08:00
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
2023-10-22 10:14:55 +08:00
} else {
2024-04-17 22:15:12 +08:00
ICommand command = commandList.get(args[1]);
2023-10-22 10:14:55 +08:00
if (command != null) {
command.ex(sender, name, args);
} else {
2024-04-17 22:15:12 +08:00
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
2023-10-22 10:14:55 +08:00
}
}
}
2024-04-17 22:15:12 +08:00
/**
* Hud的指令
*/
private static final List<String> hudlist = new ArrayList<String>() {{
this.add("enable");
this.add("reset");
this.add("info");
this.add("list");
this.add("lyric");
this.add("pic");
}};
@Override
2024-04-18 09:03:23 +08:00
public List<String> tab(String name, String[] args, int index) {
if (args.length == index + 1) {
2024-04-17 22:15:12 +08:00
return hudlist;
2024-04-18 09:03:23 +08:00
} else {
ICommand command = commandList.get(args[index]);
2024-04-17 23:43:11 +08:00
if (command != null) {
2024-04-18 09:03:23 +08:00
return command.tab(name, args, index + 1);
2024-04-17 23:43:11 +08:00
}
2024-04-17 22:15:12 +08:00
}
return Collections.emptyList();
}
2023-10-22 10:14:55 +08:00
}