(player *Player, args []string, node *CommandNode, step int)
| 88 | } |
| 89 | |
| 90 | func (c *Core) analyseCommand(player *Player, args []string, node *CommandNode, step int) bool { |
| 91 | if len(args) > step { |
| 92 | for _, child := range node.Children { |
| 93 | switch child.Type { |
| 94 | case CommandNodeTypeLiteral: |
| 95 | if child.Name == args[step] { |
| 96 | return c.analyseCommand(player, args, child, step+1) |
| 97 | } |
| 98 | case CommandNodeTypeArgument: |
| 99 | if child.Parser.IsMultiple() { |
| 100 | if child.Parser.IsArrayValid(args[step:]) { |
| 101 | return c.analyseCommand(player, args, child, step+1) |
| 102 | } |
| 103 | } else { |
| 104 | if child.Parser.IsValid(args[step]) { |
| 105 | return c.analyseCommand(player, args, child, step+1) |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | if node.Execute != nil { |
| 112 | node.Execute(player, args) |
| 113 | return true |
| 114 | } |
| 115 | return false |
| 116 | } |
| 117 | |
| 118 | func (c *Core) onTabCommand(player *Player, command string) { |
| 119 | args := strings.Split(command, " ") |
no test coverage detected