Interface Commands


@NonExtendable public interface Commands
Registration of admin commands. A registered command works wherever Project Zomboid's own admin commands work: in the in-game chat (/name), the server console, and RCON. It is looked up after the commands of Project Zomboid and runs on the main thread.

A command is a class of the running Project Zomboid version's command framework, so a mod that registers commands declares game versions in mod.toml. In Build 42 it is a public, non-abstract subclass of zombie.commands.CommandBase with:

  • one public constructor (String username, Role role, String command, UdpConnection connection), which passes its arguments to super;
  • at least one @CommandName; names consist of letters, digits, and _, and differ (ignoring case) from every name of Project Zomboid and of other mods;
  • at least one @RequiredCapability; Project Zomboid refuses to run a command without one;
  • optionally @CommandArgs (argument patterns) and @CommandHelp (help <name> and the help list).
Project Zomboid creates a new instance for every use and calls its Command(), whose result is the reply.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    register(Class<?> command)
    Registers command.
  • Method Details

    • register

      void register(Class<?> command)
      Registers command. Only on the main thread while the mod loads: in the entry point's constructor or Mod.onLoad(). Classes annotated with RegisterCommand are registered without this call.
      Throws:
      IllegalArgumentException - when command does not meet the rules above, or is registered already
      IllegalStateException - when called later or on another thread