(command string, caller Caller)
| 32 | } |
| 33 | |
| 34 | func (mgr *Manager) Call(command string, caller Caller) { |
| 35 | arguments := strings.Split(command, " ") |
| 36 | if len(arguments) == 0 { |
| 37 | caller.SystemMessage( |
| 38 | text.Unmarshal( |
| 39 | "&cInvalid command", '&', |
| 40 | ), |
| 41 | ) |
| 42 | return |
| 43 | } |
| 44 | cmd := mgr.findCommand(arguments[0]) |
| 45 | if cmd == nil { |
| 46 | caller.SystemMessage( |
| 47 | text.Unmarshalf( |
| 48 | '&', |
| 49 | "&cUnknown command %s", |
| 50 | command, |
| 51 | ), |
| 52 | ) |
| 53 | return |
| 54 | } |
| 55 | ctx := CommandCallContext{ |
| 56 | Command: *cmd, |
| 57 | Executor: caller, |
| 58 | Server: mgr.srv, |
| 59 | } |
| 60 | if len(arguments) > 1 { |
| 61 | ctx.Arguments = arguments[1:] |
| 62 | } |
| 63 | if cmd.Callback == nil { |
| 64 | return |
| 65 | } |
| 66 | cmd.Callback(ctx) |
| 67 | } |
| 68 | |
| 69 | func (mgr *Manager) findCommand(name string) *Command { |
| 70 | mgr.mu.RLock() |
no test coverage detected