Documentation ¶
Index ¶
- Constants
- func ParseFloat(arg string) (float32, error)
- func ParsePosition(player *player.Player, x_str, y_str, z_str string) (x, y, z int32, err error)
- func ParsePositionNum(base int32, val string) (int32, error)
- func Parser(k parser_kind) parser
- type Command
- type CommandManager
- type Node
- func (n *Node) AddNode(other ...*Node) *Node
- func (n *Node) Executable() *Node
- func (n *Node) Name(name string) *Node
- func (n *Node) Parser(parser parser) *Node
- func (n *Node) Redirect(other *Node) *Node
- func (n *Node) Suggestion(suggestion string) *Node
- func (n *Node) ToPacket() *packet.OutgoingPacket
Constants ¶
const ( BOOL parser_kind = iota // Boolean value DOUBLE // Double FLOAT // Float INTEGER // Integer STRING // A string ENTITY // A selector, player name, or UUID. GAME_PROFILE // A player, online or not. Can also use a selector, which may match one or more players (but not entities). BLOCK_POS // A location, represented as 3 numbers (which must be integers). May use relative locations with ~. COLUMN_POS // A column location, represented as 3 numbers (which must be integers). May use relative locations with ~. VEC3 // A location, represented as 3 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified). May use relative locations with ~. VEC2 // A location, represented as 2 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified). May use relative locations with ~. BLOCK_STATE // A block state, optionally including NBT and state information. BLOCK_PREDICATE // A block, or a block tag. ITEM_STACK // An item, optionally including NBT. ITEM_PREDICATE // An item, or an item tag. COLOR // A chat color. One of the names from Chat#Colors, or reset. Case-insensitive. COMPONENT // A JSON Chat component. MESSAGE // A regular message, potentially including selectors. NBT // An NBT value, parsed using JSON-NBT rules. NBT_PATH // A path within an NBT value, allowing for array and member accesses. OBJECTIVE // A scoreboard objective. OBJECTIVE_CRITERIA // A single score criterion. OPERATION // A scoreboard operator. PARTICLE // A particle effect (an identifier with extra information following it for specific particles, mirroring the Particle packet) ROTATION // An angle, represented as 2 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified). May use relative locations with ~. ANGLE // minecraft:angle SCOREBOARD_SLOT // A scoreboard display position slot. list, sidebar, belowName, and sidebar.team.${color} for all chat colors (reset is not included) SCORE_HOLDER // Something that can join a team. Allows selectors and *. SWIZZLE // A collection of up to 3 axes. TEAM // The name of a team. Parsed as an unquoted string. ITEM_SLOT // A name for an inventory slot. RESOURCE_LOCATION // An Identifier. MOB_EFFECT // A potion effect. FUNCTION // A function. ENTITY_ANCHOR // The entity anchor related to the facing argument in the teleport command, is feet or eyes. RANGE // A range of values with a min and a max. INT_RANGE // An integer range of values with a min and a max. FLOAT_RANGE // A floating-point range of values with a min and a max. ITEM_ENCHANTMENT // Represents a item enchantment. ENTITY_SUMMON // Represents an entity summon. DIMENSION // Represents a dimension. UUID // Represents a UUID value. NBT_TAG // Represents a partial nbt tag, usable in data modify command. NBT_COMPOUND_TAG // Represents a full nbt tag. TIME // Represents a time duration. )
See https://wiki.vg/Command_Data for more information.
Variables ¶
This section is empty.
Functions ¶
func ParsePosition ¶
This parses a block position in the world, and is just three PositionNums in a row
func ParsePositionNum ¶
Parses a number in either of these formats: 10 -5 -123 ~ ~-10 ~123 The ~ means relative positioning, and that is relative to the base parameter
func Parser ¶
func Parser(k parser_kind) parser
This creates a parser for a node. You should use the constants for the parser_kind. To change the way the values are parsed, call functions like Min() or Max(). See the individual functions for more info. All functions will return copies of the original parser, with the new settings applied. They are designed to be used inline as arguments to NewArgumentNode().
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
func New ¶
func New(name string, runner func(*world.WorldManager, *player.Player, []string) bool, children ...*Node) *Command
Creates a new command. The name will be the command without the /. The running is called whenever the client runs this command. The children are the arguments to the command. See Node for more information on command nodes.
func (*Command) AddNode ¶
Adds the given nodes as children. These are top level arguments to the command.
func (*Command) SetRunner ¶
func (c *Command) SetRunner(runner func(*world.WorldManager, *player.Player, []string) bool) *Command
Changes the function that is called when the command is run. This will override the previous runner.
func (*Command) SetTabCompleter ¶
func (c *Command) SetTabCompleter(runner func(*world.WorldManager, *player.Player, []string) []string) *Command
Changes the function that is called whenever the client requests tab completes. This will only be called if one if the nodes has the 'minecraft:ask_server' suggestion type.
type CommandManager ¶
type CommandManager struct {
// contains filtered or unexported fields
}
func NewCommandManager ¶
func NewCommandManager(world_manager *world.WorldManager) *CommandManager
func (*CommandManager) Add ¶
func (c *CommandManager) Add(command *Command)
func (*CommandManager) GetCommandTree ¶
func (c *CommandManager) GetCommandTree() *packet.OutgoingPacket
func (*CommandManager) TabComplete ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
A command node. Since minecraft 1.13, all possible commands are represented with a tree. Every node on the tree is one argument in a command. Every one of these nodes has a type: Root, literal, or argument. The root node is created automatically. Literal nodes are for things like keyworks; they only allow a certain string to be inserted at that point. Argument nodes allow for any text, and are parsed with a node parser. See parser.go for more information on parsers.
To create a command, use the New() function. To add arguments, call AddNode(Node). To create a node, use the ArgumentNode() or LiteralNode() functions.
func ArgumentNode ¶
Creates a new argument node. The name is what the users sees when they are entering the value of this arguemnt. The parser should be one of the parsers from parser.go.
func LiteralNode ¶
Creates a new literal node. The name is the only text that will be accepted for this node.
func (*Node) Executable ¶
Makes the node executable. This means that at the end of this node, this is a valid command. All nodes that have no children are automatically set to be executable, so this function should only be used if you command is valid with only partial arguments.
func (*Node) Redirect ¶
Sets this node to redirect to another node. If other is nil, then the redirect will be cleared.
func (*Node) Suggestion ¶
Changes the suggestion of the node. If this is an empty string, the suggestion will be cleared.
func (*Node) ToPacket ¶
func (n *Node) ToPacket() *packet.OutgoingPacket
Only valid on the root node. Will return an outgoing packet that contains the entire command tree. You should node call this function, as it will panic on everything that is not a root node.