cn.nukkit.command.defaults.DebugCommand Maven / Gradle / Ivy
package cn.nukkit.command.defaults;
import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;
import cn.nukkit.command.CommandSender;
import cn.nukkit.command.data.CommandEnum;
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.command.tree.ParamList;
import cn.nukkit.command.utils.CommandLogger;
import cn.nukkit.entity.ai.EntityAI;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
@PowerNukkitXOnly
@Since("1.19.50-r1")
public class DebugCommand extends TestCommand implements CoreCommand {
public DebugCommand(String name) {
super(name, "commands.debug.description");
this.setPermission("nukkit.command.debug");
this.commandParameters.clear();
//生物AI debug模式开关
this.commandParameters.put("entity", new CommandParameter[]{
CommandParameter.newEnum("entity", new String[]{"entity"}),
CommandParameter.newEnum("option", Arrays.stream(EntityAI.DebugOption.values()).map(option -> option.name().toLowerCase()).toList().toArray(new String[0])),
CommandParameter.newEnum("value", false, CommandEnum.ENUM_BOOLEAN)
});
this.enableParamTree();
}
@Since("1.19.60-r1")
@Override
public int execute(CommandSender sender, String commandLabel, Map.Entry result, CommandLogger log) {
var list = result.getValue();
switch (result.getKey()) {
case "entity" -> {
String str = list.getResult(1);
var option = EntityAI.DebugOption.valueOf(str.toUpperCase(Locale.ENGLISH));
boolean value = list.getResult(2);
EntityAI.setDebugOption(option, value);
log.addSuccess("Entity AI framework " + option.name() + " debug mode have been set to: " + EntityAI.checkDebugOption(option)).output();
return 1;
}
default -> {
return 0;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy