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

Method analyseCommand

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

Source from the content-addressed store, hash-verified

88}
89
90func (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
118func (c *Core) onTabCommand(player *Player, command string) {
119 args := strings.Split(command, " ")

Callers 1

onCommandMethod · 0.95

Calls 3

IsMultipleMethod · 0.65
IsArrayValidMethod · 0.65
IsValidMethod · 0.65

Tested by

no test coverage detected