QtCraft API C++ classes QML types Handbook

QcServerCommands Class

The command layer of the server (decision E-243), shared by the chat of every player and the server console: plain chat lines go to everyone, lines starting with '/' run a command of the registry or a macro of the content (decision E-248) after the source's rights are checked. More...

Header: #include <server/commands/QcServerCommands.h>

Public Types

struct Parts

Public Functions

QcStatus add(QcCommandSpec spec)
void admin(QcServerClient &client, const QString &line, const QcCommandSource::Output &output)
void afterTicks()
QcBackupRunner &backups()
void chat(QcServerClient &client, const QString &text)
const QcChatLog &chatLog() const
void console(const QString &line, const QcCommandSource::Output &output)
void playerLeft(quint32 entityId)
void pollBackups()
const QcCommandRegistry &registry() const
void waitForBackups()

Static Public Members

const qsizetype maxLineLength

Detailed Description

Every command is logged with its source (category qtcraft.commands). /help, /confirm and /cancel are built in.

Member Function Documentation

QcStatus QcServerCommands::add(QcCommandSpec spec)

For C++ extensions (docs/Modding.md): adds the command spec. Returns an error for taken or invalid names.

void QcServerCommands::admin(QcServerClient &client, const QString &line, const QcCommandSource::Output &output)

Runs the command line of the player client through the admin channel (decision E-848): checked and run like their chat command (the leading '/' is optional), the replies go to output instead of their chat. The line is not cut to maxLineLength characters.

void QcServerCommands::afterTicks()

After the server's due ticks: reports a sprint that ended.

QcBackupRunner &QcServerCommands::backups()

Returns the runner of background backups.

void QcServerCommands::chat(QcServerClient &client, const QString &text)

Handles the chat line text of the playing client, cut to maxLineLength characters.

const QcChatLog &QcServerCommands::chatLog() const

Returns the chat lines everyone saw (players' chat and /say).

void QcServerCommands::console(const QString &line, const QcCommandSource::Output &output)

Runs line of the console (cut to maxLineLength characters); the leading '/' is optional. Replies go to output.

void QcServerCommands::playerLeft(quint32 entityId)

The player entityId left: his pending confirmation goes.

void QcServerCommands::pollBackups()

Every tick: reports a backup copied in the background (decision E-256).

const QcCommandRegistry &QcServerCommands::registry() const

Returns the registry of the commands.

void QcServerCommands::waitForBackups()

Server stop: waits for a backup still being copied.

Member Variable Documentation

const qsizetype QcServerCommands::maxLineLength

The most characters of a chat or console line; longer ones are cut.