From 2ed52fc814130a57b3c356214052069c094d7bed Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Fri, 1 Sep 2023 13:29:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20server=20=E5=8C=85=E4=B8=AD=20RegConsole?= =?UTF-8?q?CommandEvent=20=E5=87=BD=E6=95=B0=E7=A9=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/event.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/event.go b/server/event.go index c6bb699..d5f0dea 100644 --- a/server/event.go +++ b/server/event.go @@ -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())) }