(player *Player, args []string, node *CommandNode, step int)
| 133 | } |
| 134 | |
| 135 | func (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 | |
| 162 | type commandNode struct { |
| 163 | Type CommandNodeType |
no test coverage detected