-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCore.lua
More file actions
713 lines (654 loc) · 29.7 KB
/
Core.lua
File metadata and controls
713 lines (654 loc) · 29.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
local addonName, LastSeen = ...
local eventFrame = CreateFrame("Frame")
local encounterInProgress = false
local lastTime = 0
local stringLower = string.lower
local stringFormat = string.format
local tostring = tostring
local type = type
local ignoredItemClasses = {
[12] = "Quest"
}
local function BuildSearchTextForExistingItems()
if not LastSeenDB or not LastSeenDB.Items then
return
end
for _, item in pairs(LastSeenDB.Items) do
if item and not item.searchText then
item.searchText = string.lower(("%s %s %s %s %s %s"):format(
item.name or "",
item.looterName or "",
tostring(item.looterLevel or ""),
item.source or "",
item.map or "",
item.lootDate or ""
))
end
end
end
---@param item table
---@return string
local function NormalizeField(item)
if item == nil then
return ""
end
if type(item) == "string" then
return item
end
return tostring(item)
end
---@param item table
---@return string
local function BuildItemSearchText(item)
-- Build a single string that contains everything we want to be searchable.
-- Lowercase once, then searching doesn't need to lowercase every time.
local name = NormalizeField(item.name)
local link = NormalizeField(item.link)
local looterName = NormalizeField(item.looterName)
local looterLevel = NormalizeField(item.looterLevel)
local source = NormalizeField(item.source)
local map = NormalizeField(item.map)
local lootDate = NormalizeField(item.lootDate)
-- One allocation and one lowercase allocation total here.
return stringLower(stringFormat(
"%s %s %s %s %s %s %s",
name, link, looterName, looterLevel, source, map, lootDate
))
end
---@param item table
function LastSeen.UpdateItemSearchText(item)
if type(item) ~= "table" then
return
end
item.searchText = BuildItemSearchText(item)
end
local function GetUnitTypeFromGUID(guid)
local unitType = string.split("-", guid)
return unitType
end
local function GetIDFromGUID(guid)
local id = select(6, string.split("-", guid)); id = tonumber(id)
return id or 0
end
local function ExtractItemLinkFromText(text)
if issecretvalue(text) or type(text) ~= "string" then
return nil
end
return text:match("(|Hitem:.-|h%[.-%]|h)")
end
local function ExtractItemLinkFromArgs(...)
for i = 1, select("#", ...) do
local v = select(i, ...)
if type(v) == "string" and v:find("|Hitem:", 1, true) then
local link = v:match("(|Hitem:.-|h%[.-%]|h)")
if link then
return link
end
end
end
return nil
end
local function OnEvent(_, event, ...)
if event == "ADDON_LOADED" then
local addonLoaded = ...
if addonLoaded == addonName then
eventFrame:UnregisterEvent(event)
if LastSeenDB == nil then
LastSeenDB = {}
end
local oldVariables = {
"DateFormat",
"Enabled",
"IgnoredItems",
"rarityID",
"Quests",
"Filters",
"ScanOnLootOpenedEnabled",
"ScanQuestRewardsEnabled",
"IgnoredItems",
"modeID",
"rarityID",
"Quests"
}
for _, key in ipairs(oldVariables) do
if LastSeenDB[key] or not LastSeenDB[key] then
LastSeenDB[key] = nil
end
end
local defaults = {
Characters = {},
Creatures = {},
Encounters = {},
Items = {},
Maps = {},
Objects = {}
}
for key, value in next, defaults do
if LastSeenDB[key] == nil then
LastSeenDB[key] = value
end
end
-- Code to reconstruct an old Items table to the new format
local playerGUID = UnitGUID("player")
for journalEncounterID, encounter in pairs(LastSeenDB.Encounters) do
LastSeenDB.Encounters[journalEncounterID] = encounter.encounterName
end
-- Build reverse lookup tables ONCE before the main loop
local creaturesByName = {}
local objectsByName = {}
local encountersByName = {}
for npcID, name in pairs(LastSeenDB.Creatures) do
creaturesByName[name] = npcID
end
for objectID, name in pairs(LastSeenDB.Objects) do
objectsByName[name] = objectID
end
for encounterID, name in pairs(LastSeenDB.Encounters) do
encountersByName[name] = encounterID
end
for itemID, item in pairs(LastSeenDB.Items) do
if item.itemLink and item.itemLink ~= "" then
LastSeenDB.Items[itemID].link = item.itemLink
LastSeenDB.Items[itemID].itemLink = nil
end
if item.lootedBy then
LastSeenDB.Items[itemID].looterGUID = playerGUID
LastSeenDB.Items[itemID].lootedBy = nil
end
if item.location then
LastSeenDB.Items[itemID].location = nil
end
if item.sourceInfo then
if not LastSeenDB.Items[itemID].appearances then
LastSeenDB.Items[itemID].appearances = {}
end
for appearanceSourceID, lootDate in pairs(item.sourceInfo) do
if appearanceSourceID ~= "sourceID" then
LastSeenDB.Items[itemID].appearances[appearanceSourceID] = lootDate
end
end
LastSeenDB.Items[itemID].sourceInfo = nil
end
if item.itemIcon then
LastSeenDB.Items[itemID].texture = item.itemIcon
LastSeenDB.Items[itemID].itemIcon = nil
end
if item.itemRarity then
LastSeenDB.Items[itemID].quality = item.itemRarity
LastSeenDB.Items[itemID].itemRarity = nil
end
if item.itemType then
LastSeenDB.Items[itemID].itemType = nil
end
if item.itemName then
LastSeenDB.Items[itemID].name = item.itemName
LastSeenDB.Items[itemID].itemName = nil
end
if not item.sourceID then
-- Direct lookup instead of looping
local npcID = creaturesByName[item.source]
if npcID then
LastSeenDB.Items[itemID].sourceID = npcID
LastSeenDB.Items[itemID].sourceType = "Creature"
else
local objectID = objectsByName[item.source]
if objectID then
LastSeenDB.Items[itemID].sourceID = objectID
LastSeenDB.Items[itemID].sourceType = "GameObject"
else
local encounterID = encountersByName[item.source]
if encounterID then
LastSeenDB.Items[itemID].sourceID = encounterID
LastSeenDB.Items[itemID].sourceType = "Encounter"
end
end
end
end
for key, val in pairs(item) do
if key == "appearances" then
for id, v in pairs(val) do
if id == "sourceID" then
LastSeenDB.Items[itemID].appearances[id] = nil
end
end
end
end
end
end
end
if event == "ENCOUNTER_LOOT_RECEIVED" then
local playerName, playerRealm = UnitFullName("player")
local journalEncounterID, _, itemLink, _, unitName = ...
if journalEncounterID and itemLink and unitName then
if format("%s-%s", unitName, playerRealm) ~= format("%s-%s", playerName, playerRealm) then return end
local name = LastSeenDB.Encounters[journalEncounterID]
if name then
local itemName, _, itemQuality, _, _, _, _, _, _, itemTexture, _, classID = C_Item.GetItemInfo(itemLink)
local itemID = C_Item.GetItemInfoInstant(itemLink)
if (itemName and itemQuality and itemTexture and itemID) then
LastSeen.Item(
itemID,
itemName,
itemLink,
itemQuality,
itemTexture,
classID,
LastSeen.playerGUID,
LastSeenDB.Characters[LastSeen.playerGUID].name,
LastSeenDB.Characters[LastSeen.playerGUID].level,
"Encounter",
journalEncounterID,
name,
LastSeen.currentMapName
)
end
end
end
end
if event == "CHAT_MSG_LOOT" then
-- If a loot window exists, LOOT_READY will handle attribution; do nothing...
if GetNumLootItems and GetNumLootItems() and GetNumLootItems() > 0 then
return
end
local msg = ...
local itemLink = ExtractItemLinkFromText(msg)
if not itemLink then
return
end
if C_CurrencyInfo.GetCurrencyInfoFromLink(itemLink) then
return
end
if LastSeen.WithRecentContainerUseSource then
LastSeen.WithRecentContainerUseSource(function(sourceType, sourceID, sourceName)
if not sourceType or not sourceID or not sourceName then
return
end
local itemName, _, itemQuality, _, _, _, _, _, _, itemTexture, _, classID = C_Item.GetItemInfo(itemLink)
local itemID = C_Item.GetItemInfoInstant(itemLink)
if (itemName and itemQuality and itemTexture and itemID) and (not ignoredItemClasses[classID]) then
LastSeen.Item(
itemID,
itemName,
itemLink,
itemQuality,
itemTexture,
classID,
LastSeen.playerGUID,
LastSeenDB.Characters[LastSeen.playerGUID].name,
LastSeenDB.Characters[LastSeen.playerGUID].level,
sourceType,
sourceID,
sourceName,
LastSeen.currentMapName
)
end
end)
end
end
if event == "SHOW_LOOT_TOAST" then
-- If a loot window exists, LOOT_READY will handle attribution; do nothing...
if GetNumLootItems and GetNumLootItems() and GetNumLootItems() > 0 then
return
end
local itemLink = ExtractItemLinkFromArgs(...)
if not itemLink then
return
end
if C_CurrencyInfo.GetCurrencyInfoFromLink(itemLink) then
return
end
if LastSeen.WithRecentContainerUseSource then
LastSeen.WithRecentContainerUseSource(function(sourceType, sourceID, sourceName)
if not sourceType or not sourceID or not sourceName then
return
end
local itemName, _, itemQuality, _, _, _, _, _, _, itemTexture, _, classID = C_Item.GetItemInfo(itemLink)
local itemID = C_Item.GetItemInfoInstant(itemLink)
if (itemName and itemQuality and itemTexture and itemID) and (not ignoredItemClasses[classID]) then
LastSeen.Item(
itemID,
itemName,
itemLink,
itemQuality,
itemTexture,
classID,
LastSeen.playerGUID,
LastSeenDB.Characters[LastSeen.playerGUID].name,
LastSeenDB.Characters[LastSeen.playerGUID].level,
sourceType,
sourceID,
sourceName,
LastSeen.currentMapName
)
end
end)
end
end
if event == "ENCOUNTER_START" then
encounterInProgress = true
local journalEncounterID, name = ...
if journalEncounterID and name then
if not LastSeenDB.Encounters[journalEncounterID] then
LastSeenDB.Encounters[journalEncounterID] = name
end
end
end
if event == "LOOT_CLOSED" then
encounterInProgress = false
if LastSeen.ContainerLootOnLootClosed then
LastSeen.ContainerLootOnLootClosed()
end
end
if event == "LOOT_OPENED" then
if LastSeen.ContainerLootOnLootOpened then
LastSeen.ContainerLootOnLootOpened()
end
end
if event == "LOOT_READY" then
if encounterInProgress then return end -- To prevent encounter loot from logging twice
local currentTime = GetTime()
if currentTime < (lastTime + 1) then return end -- To prevent multiple LOOT_READY events that fire in the same frame from being processed simultaneously
if currentTime > (lastTime + 1) then lastTime = currentTime end
for i=1,GetNumLootItems() do
local itemLink = GetLootSlotLink(i)
-- There are some currencies that return a valid link (like Spirit Shards),
-- so I'll plan around that by making a call to GetCurrencyInfoFromLink. If
-- nothing is found, then we'll assume we can continue.
if itemLink and (not C_CurrencyInfo.GetCurrencyInfoFromLink(itemLink)) then
local sources = { GetLootSourceInfo(i) }
-- When looting from an openable item (container), the loot source can be
-- missing or only reference the player. In such a case, fall back to the
-- last container item used (tracked in Handlers/Containers.lua).
local hasUsableSource = false
if sources and #sources > 0 then
for j = 1, #sources, 2 do
local unitType = GetUnitTypeFromGUID(sources[j])
if unitType == "Creature" or unitType == "Vehicle" or unitType == "GameObject" then
hasUsableSource = true
break
elseif unitType == "Item" then
-- Item sources are valid even if the GUID->link resolution isn't
-- available yet.
hasUsableSource = true
break
end
end
end
if (not sources) or (#sources == 0) or (not hasUsableSource) then
if LastSeen.WithActiveContainerLootSource then
local lootItem = Item:CreateFromItemLink(itemLink)
lootItem:ContinueOnItemLoad(function()
LastSeen.WithActiveContainerLootSource(function(sourceType, sourceID, sourceName)
if not sourceType or not sourceID or not sourceName then
return
end
local itemName, _, itemQuality, _, _, _, _, _, _, itemTexture, _, classID = C_Item.GetItemInfo(itemLink)
local itemID = C_Item.GetItemInfoInstant(itemLink)
if (itemName and itemQuality and itemTexture and itemID) and (not ignoredItemClasses[classID]) then
LastSeen.Item(
itemID,
itemName,
itemLink,
itemQuality,
itemTexture,
classID,
LastSeen.playerGUID,
LastSeenDB.Characters[LastSeen.playerGUID].name,
LastSeenDB.Characters[LastSeen.playerGUID].level,
sourceType,
sourceID,
sourceName,
LastSeen.currentMapName
)
end
end)
end)
end
elseif sources then
-- I skip every other entry in the table because
-- it's laid out like {guid1, quantity1, guid2, quantity2, ...}.
-- In other words, I only want to know what dropped the item and
-- I don't care about the quantity in which it was dropped.
for j=1,#sources,2 do
local item = Item:CreateFromItemLink(itemLink)
item:ContinueOnItemLoad(function()
local unitType = GetUnitTypeFromGUID(sources[j])
if unitType == "Creature" or unitType == "Vehicle" then
local npcID = GetIDFromGUID(sources[j])
local itemName, _, itemQuality, _, _, _, _, _, _, itemTexture, _, classID = C_Item.GetItemInfo(itemLink)
local itemID = C_Item.GetItemInfoInstant(itemLink)
if (itemName and itemQuality and itemTexture and itemID) and npcID and (not ignoredItemClasses[classID]) then
LastSeen.Item(
itemID,
itemName,
itemLink,
itemQuality,
itemTexture,
classID,
LastSeen.playerGUID,
LastSeenDB.Characters[LastSeen.playerGUID].name,
LastSeenDB.Characters[LastSeen.playerGUID].level,
"Creature",
npcID,
LastSeenDB.Creatures[npcID],
LastSeen.currentMapName
)
end
elseif unitType == "GameObject" then
local objectID = GetIDFromGUID(sources[j])
local itemName, _, itemQuality, _, _, _, _, _, _, itemTexture, _, classID = C_Item.GetItemInfo(itemLink)
local itemID = C_Item.GetItemInfoInstant(itemLink)
if (itemName and itemQuality and itemTexture and itemID) and objectID and (not ignoredItemClasses[classID]) then
LastSeen.Item(
itemID,
itemName,
itemLink,
itemQuality,
itemTexture,
classID,
LastSeen.playerGUID,
LastSeenDB.Characters[LastSeen.playerGUID].name,
LastSeenDB.Characters[LastSeen.playerGUID].level,
"GameObject",
objectID,
LastSeenDB.Objects[objectID],
LastSeen.currentMapName
)
end
elseif unitType == "Item" then
local itemGUID = sources[j]
-- Prefer resolving by GUID; GUID->link can be nil at LOOT_READY execution.
local sourceItem
if Item and Item.CreateFromItemGUID then
sourceItem = Item:CreateFromItemGUID(itemGUID)
else
local lootableItemItemLink = C_Item.GetItemLinkByGUID(itemGUID)
if lootableItemItemLink then
sourceItem = Item:CreateFromItemLink(lootableItemItemLink)
end
end
if not sourceItem then
return
end
sourceItem:ContinueOnItemLoad(function()
local sourceID = sourceItem:GetItemID()
local sourceName = sourceItem:GetItemName()
if not sourceID or not sourceName then
return
end
local itemName, _, itemQuality, _, _, _, _, _, _, itemTexture, _, classID = C_Item.GetItemInfo(itemLink)
local itemID = C_Item.GetItemInfoInstant(itemLink)
if (itemName and itemQuality and itemTexture and itemID) and (not ignoredItemClasses[classID]) then
LastSeen.Item(
itemID,
itemName,
itemLink,
itemQuality,
itemTexture,
classID,
LastSeen.playerGUID,
LastSeenDB.Characters[LastSeen.playerGUID].name,
LastSeenDB.Characters[LastSeen.playerGUID].level,
"Item",
sourceID,
sourceName,
LastSeen.currentMapName
)
end
end)
end
end)
end
end
end
end
end
if event == "NAME_PLATE_UNIT_ADDED" then
local token = ...
if token then
local guid = UnitGUID(token)
local name = UnitName(token)
if issecretvalue(name) or issecretvalue(guid) or name == "Unknown" then return end
if (guid and name) and (not UnitIsFriend("player", token)) and (not UnitIsGameObject(token)) then
local npcID = GetIDFromGUID(guid)
if npcID ~= 0 and (not LastSeenDB.Creatures[npcID]) then
LastSeenDB.Creatures[npcID] = name
end
end
end
end
if event == "PLAYER_LEVEL_CHANGED" then
local _, newLevel = ...
if newLevel then
LastSeenDB.Characters[LastSeen.playerGUID].level = newLevel
end
end
if event == "PLAYER_LOGIN" then
eventFrame:UnregisterEvent(event)
C_Timer.After(1, function()
LastSeen.currentMapID = C_Map.GetBestMapForUnit("player")
if LastSeen.currentMapID then
local map = LastSeen.GetAppropriateMapName(LastSeen.currentMapID)
if map and map ~= 0 then
LastSeen.currentMapName = map.name
LastSeenDB.Maps[map.mapID] = LastSeen.currentMapName
end
end
-- Set the format to use for date entries
local locale = GetLocale()
if locale == "enUS" then
LastSeen.dateFormat = "%m/%d/%Y"
else
LastSeen.dateFormat = "%d/%m/%Y"
end
BuildSearchTextForExistingItems()
-- If an item's source is unknown, then use the sourceType and sourceID as a lookup
-- tool to correct the data entry.
for _, item in pairs(LastSeenDB.Items) do
if item.source == "Unknown" and item.sourceID and item.sourceType then
if item.sourceType == "Creature" then
item.source = LastSeenDB.Creatures[item.sourceID] or item.source
elseif item.sourceType == "Encounter" then
item.source = LastSeenDB.Encounters[item.sourceID] or item.source
elseif item.sourceType == "GameObject" then
item.source = LastSeenDB.Objects[item.sourceID] or item.source
end
end
end
-- Get information about the current character and log that information
LastSeen.playerGUID = UnitGUID("player")
if LastSeen.playerGUID and (not LastSeenDB.Characters[LastSeen.playerGUID]) then
LastSeenDB.Characters[LastSeen.playerGUID] = {}
end
-- General character information
local playerName = UnitName("player")
local playerLevel = UnitLevel("player")
local playerRace = UnitRace("player")
local playerClass = UnitClass("player")
local playerFaction = UnitFactionGroup("player")
local realmName = GetRealmName()
-- Professions
local professionIndices = {GetProfessions()}
local professions = {}
for i,professionIndex in ipairs(professionIndices) do
if professionIndex then
local profession = C_SpellBook.GetSpellBookSkillLineInfo(professionIndex)
if profession then
professions[i] = profession.name or nil
end
end
end
local prof1, prof2 = professions[1], professions[2]
LastSeenDB.Characters[LastSeen.playerGUID] = {
name = playerName,
level = playerLevel,
race = playerRace,
class = playerClass,
faction = playerFaction,
realm = realmName,
professions = { profession1 = prof1, profession2 = prof2 }
}
end)
end
if event == "PLAYER_SOFT_INTERACT_CHANGED" then
local _, newTarget = ...
if newTarget then
local unit = "softinteract"
if UnitIsGameObject(unit) then
local name = UnitName(unit)
local objectID = GetIDFromGUID(newTarget)
if not issecretvalue(name) and not issecretvalue(objectID) and name and objectID then
if not LastSeenDB.Objects[objectID] then
LastSeenDB.Objects[objectID] = name
end
end
end
end
end
if event == "UPDATE_MOUSEOVER_UNIT" then
local token = "mouseover"
if UnitExists(token) then
local guid = UnitGUID(token)
local name = UnitName(token)
if issecretvalue(name) or issecretvalue(guid) then return end
if (guid and name) and (not UnitIsFriend("player", token)) then
local npcID = GetIDFromGUID(guid)
if (npcID ~= 0 and (not LastSeenDB.Creatures[npcID])) or (npcID ~= 0 and LastSeenDB.Creatures[npcID] == "Unknown") then
LastSeenDB.Creatures[npcID] = name
end
end
end
end
if event == "ZONE_CHANGED" or event == "ZONE_CHANGED_NEW_AREA" then
C_Timer.After(1, function()
LastSeen.currentMapID = C_Map.GetBestMapForUnit("player")
if LastSeen.currentMapID then
local map = LastSeen.GetAppropriateMapName(LastSeen.currentMapID)
if map and map ~= 0 then
LastSeen.currentMapName = map.name
LastSeenDB.Maps[map.mapID] = LastSeen.currentMapName
end
end
end)
end
end
eventFrame:RegisterEvent("ADDON_LOADED")
eventFrame:RegisterEvent("ENCOUNTER_START")
eventFrame:RegisterEvent("ENCOUNTER_LOOT_RECEIVED")
eventFrame:RegisterEvent("CHAT_MSG_LOOT")
eventFrame:RegisterEvent("LOOT_CLOSED")
eventFrame:RegisterEvent("LOOT_OPENED")
eventFrame:RegisterEvent("LOOT_READY")
eventFrame:RegisterEvent("SHOW_LOOT_TOAST")
eventFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:RegisterEvent("PLAYER_LEVEL_CHANGED")
eventFrame:RegisterEvent("PLAYER_SOFT_INTERACT_CHANGED")
eventFrame:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
eventFrame:RegisterEvent("ZONE_CHANGED")
eventFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
eventFrame:SetScript("OnEvent", OnEvent)
function LastSeen_AddonCompartment(self, button)
-- Open the search window
LastSeen.Search()
end