CommandModel

基本信息

属性 值
类 mypermissions.command.core.entities.CommandModel
继承 net.minecraft.command.CommandBase
实现 net.minecraftforge.permission.PermissionObject(ForgeEssentials 兼容时 optional 注入)

功能

把 CommandTree 适配为 Minecraft 的 ICommand。CommandManager 用 new CommandModel(commandTree) 把整棵命令作为一个根命令下发给注册器。

接口实现

方法 行为
getCommandName() 返回 commandTree.getRoot().getLocalizedName()
getCommandAliases() 返回 commandTree.getRoot().getAnnotation().alias() 数组
getCommandUsage(ICommandSender) 返回根节点的 localized syntax
processCommand(ICommandSender, String[]) 把 args 转 List,调 commandTree.commandCall(sender, args)
addTabCompletionOptions(ICommandSender, String[]) 通过 getNodeFromArgs 定位当前节点,再 getTabCompletionList(argumentNumber, lastArg) 给候选
canCommandSenderUseCommand(ICommandSender) 固定 true;权限真正检查在 CommandTree.commandCall → hasPermission
getPermissionNode() 返回根节点的 permission()(用于 ForgeEssentials)
getPermissionLevel() @Optional.Method(modid = "ForgeEssentials"):当前 Bridge 不是 ForgeEssentialsPermissionBridge 时返回 OP 级别(true),否则返回 NONE(false)

相关条目