Interface ClientCommands


public interface ClientCommands
Server commands to clients, the reply channel to ClientCommandEvent: a client receives them in Lua's Events.OnServerCommand(module, command, args). Together, a Java mod on the server and a Lua mod on the client exchange commands while players keep the official client.

args becomes a Lua table: keys are String or a Number (sent as a Lua number), values are String, Number, Boolean, a nested Map, a List (a Lua array, indexed from 1), or a game object that Project Zomboid sends with commands (see ClientCommandEvent). null keys or values, and cycles, are not allowed. An empty map sends no arguments; the client then receives nil.

The methods can be called on any thread. The arguments are checked at once; the command is sent on the main thread, at once when called there, otherwise with the mod's queued main-thread tasks.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    send(PlayerRef player, String module, String command, Map<?,?> args)
    Sends a command to player.
    void
    sendToAll(String module, String command, Map<?,?> args)
    Sends a command to every connected client.
  • Method Details

    • send

      void send(PlayerRef player, String module, String command, Map<?,?> args)
      Sends a command to player. Nothing is sent when the player is no longer connected.
      Throws:
      IllegalArgumentException - when args contains a key or value that cannot be sent
    • sendToAll

      void sendToAll(String module, String command, Map<?,?> args)
      Sends a command to every connected client.
      Throws:
      IllegalArgumentException - when args contains a key or value that cannot be sent