服务端指令总表

基本信息

属性 值
注册入口 ServerUtilitiesCommands.registerCommands(FMLServerStartingEvent)
注册源码 src/main/java/serverutils/command/ServerUtilitiesCommands.java:28-175
调用点 ServerUtilitiesCommon.java:126(FMLServerStartingEvent)
顶层注册调用数 44(grep -c "event.registerServerCommand" ServerUtilitiesCommands.java → 44)
声明的 Cmd* 类总数 85 个文件(git ls-files | grep -c '/Cmd[A-Za-z]*\.java$')
未注册的 Cmd* 类 CommandListAchievements(见下方「死代码」)

所有指令由 FMLServerStartingEvent.registerServerCommand 注册,即在服务端启动时注册,客户端安装同版本 jar 才能看到(@NetworkCheckHandler 要求版本一致,ServerUtilities.java:102-105)。

指令基类与权限等级

全部指令继承 serverutils.lib.command.CmdBase(src/main/java/serverutils/lib/command/CmdBase.java:18),指令名由构造函数 super(name, level) 传入,getCommandName() 直接返回该字段(CmdBase.java:57-66)。

CmdBase.Level(CmdBase.java:20-35)定义了 6 个内置等级,ALL 的 requiredPermissionLevel 为 0:

Level requiredPermissionLevel 判定条件
ALL 0 恒真(所有玩家)
OP_OR_SP 2 单人游戏,或 canCommandSenderUseCommand(2, ...)
OP 2 canCommandSenderUseCommand(2, ...)
STRONG_OP_OR_SP 4 单人游戏,或 canCommandSenderUseCommand(4, ...)
STRONG_OP 4 canCommandSenderUseCommand(4, ...)
SERVER 4 发送者 instanceof MinecraftServer(控制台)

[!NOTE] CmdBase.Level 是原版 Forge 权限等级通道,与本模组自己的 rank 权限节点是两套并存体系。当 ranks.command_permissions = true 时,Mixin 会用 rank 体系覆写原版判定,详见 权限节点。

TransferCommand 例外:它直接 extends net.minecraft.command.CommandBase(src/main/java/serverutils/command/TransferCommand.java:9),getRequiredPermissionLevel() 硬编码返回 2(TransferCommand.java:29-32),不经 CmdBase.Level。

完整指令表

「配置开关」列为 ServerUtilitiesConfig 中的字段路径;为空表示无条件注册。

指令 类 权限 配置开关 附加条件
/my_settings CmdMySettings ALL — 无
/team CmdTeam — — 指令树,见 队伍指令
/motd CmdMotd ALL — 无
/reload CmdReload OP_OR_SP commands.reload 无
/shutdown CmdShutdown OP — 仅 isDedicatedServer()
/shutdown_time CmdShutdownTime ALL auto_shutdown.enabled 仅 isDedicatedServer()
/pause_when_empty CmdPauseWhenEmpty — general.enable_pause_when_empty_property 仅 isDedicatedServer()
/view CmdInv OP commands.inv 无
/warp CmdWarp ALL commands.warp 无
/setwarp CmdSetWarp OP commands.warp 无
/delwarp CmdDelWarp OP commands.warp 无
/home CmdHome ALL commands.home 无
/sethome CmdSetHome ALL commands.home 无
/delhome CmdDelHome ALL commands.home 无
/tpl CmdTplast OP commands.tpl 无
/trash_can CmdTrashCan ALL commands.trash_can 无
/back CmdBack ALL commands.back 无
/spawn CmdSpawn ALL commands.spawn 无
/chunks CmdChunks — commands.chunks 指令树,见 区块指令
/kickme CmdKickme ALL commands.kickme 无
/ranks CmdRanks — commands.ranks 指令树,见 Rank 指令
/heal CmdHeal OP commands.heal 无
/killall CmdKillall OP commands.killall 无
/nbtedit CmdEditNBT OP commands.nbtedit 无
/fly CmdFly OP commands.fly 无
/leaderboards CmdLeaderboard ALL commands.leaderboard 无
/dump_chunkloaders CmdDumpChunkloaders OP_OR_SP commands.dump_chunkloaders 无
/tpa CmdTPA ALL commands.tpa 无
/tpaccept CmdTPAccept ALL commands.tpa 无
/nick CmdNick ALL commands.nick 无
/nickfor CmdNickFor OP commands.nick 无
/mute CmdMute OP commands.mute 无
/unmute CmdUnmute OP commands.mute 无
/backup CmdBackup OP_OR_SP commands.backup 无
/rtp CmdRTP ALL commands.rtp 无
/god CmdGod OP commands.god 无
/rec CmdRec ALL commands.rec 无
/dump_permissions CmdDumpPermissions OP_OR_SP commands.dump_permissions 无
/add_fake_player CmdAddFakePlayer OP debugging.special_commands 默认关闭
/dump_stats CmdDumpStats OP_OR_SP commands.dump_stats 无
/vanish CmdVanish OP commands.vanish 无
/seek_block CmdSeekBlock OP commands.seek_block 无
/pregen CmdPregen — commands.pregen 指令树(start / stop / progress)
/transfer TransferCommand 2(硬编码) transfer.enabled 无

注册条件要点

  • 专用服务器专属:/shutdown、/shutdown_time、/pause_when_empty 三条被 event.getServer().isDedicatedServer() 包住(ServerUtilitiesCommands.java:37-47),在单人游戏里不注册。
  • 无配置开关的 3 条:/my_settings、/team、/motd(ServerUtilitiesCommands.java:29-31),永远存在。
  • 默认关闭的 1 条:/add_fake_player 由 debugging.special_commands 控制,默认 false(ServerUtilitiesConfig.java:105-106)。
  • 受 Mixin 联动:/vanish 的功能本体由 VANISH_COMMAND Mixin 提供(mixins.serverutilities.vanish.*),关掉 commands.vanish 会同时关掉 Mixin(mixin/Mixins.java VANISH_COMMAND.setApplyIf)。

死代码

src/main/java/serverutils/command/client/CommandListAchievements.java 声明为 public class CommandListAchievements extends CmdBase(:9),但全仓检索只有它自己的声明行一处引用:

grep -rn "CommandListAchievements" src/
# src/main/java/serverutils/command/client/CommandListAchievements.java:9
# src/main/java/serverutils/command/client/CommandListAchievements.java:11

它不在 ServerUtilitiesCommands.registerCommands 的任何 registerServerCommand 调用中,也不在 ServerUtilitiesClient.postInit 的 ClientCommandHandler.instance.registerCommand 列表中(client/ServerUtilitiesClient.java:73-79)。按「声明 ≠ 注册」原则,/list_achievements 不存在,不计入 44 条。

相关条目