onPlayerSpawn loads the user's inbox into memory and migrates legacy data.
(e events.Event)
| 148 | |
| 149 | // onPlayerSpawn loads the user's inbox into memory and migrates legacy data. |
| 150 | func (m *MudmailModule) onPlayerSpawn(e events.Event) events.ListenerReturn { |
| 151 | evt, ok := e.(events.PlayerSpawn) |
| 152 | if !ok { |
| 153 | return events.Continue |
| 154 | } |
| 155 | |
| 156 | inbox := m.load(evt.UserId) |
| 157 | |
| 158 | m.inboxes[evt.UserId] = inbox |
| 159 | |
| 160 | // Notify the user if they have unread messages. |
| 161 | if countUnread(inbox) > 0 { |
| 162 | if u := users.GetByUserId(evt.UserId); u != nil { |
| 163 | u.Command(`inbox check`) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | return events.Continue |
| 168 | } |
| 169 | |
| 170 | // onPlayerDespawn saves and unloads the user's inbox. |
| 171 | func (m *MudmailModule) onPlayerDespawn(e events.Event) events.ListenerReturn { |
nothing calls this directly
no test coverage detected