-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInstanceCounter.lua
694 lines (577 loc) · 18.8 KB
/
InstanceCounter.lua
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
InstanceCounter = CreateFrame('Frame', 'InstanceCounter')
InstanceCounter:SetScript('OnEvent', function (addon, event, ...) addon[event](addon, ...) end)
InstanceCounter:SetScript('OnUpdate', function (addon, ...) addon["OnUpdate"](addon, ...) end)
InstanceCounter:RegisterEvent('ADDON_LOADED')
InstanceCounter.ADDONNAME = 'InstanceCounter'
InstanceCounter.ADDONVERSION = GetAddOnMetadata(InstanceCounter.ADDONNAME, 'Version')
InstanceCounter.ADDONAUTHOR = GetAddOnMetadata(InstanceCounter.ADDONNAME, 'Author')
local self = InstanceCounter
local L = InstanceCounterLocals
local C = {
BLUE = '|cff00ccff';
GREEN = '|cff66ff33';
RED = '|cffff3300';
YELLOW = '|cffffff00';
WHITE = '|cffffffff';
}
local db = {}
local ADDON_MESSAGE_PREFIX = 'INSTANCE_COUNTER'
local ADDON_MESSAGE_RESET_SPECIFIC = 'INSTANCE RESET\t'
local ADDON_MESSAGE_QUERY_RESETS = 'QUERY RESETS'
local ADDON_MESSAGE_REPLY_QUERY_RESETS = 'QUERY REPLY\t'
local print_debug = false
local name, realm, fullName
local currentSavedCountHour, currentSavedCountDay = 0
local AnnounceCountWhenAboveForHour = 3
local AnnounceCountWhenAboveForDay = 15
local InstancesPerHour = 5
local InstancesPerDay = 30
local LengthOfHour = 3600
local LengthOfDay = 86400
local ListCutOffTime = 86400
local UpdateFrequency = 5
function InstanceCounter:ADDON_LOADED(frame)
if frame ~= InstanceCounter.ADDONNAME then return end
self.debug('ADDON_LOADED')
self:UnregisterEvent('ADDON_LOADED')
self.ADDON_LOADED = nil
-- Init DB
if InstanceCounterDB == nil then InstanceCounterDB = {} end
if InstanceCounterDB.List == nil then InstanceCounterDB.List = {} end
if InstanceCounterDB.DelayedResetList == nil then InstanceCounterDB.DelayedResetList = {} end
if InstanceCounterDB.PlayerLogoutLocation == nil then InstanceCounterDB.PlayerLogoutLocation = {} end
db = InstanceCounterDB
-- Register Events
self.ClearOld()
self:RegisterEvent('PLAYER_ENTERING_WORLD')
self:RegisterEvent('CHAT_MSG_ADDON')
self:RegisterEvent('PLAYER_CAMPING')
self:RegisterEvent('ZONE_CHANGED')
self:RegisterEvent('ZONE_CHANGED_INDOORS')
self:RegisterEvent('ZONE_CHANGED_NEW_AREA')
if # db.List >= 1 then
self:RegisterEvent('CHAT_MSG_SYSTEM')
end
successfulRequest = C_ChatInfo.RegisterAddonMessagePrefix(ADDON_MESSAGE_PREFIX)
if not successfulRequest then
self.error(L['TOO_MANY_PREFIXES'])
end
self.Delayed = true
self.Zoned = true
end
function InstanceCounter:PLAYER_ENTERING_WORLD(isInitialLogin, isReloadingUi)
self.debug('PLAYER_ENTERING_WORLD')
if isInitialLogin then self.debug("Initial Login") end
if isReloadingUi then self.debug("Reload") end
self.Delayed = isInitialLogin
self.Zoned = not isInitialLogin
name, realm = UnitFullName("player")
fullName = name .. "-" .. realm
if self.Delayed then return end
self.ClearOld()
if IsInInstance() then
self.UpdateTimeInInstance()
end
end
function InstanceCounter:PLAYER_CAMPING()
self.debug('PLAYER_CAMPING')
db.PlayerLogoutLocation[fullName] = self.getDetailedLocation();
end
function InstanceCounter:ZONE_CHANGED()
self.debug('ZONE_CHANGED')
self.ZonedIn()
end
function InstanceCounter:ZONE_CHANGED_INDOORS()
self.debug('ZONE_CHANGED_INDOORS')
self.ZonedIn()
end
function InstanceCounter:ZONE_CHANGED_NEW_AREA()
self.debug('ZONE_CHANGED_NEW_AREA')
self.ZonedIn()
end
function InstanceCounter.ZonedIn()
if not self.Zoned then
self.checkForOfflineReset()
self.Zoned = true
end
end
function InstanceCounter:CHAT_MSG_SYSTEM(msg)
if msg == TRANSFER_ABORT_TOO_MANY_INSTANCES then
self.ClearOld()
self.PrintTimeUntilReset()
end
if msg == ERR_LEFT_GROUP_YOU then
self.ResetInstancesByKey('character', fullName)
end
local name = string.match(msg, '(.*) has been reset')
if name ~= nil then
if IsInGroup() then
self.BroadcastReset(name)
end
end
end
function InstanceCounter:CHAT_MSG_ADDON(prefix, msg, channel, sender)
if prefix == ADDON_MESSAGE_PREFIX and (channel == 'PARTY' or channel == 'RAID' or channel == 'WHISPER') and sender ~= fullName then
local name = string.match(msg, ADDON_MESSAGE_RESET_SPECIFIC .. '(.+)')
if (channel == 'PARTY' or channel == 'RAID') and name ~= nil then
self.ResetInstancesByKey('name', name)
end
if (channel == 'PARTY' or channel == 'RAID') and msg == ADDON_MESSAGE_QUERY_RESETS then
self.ReplyToQueryResetRequest(sender)
end
local t = string.match(msg, ADDON_MESSAGE_REPLY_QUERY_RESETS .. '([0-9]+)')
if channel == 'WHISPER' and t ~= nil then
self.ResetInstancesOlderThen(fullName, tonumber(t))
end
elseif prefix == 'instHistory' and not UnitIsUnit(sender, "player") then
if msg == 'GENERATION_ADVANCE' then
self.ResetInstancesByKey('character', fullName)
self.print(L["INSTANCE_RESET"])
end
end
end
function InstanceCounter:OnUpdate(sinceLastUpdate)
self.sinceLastUpdate = (self.sinceLastUpdate or 0) + sinceLastUpdate
if self.sinceLastUpdate >= UpdateFrequency then
self.sinceLastUpdate = 0
if self.Delayed then
if IsInGroup() then
self.BroadcastQueryResets()
end
self.Delayed = false
return
end
if not self.Zoned then
InstanceCounter.ZonedIn()
end
if not self.Zoned then
return
end
self.ClearOld()
countHour, countDay = InstanceCounter.InstanceCount()
if countHour < currentSavedCountHour and currentSavedCountHour > SavedCountAnnounceHourLimit then
self.print(format(L['OPEN_INSTANCES_DAY'], countHour))
end
if countHour < currentSavedCountHour and currentSavedCountDay > SavedCountAnnounceDayLimit then
self.print(format(L['OPEN_INSTANCES_DAY'], countDay))
end
currentSavedCountHour = countHour
currentSavedCountDay = countDay
if IsInInstance() then
self.UpdateTimeInInstance()
end
end
end
function InstanceCounter.BroadcastReset(name)
self.debug("BroadcastReset")
if IsInRaid() then
success = C_ChatInfo.SendAddonMessage(ADDON_MESSAGE_PREFIX, ADDON_MESSAGE_RESET_SPECIFIC .. name, 'RAID')
elseif IsInGroup() then
success = C_ChatInfo.SendAddonMessage(ADDON_MESSAGE_PREFIX, ADDON_MESSAGE_RESET_SPECIFIC .. name, 'PARTY')
end
if not success then
self.error(L['MESSAGE_NOT_SENT'])
end
end
function InstanceCounter.BroadcastQueryResets()
self.debug("BroadcastQueryResets")
if IsInRaid() then
success = C_ChatInfo.SendAddonMessage(ADDON_MESSAGE_PREFIX, ADDON_MESSAGE_QUERY_RESETS, 'RAID')
elseif IsInGroup() then
success = C_ChatInfo.SendAddonMessage(ADDON_MESSAGE_PREFIX, ADDON_MESSAGE_QUERY_RESETS, 'PARTY')
end
if not success then
self.error(L['MESSAGE_NOT_SENT'])
end
end
function InstanceCounter.ReplyQueryResets(name, t)
self.debug("ReplyQueryResets ".. name)
success = C_ChatInfo.SendAddonMessage(ADDON_MESSAGE_PREFIX, ADDON_MESSAGE_REPLY_QUERY_RESETS .. t, 'WHISPER', name)
if not success then
self.error(L['MESSAGE_NOT_SENT'])
end
end
function InstanceCounter.getDetailedLocation()
self.debug("getDetailedLocation")
local name, instanceType, difficultyID = GetInstanceInfo()
if instanceType ~= "party" and instanceType ~= "raid" then return nil end
return {
name = name;
instanceType = instanceType;
difficultyID = difficultyID;
subzone = GetSubZoneText();
}
end
function InstanceCounter.checkForOfflineReset()
self.debug("checkForOfflineReset")
if db.PlayerLogoutLocation[fullName] == nil then return end
self.debug("Logout Location: " .. db.PlayerLogoutLocation[fullName].name .. ' - ' .. db.PlayerLogoutLocation[fullName].subzone)
local currentLocation = self.getDetailedLocation()
if currentLocation ~= nil and
db.PlayerLogoutLocation[fullName].name == currentLocation.name and
db.PlayerLogoutLocation[fullName].subzone ~= currentLocation.subzone then
self.ResetInstancesByKey('character', fullName)
self.debug('Offline reset from location')
self.print(L['OFFLINE_RESET'])
end
db.PlayerLogoutLocation[fullName] = nil
end
function InstanceCounter.UpdateTimeInInstance()
local name, instanceType, difficultyID = GetInstanceInfo()
if instanceType ~= "party" and instanceType ~= "raid" then return end
for i = # db.List, 1, -1 do
if db.List[i].name == name and
db.List[i].instanceType == instanceType and
db.List[i].difficultyID == difficultyID and
db.List[i].character == fullName and
not db.List[i].reset then
db.List[i].lastSeen = time()
return
end
end
if IsInInstance() then
self.AddCurrentInstance()
end
end
function InstanceCounter.AddCurrentInstance()
self.debug("AddCurrentInstance")
local name, instanceType, difficultyID = GetInstanceInfo()
if instanceType ~= "party" and instanceType ~= "raid" then return end
self.AddInstance(name, instanceType, difficultyID)
countHour, countDay = self.InstanceCount()
if countHour >= AnnounceCountWhenAboveForHour and countDay >= AnnounceCountWhenAboveForDay then
self.PrintTimeUntilReset()
elseif countHour >= AnnounceCountWhenAboveForHour then
self.PrintTimeUntilResetHour()
elseif countDay >= AnnounceCountWhenAboveForDay then
self.PrintTimeUntilResetDay()
end
end
function InstanceCounter.AddInstance(name, instanceType, difficultyID)
self.debug("AddInstance")
if self.IsInstanceInList(name, instanceType, difficultyID) then return end
local instance = {
name = name;
instanceType= instanceType;
difficultyID= difficultyID;
character = fullName;
reset = false;
saved = self.IsPlayerSavedToInstance(name, instanceType, difficultyID);
entered = time();
lastSeen = time();
resetTime = nil;
}
table.insert(db.List, instance)
self.SortInstances()
self:RegisterEvent('CHAT_MSG_SYSTEM')
end
function InstanceCounter.ClearInstances()
self.debug("ClearInstances")
db.List = {}
currentSavedCountHour = 0
currentSavedCountDay = 0
self:UnregisterEvent('CHAT_MSG_SYSTEM')
end
function InstanceCounter.ClearOld() -- DOUBLE CHECK!
local t = time()
local removed = false
for i = # db.List, 1, -1 do
if t - db.List[i].lastSeen > ListCutOffTime then
self.debug(format("Removing instance %s from list due to not being seen in 24 hours", db.List[i].name))
table.remove(db.List, i)
removed = true
end
end
for i = # db.DelayedResetList, 1, -1 do
if t - db.DelayedResetList[i].resetTime > ListCutOffTime then
table.remove(db.DelayedResetList, i)
end
end
self.SortInstances()
if # db.List == 0 then
self:UnregisterEvent('CHAT_MSG_SYSTEM')
end
return removed
end
function InstanceCounter.IsInstanceInList(name, instanceType, difficultyID)
for i = 1, # db.List do
if not db.List[i].reset and
db.List[i].name == name and
db.List[i].instanceType == instanceType and
db.List[i].difficultyID == difficultyID and
db.List[i].character == fullName then
return true
end
end
return false
end
function InstanceCounter.IsPlayerSavedToInstance(name, instanceType, difficultyID)
if instanceType == 'party' and difficultyID == 1 then return false end
for i = 1, GetNumSavedInstances() do
local i_name, _, _, i_difficultyID, i_locked = GetSavedInstanceInfo(i)
if i_name == name and i_difficultyID == difficultyID and i_locked then
return true
end
end
return false
end
function InstanceCounter.ResetInstancesForParty()
self.debug("ResetInstancesForParty")
self.ResetInstancesByKey('character', fullName)
t = time()
-- For alts in group --
for groupindex = 1, GetNumGroupMembers() do
local playername, _, _, _, _, _, _, online = GetRaidRosterInfo(groupindex)
if playername ~= nil and not online then
if not string.find(playername,'-') then
playername = playername .. '-' .. realm
end
self.ResetInstancesByKey('character', playername)
self.AddToDelayedReset(playername, t)
end
end
end
function InstanceCounter.ResetInstancesOlderThen(playername, t)
self.debug("ResetInstancesOlderThen")
for i = 1, # db.List do
if db.List[i].character == playername and
db.List[i].lastSeen < t and
not db.List[i].reset and
not db.List[i].saved then
self.print(L["OFFLINE_RESET"])
self.debug('Offline reset from location')
db.List[i].resetTime = time()
db.List[i].reset = true
end
end
end
function InstanceCounter.ResetInstancesByKey(key, value)
self.debug("ResetInstancesByKey")
for i = 1, # db.List do
if db.List[i][key] == value and
not db.List[i].reset and
not db.List[i].saved then
db.List[i].resetTime = time()
db.List[i].reset = true
end
end
end
function InstanceCounter.OnResetInstances()
if not IsInInstance() and (UnitIsGroupLeader('player') or not IsInGroup()) then
self.ResetInstancesForParty()
end
end
function InstanceCounter.SortInstances()
table.sort(db.List, function(a, b) return a.entered < b.entered end)
end
function InstanceCounter.AddToDelayedReset(playername, t)
self.debug("ResetInstancesByKey")
for i = # db.DelayedResetList, 1, -1 do
if db.DelayedResetList[i].name == playername then
db.DelayedResetList[i].resetTime = t
return
end
end
local reset = {
name = playername;
resetTime = t;
}
table.insert(db.DelayedResetList, reset)
end
function InstanceCounter.ReplyToQueryResetRequest(playername)
self.debug("ReplyToQueryResetRequest")
for i = # db.DelayedResetList, 1, -1 do
if db.DelayedResetList[i].name == playername then
InstanceCounter.ReplyQueryResets(playername, db.DelayedResetList[i].resetTime)
table.remove(db.DelayedResetList, i)
return
end
end
end
function InstanceCounter.TimeRemaining(t, period)
local t = period - (time() - t)
local neg = ''
if t < 0 then
t = -t
neg = '-'
end
local sec = t%60
local min = floor(t/60)%60
local hour = floor(t/3600)
if hour > 0 then
return neg .. format("%.2d:%.2d:%.2d", hour, min, sec)
end
return neg .. format("%.2d:%.2d", min, sec)
end
function InstanceCounter.InstanceCount()
local t = time()
local hourCount = 0
local dayCount = 0
if # db.List > 0 then
for i,v in ipairs(db.List) do
if t - v.lastSeen <= LengthOfHour then
hourCount = hourCount + 1
end
if t - v.lastSeen <= LengthOfDay then
dayCount = dayCount + 1
end
end
end
return hourCount, dayCount
end
function InstanceCounter.NextReset(Period)
local t = time()
local lastSeen = t
if # db.List > 0 then
for i,v in ipairs(db.List) do
if (t - v.lastSeen <= Period) and (v.lastSeen < lastSeen) then
lastSeen = v.lastSeen
end
end
end
return lastSeen
end
------ PRINT ------
function InstanceCounter.PrintTimeUntilReset()
self.ClearOld()
local hourCount, dayCount = self.InstanceCount()
if hourCount >= 1 then
self.print(format(L['TIME_REMAINING_HOUR'], hourCount, self.TimeRemaining(self.NextReset(LengthOfHour), LengthOfHour)))
else
self.print(L['NO_INSTANCES_HOUR'])
end
if dayCount >= 1 then
self.print(format(L['TIME_REMAINING_DAY'], dayCount, self.TimeRemaining(self.NextReset(LengthOfDay), LengthOfDay)))
else
self.print(L['NO_INSTANCES_DAY'])
end
end
function InstanceCounter.PrintTimeUntilResetHour()
self.ClearOld()
local hourCount, dayCount = self.InstanceCount()
if hourCount >= 1 then
self.print(format(L['TIME_REMAINING_HOUR'], hourCount, self.TimeRemaining(self.NextReset(LengthOfHour), LengthOfHour)))
else
self.print(L['NO_INSTANCES_HOUR'])
end
end
function InstanceCounter.PrintTimeUntilResetDay()
self.ClearOld()
local hourCount, dayCount = self.InstanceCount()
if dayCount >= 1 then
self.print(format(L['TIME_REMAINING_DAY'], dayCount, self.TimeRemaining(self.NextReset(LengthOfDay), LengthOfDay)))
else
self.print(L['NO_INSTANCES_DAY'])
end
end
function InstanceCounter.PrintInstances()
self.ClearOld()
local hourCount, dayCount = self.InstanceCount()
if hourCount >= 1 then
self.print(L['PRINT_DESCRIPTION_HOUR'])
print(L['PRINT_HEADERS'])
self.PrintInstancesHelper(LengthOfHour)
else
self.print(L['NO_INSTANCES_HOUR'])
end
end
function InstanceCounter.PrintInstancesAll()
self.ClearOld()
local hourCount, dayCount = self.InstanceCount()
if dayCount >= 1 then
self.print(L['PRINT_DESCRIPTION_DAY'])
print(L['PRINT_HEADERS'])
self.PrintInstancesHelper(LengthOfDay)
else
self.print(L['NO_INSTANCES_DAY'])
end
end
function InstanceCounter.PrintInstancesHelper(period)
local t = time()
for i,v in ipairs(db.List) do
if t - v.lastSeen <= period then
local name = strsplit('-', v.character, 2)
print(C.WHITE .. format(L['PRINT_ROW'],
name,
v.reset and (C.RED .. v.name .. C.WHITE) or v.name,
self.TimeRemaining(v.lastSeen, period)))
end
end
end
function InstanceCounter.PrintInstancesToChat(chat, channel)
self.ClearOld()
local hourCount, dayCount = self.InstanceCount()
if hourCount >= 1 then
SendChatMessage(L['NAME'] .. ': ' .. L['PRINT_DESCRIPTION_HOUR'], chat ,"Common", channel)
SendChatMessage(L['PRINT_HEADERS'], chat ,"Common", channel)
self.PrintInstancesToChatHelper(chat, channel, LengthOfHour)
else
self.print(L['NO_INSTANCES_HOUR'])
end
end
function InstanceCounter.PrintInstancesToChatAll(chat, channel)
self.ClearOld()
local hourCount, dayCount = self.InstanceCount()
if dayCount >= 1 then
SendChatMessage(L['NAME'] .. ': ' .. L['PRINT_DESCRIPTION_DAY'], chat ,"Common", channel)
SendChatMessage(L['PRINT_HEADERS'], chat ,"Common", channel)
self.PrintInstancesToChatHelper(chat, channel, LengthOfDay)
else
self.print(L['NO_INSTANCES_DAY'])
end
end
function InstanceCounter.PrintInstancesToChatHelper(chat, channel, period)
local t = time()
for i,v in ipairs(db.List) do
if t - v.lastSeen <= period then
SendChatMessage(format(L['PRINT_ROW'], v.character, v.name, self.TimeRemaining(v.lastSeen, period)), chat ,"Common", channel)
end
end
end
function InstanceCounter.PrintOptions()
local cmd_color = C.RED
local cmd_text = C.WHITE
self.print(cmd_text .. format(L['CMD_HEADER_DESC'],
L['CMD_LONG'], cmd_color .. L['CMD_CMD'] .. cmd_text,
L['CMD_SHORT'], cmd_color .. L['CMD_CMD'] .. cmd_text))
for k, v in pairs(L['CMD']) do
self.print(cmd_text .. format(L['CMD_DESC'], cmd_color .. v['CMD'] .. cmd_text, cmd_color .. v['ARGS'] .. cmd_text, v['DESCRIPTION']))
end
end
function InstanceCounter.debug(msg)
if(print_debug) then
print(C.RED .. L['NAME'] .. ': ' .. C.YELLOW .. msg)
end
end
function InstanceCounter.print(msg)
print(C.GREEN .. L['NAME'] .. ': ' .. C.YELLOW .. msg)
end
function InstanceCounter.error(msg)
print(C.GREEN .. L['NAME'] .. ': ' .. C.RED .. msg)
end
------
hooksecurefunc('ResetInstances', function(...)
self.OnResetInstances()
end)
SlashCmdList['InstanceCounter'] = function(txt)
local txt, arg1, arg2 = strsplit(" ", txt, 3)
if txt == L['CMD']['CLEAR']['CMD'] then
InstanceCounter.ClearInstances()
self.print(L['LIST_CLEARED'])
elseif txt == L['CMD']['PRINT']['CMD'] then
InstanceCounter.PrintInstances()
elseif txt == L['CMD']['PRINTALL']['CMD'] then
InstanceCounter.PrintInstancesAll()
elseif txt == L['CMD']['RESET']['CMD'] then
InstanceCounter.ResetInstancesForParty()
self.print(L['MANUAL_RESET'])
elseif txt == L['CMD']['TIME']['CMD'] then
InstanceCounter.PrintTimeUntilReset()
elseif txt == L['CMD']['REPORT']['CMD'] then
InstanceCounter.PrintInstancesToChat(arg1, arg2)
elseif txt == L['CMD']['REPORTALL']['CMD'] then
InstanceCounter.PrintInstancesToChatAll(arg1, arg2)
else
InstanceCounter.PrintOptions()
end
end