Code polish for release
This commit is contained in:
26
Whoer.lua
26
Whoer.lua
@@ -4,12 +4,16 @@ local addonname, data = ...
|
||||
|
||||
data.Whoer = {}
|
||||
function data.Whoer.Init()
|
||||
if not data.config.who.enabled then return end
|
||||
if not data.config.who.enabled then
|
||||
print("Heimdall - Whoer disabled")
|
||||
return
|
||||
end
|
||||
|
||||
if not Heimdall_Data.who then Heimdall_Data.who = {} end
|
||||
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
|
||||
|
||||
---@type table<string, Player>
|
||||
local players = {}
|
||||
HeimdallStinkies = {}
|
||||
|
||||
---@class Player
|
||||
---@field name string
|
||||
@@ -21,6 +25,7 @@ function data.Whoer.Init()
|
||||
---@field lastSeen string
|
||||
---@field firstSeen string
|
||||
---@field seenCount number
|
||||
---@field stinky boolean?
|
||||
Player = {
|
||||
---@param name string
|
||||
---@param guild string
|
||||
@@ -262,7 +267,7 @@ function data.Whoer.Init()
|
||||
|
||||
if not continue then
|
||||
local timestamp = date("%Y-%m-%dT%H:%M:%S")
|
||||
local player = players[name]
|
||||
local player = HeimdallStinkies[name]
|
||||
if not player then
|
||||
player = Player.new(name, guild, race, class, zone)
|
||||
if not Heimdall_Data.who then Heimdall_Data.who = {} end
|
||||
@@ -280,6 +285,7 @@ function data.Whoer.Init()
|
||||
|
||||
local stinky = data.config.stinkies[name]
|
||||
if stinky then
|
||||
player.stinky = true
|
||||
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
|
||||
else
|
||||
PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master")
|
||||
@@ -292,7 +298,7 @@ function data.Whoer.Init()
|
||||
|
||||
player.lastSeen = timestamp
|
||||
player.seenCount = player.seenCount + 1
|
||||
players[name] = player
|
||||
HeimdallStinkies[name] = player
|
||||
end
|
||||
|
||||
player.lastSeenInternal = GetTime()
|
||||
@@ -304,7 +310,7 @@ function data.Whoer.Init()
|
||||
end
|
||||
player.zone = zone
|
||||
player.lastSeen = timestamp
|
||||
players[name] = player
|
||||
HeimdallStinkies[name] = player
|
||||
if not Heimdall_Data.who then Heimdall_Data.who = {} end
|
||||
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
|
||||
Heimdall_Data.who.data[name] = player
|
||||
@@ -318,11 +324,11 @@ function data.Whoer.Init()
|
||||
|
||||
if not data.who.updateTicker then
|
||||
data.who.updateTicker = C_Timer.NewTicker(0.5, function()
|
||||
for name, player in pairs(players) do
|
||||
for name, player in pairs(HeimdallStinkies) do
|
||||
if player.lastSeenInternal + data.config.who.ttl < GetTime() then
|
||||
NotifyGone(player)
|
||||
PlaySoundFile("Interface\\Sounds\\Uncloak.ogg", "Master")
|
||||
players[name] = nil
|
||||
HeimdallStinkies[name] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -353,7 +359,7 @@ function data.Whoer.Init()
|
||||
whoQueryWhisperFrame:RegisterEvent("CHAT_MSG_WHISPER")
|
||||
whoQueryWhisperFrame:SetScript("OnEvent", function(self, event, msg, sender)
|
||||
if msg == "who" then
|
||||
for _, player in pairs(players) do
|
||||
for _, player in pairs(HeimdallStinkies) do
|
||||
local text = player:NotifyMessage()
|
||||
---@type Message
|
||||
local msg = {
|
||||
@@ -388,7 +394,7 @@ function data.Whoer.Init()
|
||||
end
|
||||
|
||||
if msg == "who" then
|
||||
for _, player in pairs(players) do
|
||||
for _, player in pairs(HeimdallStinkies) do
|
||||
local text = player:NotifyMessage()
|
||||
---@type Message
|
||||
local msg = {
|
||||
@@ -400,4 +406,6 @@ function data.Whoer.Init()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
print("Heimdall - Whoer loaded")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user