MCPcopy Create free account
hub / github.com/TyphoonMC/TyphoonCore / analyseTabCommand

Method analyseTabCommand

command.go:135–160  ·  view source on GitHub ↗
(player *Player, args []string, node *CommandNode, step int)

Source from the content-addressed store, hash-verified

133}
134
135func (c *Core) analyseTabCommand(player *Player, args []string, node *CommandNode, step int) []string {
136 strs := make([]string, 0)
137 if len(args) > step {
138 for _, child := range node.Children {
139 switch child.Type {
140 case CommandNodeTypeLiteral:
141 if len(args)-1 == step && strings.HasPrefix(child.Name, args[step]) {
142 strs = append(strs, commandJoin(args[:len(args)-1], child.Name))
143 } else {
144 if child.Name == args[step] {
145 strs = append(strs, c.analyseTabCommand(player, args, child, step+1)...)
146 }
147 }
148 case CommandNodeTypeArgument:
149 if child.Parser.IsMultiple() {
150 if child.Parser.IsArrayValid(args[step:]) {
151 strs = append(strs, strings.Join(args, " "))
152 }
153 } else {
154 strs = append(strs, child.Parser.Complete(args[step])...)
155 }
156 }
157 }
158 }
159 return strs
160}
161
162type commandNode struct {
163 Type CommandNodeType

Callers 1

onTabCommandMethod · 0.95

Calls 4

commandJoinFunction · 0.85
IsMultipleMethod · 0.65
IsArrayValidMethod · 0.65
CompleteMethod · 0.65

Tested by

no test coverage detected