跳到主要内容
版本:0.2.4

Interface IWukongConsoleApi

Namespace: WukongMp.Sdk.Api
Assembly: WukongMp.Sdk.dll

API for the in-game console (F1).

public interface IWukongConsoleApi

Methods

AddCommand(string, ConsoleCommand, IEnumerable<string>?)

Registers a console command that all players in the session can run.

void AddCommand(string commandName, ConsoleCommand command, IEnumerable<string>? availableFirstParams = null)

Parameters

commandName string

Text the player types to invoke the command (e.g. "spawn").

command ConsoleCommand

Handler that runs when the command is executed.

availableFirstParams IEnumerable<string>?

Optional fixed list of autocomplete suggestions for the command's first parameter. The list is captured once at registration, so use this overload when the suggestions never change, e.g. a known set of spawnables: "spawn wolf_sentinel".

AddCommand(string, ConsoleCommand, Func<IEnumerable<string>>)

Registers a console command that all players in the session can run.

void AddCommand(string commandName, ConsoleCommand command, Func<IEnumerable<string>> availableFirstParams)

Parameters

commandName string

Text the player types to invoke the command (e.g. "kick").

command ConsoleCommand

Handler that runs when the command is executed.

availableFirstParams Func<IEnumerable<string>>

A factory that produces autocomplete suggestions for the command's first parameter. It is invoked each time the console requests suggestions, so use this overload when the values depend on live state, e.g. currently connected players or spawned entities.

HasCommand(string)

Checks if a command with the given name is already registered in the console.

bool HasCommand(string commandName)

Parameters

commandName string

Name of the command to check.

Returns

bool

true if a command with the given name is registered, false otherwise.

LogMessage(string)

Logs a message to the in-game console. This can be used to provide feedback to the player after executing a command, or to log important information that the player should see.

void LogMessage(string message)

Parameters

message string

The message to log.

  • Methods
    • AddCommand(string, ConsoleCommand, IEnumerable<string>?)
    • AddCommand(string, ConsoleCommand, Func<IEnumerable<string>>)
    • HasCommand(string)
    • LogMessage(string)