2025-08-28 13:49:55 +08:00
|
|
|
package com.coloryr.allmusic.server.core.command.sub;
|
2024-04-17 22:15:12 +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.AHudCommand;
|
|
|
|
|
import com.coloryr.allmusic.server.core.command.ICommand;
|
2024-04-19 09:46:54 +08:00
|
|
|
import com.coloryr.allmusic.server.core.objs.enums.HudDirType;
|
2024-04-19 11:14:17 +08:00
|
|
|
import com.coloryr.allmusic.server.core.objs.enums.HudType;
|
2024-04-19 09:46:54 +08:00
|
|
|
import com.coloryr.allmusic.server.core.objs.hud.PosObj;
|
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;
|
2024-04-17 22:15:12 +08:00
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
public class CommandHudSet extends AHudCommand {
|
2024-05-08 16:25:33 +08:00
|
|
|
/**
|
|
|
|
|
* Hud的指令
|
|
|
|
|
*/
|
|
|
|
|
private static final List<String> hud = new ArrayList<String>() {{
|
|
|
|
|
this.add("enable");
|
|
|
|
|
this.add("pos");
|
|
|
|
|
this.add("dir");
|
|
|
|
|
this.add("reset");
|
|
|
|
|
}};
|
|
|
|
|
private static final List<String> pic = new ArrayList<String>() {{
|
|
|
|
|
this.add("size");
|
|
|
|
|
this.add("rotate");
|
|
|
|
|
this.add("speed");
|
|
|
|
|
}};
|
|
|
|
|
private static final List<String> info = new ArrayList<String>() {{
|
|
|
|
|
this.add("color");
|
|
|
|
|
this.add("shadow");
|
|
|
|
|
}};
|
|
|
|
|
private static final List<String> tf = new ArrayList<String>() {{
|
|
|
|
|
this.add("true");
|
|
|
|
|
this.add("false");
|
|
|
|
|
}};
|
2024-04-17 22:15:12 +08:00
|
|
|
private final Map<String, ICommand> commandList = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
public CommandHudSet(HudType type) {
|
|
|
|
|
super(type);
|
|
|
|
|
commandList.put("enable", new HudEnable(type));
|
|
|
|
|
commandList.put("reset", new HudReset(type));
|
|
|
|
|
commandList.put("pos", new HudPos(type));
|
|
|
|
|
commandList.put("dir", new HudDir(type));
|
|
|
|
|
if (type == HudType.PIC) {
|
|
|
|
|
commandList.put("size", new PicSize());
|
|
|
|
|
commandList.put("rotate", new PicRotate());
|
|
|
|
|
commandList.put("speed", new PicRotateSpeed());
|
|
|
|
|
} else {
|
|
|
|
|
commandList.put("color", new HudColor(type));
|
2024-04-19 09:46:54 +08:00
|
|
|
commandList.put("shadow", new HudShadow(type));
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-08 16:25:33 +08:00
|
|
|
@Override
|
2025-01-19 22:51:01 +08:00
|
|
|
public void execute(Object sender, String name, String[] args) {
|
2024-07-09 11:06:38 +08:00
|
|
|
if (args.length == 2) {
|
2024-05-08 16:25:33 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
} else {
|
|
|
|
|
ICommand command = commandList.get(args[2]);
|
|
|
|
|
if (command != null) {
|
2025-01-19 22:51:01 +08:00
|
|
|
command.execute(sender, name, args);
|
2024-05-08 16:25:33 +08:00
|
|
|
} else {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-09 21:24:18 +08:00
|
|
|
public List<String> tab(Object player, String name, String[] args, int index) {
|
2024-05-08 16:25:33 +08:00
|
|
|
if (args.length == index + 1) {
|
|
|
|
|
List<String> list = new ArrayList<>(hud);
|
|
|
|
|
if (type == HudType.PIC) {
|
|
|
|
|
list.addAll(pic);
|
|
|
|
|
} else {
|
|
|
|
|
list.addAll(info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
} else {
|
|
|
|
|
ICommand command = commandList.get(args[index]);
|
|
|
|
|
if (command != null) {
|
2025-03-09 21:24:18 +08:00
|
|
|
return command.tab(player, name, args, index + 1);
|
2024-05-08 16:25:33 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-17 22:15:12 +08:00
|
|
|
private static class HudEnable extends AHudCommand {
|
|
|
|
|
public HudEnable(HudType type) {
|
|
|
|
|
super(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-01-19 22:51:01 +08:00
|
|
|
public void execute(Object sender, String name, String[] args) {
|
2024-04-19 11:14:17 +08:00
|
|
|
if (args.length == 3 || args.length == 4) {
|
2024-04-18 09:03:23 +08:00
|
|
|
boolean temp = HudUtils.setHudEnable(name, type, args.length == 4 ? args[3] : null);
|
2025-03-24 18:20:45 +08:00
|
|
|
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().hud.state
|
2024-06-21 11:06:14 +08:00
|
|
|
.replace(PAL.state, temp
|
2024-04-18 09:03:23 +08:00
|
|
|
? AllMusic.getMessage().hudList.enable
|
|
|
|
|
: AllMusic.getMessage().hudList.disable)
|
2024-06-21 11:06:14 +08:00
|
|
|
.replace(PAL.hud, AllMusic.getMessage().hudList.getHud(type)));
|
2024-04-18 09:03:23 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-09 21:24:18 +08:00
|
|
|
public List<String> tab(Object player, String name, String[] args, int index) {
|
2024-04-18 09:03:23 +08:00
|
|
|
if (args.length == index + 1) {
|
|
|
|
|
return tf;
|
|
|
|
|
}
|
|
|
|
|
return Collections.emptyList();
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class HudReset extends AHudCommand {
|
|
|
|
|
public HudReset(HudType type) {
|
|
|
|
|
super(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
HudUtils.reset(name, type);
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.reset
|
2024-06-21 11:06:14 +08:00
|
|
|
.replace(PAL.hud, AllMusic.getMessage().hudList.getHud(type)));
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class HudPos extends AHudCommand {
|
|
|
|
|
public HudPos(HudType type) {
|
|
|
|
|
super(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
try {
|
|
|
|
|
if (args.length != 5) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PosObj obj = HudUtils.setHudPos(name, type, args[3], args[4]);
|
|
|
|
|
if (obj == null) {
|
2025-03-24 18:20:45 +08:00
|
|
|
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().command.error);
|
2024-04-17 22:15:12 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-24 18:20:45 +08:00
|
|
|
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().hud.set
|
2024-06-21 11:06:14 +08:00
|
|
|
.replace(PAL.hud, AllMusic.getMessage().hudList.getHud(type))
|
|
|
|
|
.replace(PAL.x, args[3])
|
|
|
|
|
.replace(PAL.y, args[4]));
|
2024-04-17 22:15:12 +08:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class HudDir extends AHudCommand {
|
2024-05-08 16:25:33 +08:00
|
|
|
private static final List<String> dir = new ArrayList<String>() {{
|
|
|
|
|
for (HudDirType type : HudDirType.values()) {
|
|
|
|
|
this.add(type.name());
|
|
|
|
|
}
|
|
|
|
|
}};
|
|
|
|
|
|
2024-04-17 22:15:12 +08:00
|
|
|
public HudDir(HudType type) {
|
|
|
|
|
super(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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 (args.length != 4) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
HudDirType type1 = HudUtils.setDir(name, type, args[3]);
|
|
|
|
|
if (type1 == null) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.set1
|
2024-06-21 11:06:14 +08:00
|
|
|
.replace(PAL.hud, AllMusic.getMessage().hudList.getHud(type))
|
|
|
|
|
.replace(PAL.dir, AllMusic.getMessage().hudList.getDir(type1)));
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-09 21:24:18 +08:00
|
|
|
public List<String> tab(Object player, String name, String[] args, int index) {
|
2024-04-18 09:03:23 +08:00
|
|
|
if (args.length == index + 1) {
|
2024-04-17 22:15:12 +08:00
|
|
|
return dir;
|
|
|
|
|
}
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class HudColor extends AHudCommand {
|
|
|
|
|
public HudColor(HudType type) {
|
|
|
|
|
super(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-01-19 22:51:01 +08:00
|
|
|
public void execute(Object sender, String name, String[] args) {
|
2024-04-17 23:43:11 +08:00
|
|
|
if (args.length != 4) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-04-17 22:15:12 +08:00
|
|
|
if (!HudUtils.setColor(name, type, args[3])) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.set2
|
2024-06-21 11:06:14 +08:00
|
|
|
.replace(PAL.hud, AllMusic.getMessage().hudList.getHud(type))
|
|
|
|
|
.replace(PAL.color, args[3]));
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-19 09:46:54 +08:00
|
|
|
private static class HudShadow extends AHudCommand {
|
|
|
|
|
public HudShadow(HudType type) {
|
|
|
|
|
super(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-01-19 22:51:01 +08:00
|
|
|
public void execute(Object sender, String name, String[] args) {
|
2024-04-19 09:46:54 +08:00
|
|
|
if (args.length == 3 || args.length == 4) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.set3
|
2024-06-21 11:06:14 +08:00
|
|
|
.replace(PAL.hud, AllMusic.getMessage().hudList.getHud(type))
|
|
|
|
|
.replace(PAL.state, HudUtils.setShadow(name, type, args.length == 4 ? args[3] : null)
|
2024-04-19 09:46:54 +08:00
|
|
|
? AllMusic.getMessage().hudList.enable
|
|
|
|
|
: AllMusic.getMessage().hudList.disable));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-09 21:24:18 +08:00
|
|
|
public List<String> tab(Object player, String name, String[] args, int index) {
|
2024-04-19 09:46:54 +08:00
|
|
|
if (args.length == index + 1) {
|
|
|
|
|
return tf;
|
|
|
|
|
}
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-18 09:03:23 +08:00
|
|
|
private static class PicSize extends ACommand {
|
2024-04-17 22:15:12 +08:00
|
|
|
@Override
|
2025-01-19 22:51:01 +08:00
|
|
|
public void execute(Object sender, String name, String[] args) {
|
2024-09-03 11:19:15 +08:00
|
|
|
if (args.length != 4 || !HudUtils.setPicSize(name, args[3])) {
|
2024-04-17 22:15:12 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllMusic.side.sendMessage(sender,
|
2024-06-21 11:06:14 +08:00
|
|
|
AllMusic.getMessage().hud.picSize.replace(PAL.size, args[2]));
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class PicRotate extends ACommand {
|
|
|
|
|
@Override
|
2025-01-19 22:51:01 +08:00
|
|
|
public void execute(Object sender, String name, String[] args) {
|
2024-04-18 09:03:23 +08:00
|
|
|
if (args.length == 3 || args.length == 4) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.picRotate
|
2024-06-21 11:06:14 +08:00
|
|
|
.replace(PAL.state, HudUtils.setPicRotate(name, args.length == 4 ? args[3] : null)
|
2024-04-18 09:03:23 +08:00
|
|
|
? AllMusic.getMessage().hudList.enable
|
|
|
|
|
: AllMusic.getMessage().hudList.disable));
|
2024-04-17 22:15:12 +08:00
|
|
|
return;
|
|
|
|
|
}
|
2024-04-18 09:03:23 +08:00
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-09 21:24:18 +08:00
|
|
|
public List<String> tab(Object player, String name, String[] args, int index) {
|
2024-04-18 09:03:23 +08:00
|
|
|
if (args.length == index + 1) {
|
|
|
|
|
return tf;
|
|
|
|
|
}
|
|
|
|
|
return Collections.emptyList();
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class PicRotateSpeed extends ACommand {
|
|
|
|
|
@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 (args.length != 4 || !HudUtils.setPicRotateSpeed(name, args[3])) {
|
|
|
|
|
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllMusic.side.sendMessage(sender,
|
2024-06-21 11:06:14 +08:00
|
|
|
AllMusic.getMessage().hud.picSpeed.replace(PAL.size, args[3]));
|
2024-04-17 22:15:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|