MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / HandleSystemEvents

Method HandleSystemEvents

world.go:186–240  ·  view source on GitHub ↗

Checks whether their level is too high for a guide

(e events.Event)

Source from the content-addressed store, hash-verified

184
185// Checks whether their level is too high for a guide
186func (w *World) HandleSystemEvents(e events.Event) events.ListenerReturn {
187
188 sys, typeOk := e.(events.System)
189 if !typeOk {
190 mudlog.Error("Event", "Expected Type", "System", "Actual Type", e.Type())
191 return events.Continue
192 }
193
194 if sys.Command == `reload` {
195
196 events.AddToQueue(events.Broadcast{
197 Text: `Reloading flat files...`,
198 })
199
200 loadAllDataFiles(true)
201
202 events.AddToQueue(events.Broadcast{
203 Text: `Done.` + term.CRLFStr,
204 SkipLineRefresh: true,
205 })
206
207 } else if sys.Command == `kick` {
208 w.Kick(sys.Data.(int), sys.Description)
209 } else if sys.Command == `leaveworld` {
210
211 if userInfo := users.GetByUserId(sys.Data.(int)); userInfo != nil {
212 events.AddToQueue(events.PlayerDespawn{
213 UserId: userInfo.UserId,
214 RoomId: userInfo.Character.RoomId,
215 Username: userInfo.Username,
216 CharacterName: userInfo.Character.Name,
217 TimeOnline: userInfo.GetOnlineInfo().OnlineTimeStr,
218 })
219 }
220
221 } else if sys.Command == `logoff` {
222
223 if user := users.GetByUserId(sys.Data.(int)); user != nil {
224
225 user.EventLog.Add(`conn`, `Logged off`)
226
227 events.AddToQueue(events.PlayerDespawn{
228 UserId: user.UserId,
229 RoomId: user.Character.RoomId,
230 Username: user.Username,
231 CharacterName: user.Character.Name,
232 TimeOnline: user.GetOnlineInfo().OnlineTimeStr,
233 })
234
235 }
236
237 }
238
239 return events.Continue
240}
241
242// Send input to the world.
243// Just sends via a channel. Will block until read.

Callers

nothing calls this directly

Calls 8

KickMethod · 0.95
ErrorFunction · 0.92
AddToQueueFunction · 0.92
GetByUserIdFunction · 0.92
loadAllDataFilesFunction · 0.85
GetOnlineInfoMethod · 0.80
TypeMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected