Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions PersonalLootHelper-Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ local function GetItemPrimaryAttribute(item)
end

local function IsPlayer(characterName)
if characterName == nil then
return false
end
return characterName == 'player'
or characterName == PLH_GetFullName('player')
or characterName == UnitName('player')
Expand Down Expand Up @@ -1722,6 +1725,10 @@ end

-- Adds the item to the lootedItems array; returns the index of the newly added item
local function AddLootedItem(fullItemInfo, characterName, status)
if characterName == nil then
return nil
end

local lootedItemIndex = #lootedItems + 1

lootedItems[lootedItemIndex] = {}
Expand Down Expand Up @@ -1841,8 +1848,10 @@ function PLH_ProcessTradeItemMessage(looterName, item)
local fullItemInfo = GetFullItemInfo(item)
if shouldAddLootedItem(fullItemInfo) then
local lootedItemIndex = AddLootedItem(fullItemInfo, looterName)
lootedItems[lootedItemIndex][STATUS] = STATUS_AVAILABLE
UpdateLootedItemsDisplay()
if lootedItemIndex ~= nil then
lootedItems[lootedItemIndex][STATUS] = STATUS_AVAILABLE
UpdateLootedItemsDisplay()
end
elseif ShouldAnnounceTrades() then
AddLootedItem(fullItemInfo, looterName, STATUS_HIDDEN)
end
Expand Down Expand Up @@ -1938,7 +1947,7 @@ end
local function PLH_ProcessIdentifyUsersMessage()
-- PLH_SendDebugMessage('Entering PLH_ProcessIdentifyUsersMessage()')

PLH_SendAddonMessage('VERSION~ ~' .. PLH_GetFullName('player') .. '~' .. C_AddOns.GetAddOnMetadata('PersonalLootHelper', 'Version'))
PLH_SendAddonMessage('VERSION~ ~' .. tostring(PLH_GetFullName('player')) .. '~' .. C_AddOns.GetAddOnMetadata('PersonalLootHelper', 'Version'))
end

-- Event handler for CHAT_MSG_ADDON event
Expand All @@ -1948,6 +1957,9 @@ local function AddonMessageReceivedEvent(self, event, ...)
if prefix == 'PLH' then

sender = PLH_GetFullName(sender)
if sender == nil then
return
end

PLH_SendDebugMessage('Received AddonMessage: ' .. message .. ' from ' .. sender)

Expand Down Expand Up @@ -2258,7 +2270,7 @@ end
local function UpdateGroupInfoCache(unit)
local name = PLH_GetFullName(unit)

PLH_SendDebugMessage(' Entering UpdateGroupInfoCache() for ' .. name)
PLH_SendDebugMessage(' Entering UpdateGroupInfoCache() for ' .. tostring(name))

if name ~= nil then
local characterDetails
Expand Down Expand Up @@ -2309,7 +2321,7 @@ local function IsCharacterInGroup(characterName)
local index = 1
local name = select(1, GetRaidRosterInfo(index))
while name ~= nil do
if name == characterName or PLH_GetFullName(name) == characterName then
if (canaccessvalue(name) and name == characterName) or PLH_GetFullName(name) == characterName then
return true
end
index = index + 1
Expand All @@ -2325,6 +2337,9 @@ end
local function InspectReadyEvent(self, event, ...)
local guid = select(1, ...)
local name = select(6, GetPlayerInfoByGUID(guid))
if not canaccessvalue(name) then
return
end

PLH_SendDebugMessage(' Entering InspectReadyEvent() for ' .. name)

Expand Down Expand Up @@ -2471,7 +2486,7 @@ local function Enable()

LoadPlayerItems()

PLH_SendAddonMessage('IDENTIFY_USERS~ ~' .. PLH_GetFullName('player'))
PLH_SendAddonMessage('IDENTIFY_USERS~ ~' .. tostring(PLH_GetFullName('player')))
end

local function Disable()
Expand Down Expand Up @@ -2602,9 +2617,11 @@ function SlashCmdList.PLHCommand(msg)
end
if itemInfo ~= nil then
local lootedItemIndex = AddLootedItem(GetFullItemInfo(itemLink), PLH_GetFullName('player'))
PLH_DoTradeItem(lootedItemIndex)
if PLH_PREFS[PLH_PREFS_SKIP_CONFIRMATION] then -- show confirmation as chat since they won't see it in window
PLH_SendUserMessage("Thank you! Other PLH users have been notified that " .. itemLink .. " is available.")
if lootedItemIndex ~= nil then
PLH_DoTradeItem(lootedItemIndex)
if PLH_PREFS[PLH_PREFS_SKIP_CONFIRMATION] then -- show confirmation as chat since they won't see it in window
PLH_SendUserMessage("Thank you! Other PLH users have been notified that " .. itemLink .. " is available.")
end
end
else
PLH_SendUserMessage("Usage: /plh trade [item]")
Expand Down
6 changes: 6 additions & 0 deletions PersonalLootHelper-Util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@ end
function PLH_GetFullName(name)
if name == nil then
return nil
elseif not canaccessvalue(name) then
-- 12.0 can return a secret name here
return nil
elseif string.find(name, '-') ~= nil then
return GetNameWithoutSpacesInRealm(name)
else
local guid = UnitGUID(name)
if guid ~= nil then
local shortname, realm = UnitNameFromGUID(guid)
if not canaccessvalue(shortname) or not canaccessvalue(realm) then
return nil
end
if not realm or realm == '' then
realm = GetRealmName()
end
Expand Down