Files
AllMusic/core/command/CommandHud.java
T

95 lines
3.3 KiB
Java
Raw Normal View History

2024-04-19 09:46:54 +08:00
package com.coloryr.allmusic.server.core.command;
2023-10-22 10:14:55 +08:00
2024-04-19 09:46:54 +08:00
import com.coloryr.allmusic.server.core.AllMusic;
import com.coloryr.allmusic.server.core.objs.enums.HudType;
2024-06-21 11:06:14 +08:00
import com.coloryr.allmusic.server.core.objs.message.PAL;
2024-04-19 09:46:54 +08:00
import com.coloryr.allmusic.server.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 {
2024-05-08 16:25:33 +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");
}};
2024-04-17 22:15:12 +08:00
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-05-08 16:25:33 +08:00
@Override
public void ex(Object sender, String name, String[] args) {
if (args.length == 1) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
} else {
ICommand command = commandList.get(args[1]);
if (command != null) {
command.ex(sender, name, args);
} else {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
}
}
}
@Override
public List<String> tab(String name, String[] args, int index) {
if (args.length == index + 1) {
return hudlist;
} else {
ICommand command = commandList.get(args[index]);
if (command != null) {
return command.tab(name, args, index + 1);
}
}
return Collections.emptyList();
}
2024-04-18 09:03:23 +08:00
public static class HudEnable extends ACommand {
2024-05-08 16:25:33 +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
@Override
public void ex(Object sender, String name, String[] args) {
2024-04-19 11:14:17 +08:00
if (args.length == 2 || args.length == 3) {
2024-04-18 09:03:23 +08:00
boolean temp = HudUtils.setHudEnable(name, null, args.length == 3 ? args[2] : null);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.state
2024-06-21 11:06:14 +08:00
.replace(PAL.state, temp ? "启用" : "关闭")
.replace(PAL.hud, AllMusic.getMessage().hudList.getHud(null)));
2024-04-18 09:03:23 +08:00
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
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
2024-06-21 11:06:14 +08:00
.replace(PAL.hud, AllMusic.getMessage().hudList.getHud(null)));
2023-10-22 10:14:55 +08:00
}
}
}