github.com/df-mc/dragonfly@v0.9.13/server/cmd/doc.go (about)

     1  // Package cmd implements a Minecraft specific command system, which may be used simply by 'plugging' it in
     2  // and sending commands registered in an AvailableCommandsPacket.
     3  //
     4  // The cmd package handles commands in a specific way: It requires a struct to be passed to the cmd.New()
     5  // function, which implements the Runnable interface. For every exported field in the struct, executing the
     6  // command will result in the parsing of the arguments using the types of the fields of the struct, in the
     7  // order that they appear in. Fields unexported or ignored using the `cmd:"-"` struct tag (see below) have
     8  // their values copied but retained.
     9  //
    10  // A Runnable may have exported fields only of the following types:
    11  // int8, int16, int32, int64, int, uint8, uint16, uint32, uint64, uint,
    12  // float32, float64, string, bool, mgl64.Vec3, Varargs, []Target, cmd.SubCommand, Optional[T] (to make a parameter
    13  // optional), or a type that implements the cmd.Parameter or cmd.Enum interface. cmd.Enum implementations must be of the
    14  // type string.
    15  // Fields in the Runnable struct may have `cmd:` struct tag to specify the name and suffix of a parameter as such:
    16  //
    17  //	type T struct {
    18  //	    Param int `cmd:"name,suffix"`
    19  //	}
    20  //
    21  // If no name is set, the field name is used. Additionally, the name as specified in the struct tag may be '-' to make
    22  // the parser ignore the field. In this case, the field does not have to be of one of the types above.
    23  //
    24  // Commands may be registered using the cmd.Register() method. By itself, this method will not ensure that the
    25  // client will be able to use the command: The user of the cmd package must handle commands itself and run the
    26  // appropriate one using the cmd.ByAlias function.
    27  package cmd