Skip to main content

CommandConverters

Per-type string parsers for CommandAttribute parameters, for types Deadworks doesn't parse itself. Register from OnLoad; a plugin's converters are dropped automatically when it unloads. A parser may throw CommandException to tell the caller what's wrong with their input; anything else shows the usage line. A converter applies to every plugin's commands, so prefer registering one for your own types; one for a shared type such as TimeSpan replaces any other plugin's.

public static class CommandConverters

Namespace: DeadworksManaged.Api
Source: Commands/CommandConverters.cs#L13

Methods​

CommandConverters.Register()​

Registers a parser for T, replacing any earlier one (with a warning if another plugin's).

Signature

public static void Register<T>(Func<string, T> parser)

Throws

  • ArgumentException: Deadworks parses T itself: numbers, bool, string, enums, Caller, Target and CCitadelPlayerController. Take a string parameter and parse it in the command instead.

Source: Commands/CommandConverters.cs#L25

CommandConverters.Unregister()​

Removes the parser for T. Returns false if there wasn't one.

Signature

public static bool Unregister<T>()

Source: Commands/CommandConverters.cs#L38