Clean up the modules a little

This commit is contained in:
2025-05-04 20:47:00 +02:00
parent 1da1e7bf9f
commit 3a1639ab27
9 changed files with 53 additions and 36 deletions

View File

@@ -1,6 +1,5 @@
local addonname, shared = ...
local _, shared = ...
---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "BonkDetector"
---@diagnostic disable-next-line: missing-fields
@@ -30,14 +29,23 @@ function shared.BonkDetector.Init()
return
end
local source, err = CLEUParser.GetSourceName(...)
---@type string|nil, string, string, string, string
local err, source, sourceGUID, destination, destinationGUID
source, err = CLEUParser.GetSourceName(...)
if err then
if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Error getting source name: %s", ModuleName, err))
end
return
end
local sourceGUID = CLEUParser.GetSourceGUID(...)
sourceGUID, err = CLEUParser.GetSourceGUID(...)
if err then
if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Error getting source GUID: %s", ModuleName, err))
end
return
end
if not string.find(sourceGUID, "Player") then
if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Source %s is not a player, nothing to do", ModuleName, source))
@@ -45,14 +53,20 @@ function shared.BonkDetector.Init()
return
end
local destination, err = CLEUParser.GetDestName(...)
destination, err = CLEUParser.GetDestName(...)
if err then
if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Error getting destination name: %s", ModuleName, err))
end
return
end
local destinationGUID = CLEUParser.GetDestGUID(...)
destinationGUID, err = CLEUParser.GetDestGUID(...)
if err then
if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Error getting destination GUID: %s", ModuleName, err))
end
return
end
if not string.find(destinationGUID, "Player") then
if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Destination %s is not a player, nothing to do", ModuleName, destination))