fix: server 包中 RegConsoleCommandEvent 函数空指针问题处理

This commit is contained in:
kercylan98 2023-09-01 13:29:49 +08:00
parent 7c6722e36d
commit 2ed52fc814
1 changed files with 6 additions and 1 deletions

View File

@ -95,7 +95,12 @@ func (slf *event) RegConsoleCommandEvent(command string, handle ConsoleCommandEv
}
}()
})
slf.consoleCommandEventHandles[command].Append(handle, slice.GetValue(priority, 0))
list, exist := slf.consoleCommandEventHandles[command]
if !exist {
list = slice.NewPriority[ConsoleCommandEventHandle]()
slf.consoleCommandEventHandles[command] = list
}
list.Append(handle, slice.GetValue(priority, 0))
log.Info("Server", log.String("RegEvent", runtimes.CurrentRunningFuncName()), log.String("handle", reflect.TypeOf(handle).String()))
}