package com.coloryr.allmusic.server.core.command; import com.coloryr.allmusic.server.core.AllMusic; import com.coloryr.allmusic.server.core.objs.enums.HudType; import com.coloryr.allmusic.server.core.utils.HudUtils; import java.util.*; public class CommandHud extends ACommand { private final Map commandList = new HashMap<>(); public CommandHud() { 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)); } public static class HudEnable extends ACommand { @Override public void ex(Object sender, String name, String[] args) { 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); } @Override public List tab(String name, String[] args, int index) { if (args.length == index + 1) { return tf; } return Collections.emptyList(); } private static final List tf = new ArrayList() {{ this.add("true"); this.add("false"); }}; } public static class HudReset extends ACommand { @Override public void ex(Object sender, String name, String[] args) { HudUtils.reset(name); AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.reset .replace("%Hud%", AllMusic.getMessage().hudList.getHud(null))); } } @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); } } } /** * Hud的指令 */ private static final List hudlist = new ArrayList() {{ this.add("enable"); this.add("reset"); this.add("info"); this.add("list"); this.add("lyric"); this.add("pic"); }}; @Override public List 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(); } }