/blimit 指令

基本信息

属性 值
实现类 com.github.namikon.blocklimiter.command.BlockLimiterCommand
接口 net.minecraft.command.ICommand
命令名 blimit
别名 blimit
注册时机 BlockLimiter.serverLoad(FMLServerStartingEvent) 时调用 registerServerCommand
可执行者 canCommandSenderUseCommand 始终返回 true;reload 子命令额外校验 OP 身份

命令格式

/blimit <reload|blockinfo|iteminfo>

无参数或参数未知时返回:

Usage: /blimit reload|blockinfo|iteminfo

子命令

reload

  • 权限:OP 或单人模式的 LAN 主。

  • 行为:调用 BlockLimiter.Config.Reload():

    1. 重新 _mainConfig.load() 配置文件。
    2. 调用 Init() 重新读取所有配置字段。
    3. 调用 InitDefinedBlocks() 与 InitDefinedItems() 重建禁用集合。
  • 成功反馈:

    Blocklimiter config reloaded. Now monitoring:
     - <N> Block(s)
     - <N> Item(s)
    
  • 失败反馈:

    Blocks could not be reloaded properly. Please check the console output and fix the config file
    

    非 OP 时:

    You need to be op or admin to reload the config
    

blockinfo

  • 权限:所有玩家可用(不需要 OP)。
  • 行为:列出 BlockLimiter.Config.LimitedBlocks 的内容;每条通过 BlockInfo.getInfoString() 格式化输出:
    • 全局禁用:Block <modID>:<blockname> [ALL]
    • 维度禁用:Block <modID>:<blockname> [In DIM: <dim1>, <dim2>, ...]
  • 空列表时输出 There are currently no forbidden Blocks。

iteminfo

  • 权限:所有玩家可用。
  • 行为:列出 BlockLimiter.Config.LimitedItems 的内容;格式与 blockinfo 一致,但 Block 前缀改为 Item。
  • 空列表时输出 There are currently no forbidden Items。

OP 判定逻辑

isOpOrAdmin(ICommandSender):

  1. 服务端为集成模式(!isDedicatedServer())时直接返回 true(单人/LAN 主玩家)。
  2. 命令发送者为 EntityPlayerMP 时,调用 MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile())(即原版 OP 列表查询)。

数值

数值 默认值
命令别名 blimit
Tab 补全 未实现(addTabCompletionOptions 返回 null)

限制

  • 命令通过 ICommand(旧式 ICommandSender 接口)实现,与现代 CommandBase 接口不同;可能与其他 mod 的命令框架发生冲突。
  • tab 自动补全关闭,使用时需手动输入子命令。
  • compareTo(Object) 直接返回 0,即不参与命令排序。
  • ProcessDenyinDims 方法体为空——这是代码中保留的 stub,没有实际功能。

相关条目