Lib39/src/main/java/top/r3944realms/lib39/api/event/RegisterCommandHelpEvent.java
3944Realms c0a25f9172 更新内容
1. 初始化部分JavaDoc
2025-12-23 20:39:27 +08:00

101 lines
2.9 KiB
Java

package top.r3944realms.lib39.api.event;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.eventbus.api.Event;
import top.r3944realms.lib39.core.command.ICommandHelpManager;
import top.r3944realms.lib39.core.command.model.CommandNode;
import top.r3944realms.lib39.core.command.model.CommandPath;
import top.r3944realms.lib39.core.command.model.Parameter;
/**
* The type Register command help event.
*/
public class RegisterCommandHelpEvent extends Event {
private final LiteralArgumentBuilder<CommandSourceStack> builder;
private final ICommandHelpManager helpManager;
private final CommandBuildContext context;
/**
* Instantiates a new Register command help event.
*
* @param builder the builder
* @param helpManager the help manager
* @param source the source
*/
public RegisterCommandHelpEvent(LiteralArgumentBuilder<CommandSourceStack> builder, ICommandHelpManager helpManager, CommandBuildContext source) {
this.builder = builder;
this.helpManager = helpManager;
this.context = source;
}
/**
* Gets id.
*
* @return the id
*/
public ResourceLocation getID() {
return helpManager.getID();
}
/**
* Add child.
*
* @param child the child
*/
public void addChild(LiteralArgumentBuilder<CommandSourceStack> child) {
this.builder.then(child);
}
/**
* Get context command build context.
*
* @return the command build context
*/
public CommandBuildContext getContext(){
return this.context;
}
/**
* Get tree literal argument builder.
*
* @return the literal argument builder
*/
public LiteralArgumentBuilder<CommandSourceStack> getTree(){
return this.builder;
}
/**
* 注册命令帮助信息
*
* @param CommandNode 命令节点
* @param description 命令描述
*/
public void registerHelp(CommandNode CommandNode, MutableComponent description) {
this.helpManager.registerCommandHelp(CommandNode, description);
}
/**
* 注册命令帮助信息
*
* @param CommandNode 命令节点
* @param descriptionKey 命令描述的语言键
*/
public void registerHelp(CommandNode CommandNode, String descriptionKey) {
this.helpManager.registerCommandHelp(CommandNode, descriptionKey);
}
/**
* 注册命令参数
*
* @param commandPath 命令节点
* @param parametersBuilder 参数列表构造器
*/
public void registerParameters(CommandPath commandPath, Parameter.Builder parametersBuilder) {
this.helpManager.registerCommandParameters(commandPath, parametersBuilder);
}
}