diff --git a/libs/libhealth.lua b/libs/libhealth.lua index 4060557e..f1bc01d0 100644 --- a/libs/libhealth.lua +++ b/libs/libhealth.lua @@ -10,8 +10,8 @@ local libhealth = CreateFrame("Frame") libhealth.enabled = true libhealth.reqhit = 4 libhealth.reqdmg = 5 -libhealth:RegisterEvent("UNIT_HEALTH") -libhealth:RegisterEvent("UNIT_COMBAT") +libhealth:RegisterUnitEvent("UNIT_HEALTH", "target") +libhealth:RegisterUnitEvent("UNIT_COMBAT", "target") libhealth:RegisterEvent("PLAYER_TARGET_CHANGED") libhealth:RegisterEvent("PLAYER_ENTERING_WORLD") libhealth:SetScript("OnEvent", function() diff --git a/libs/libpredict.lua b/libs/libpredict.lua index 27fa98b4..2943f233 100644 --- a/libs/libpredict.lua +++ b/libs/libpredict.lua @@ -1134,7 +1134,7 @@ libpredict.sender:RegisterEvent("SPELL_HEAL_BY_SELF") libpredict.sender:RegisterEvent("SPELL_HEAL_BY_OTHER") -- populates foreignCache for other healers -- force cache updates -libpredict.sender:RegisterEvent("UNIT_INVENTORY_CHANGED") +libpredict.sender:RegisterUnitEvent("UNIT_INVENTORY_CHANGED", "player") libpredict.sender:RegisterEvent("SKILL_LINES_CHANGED") -- Shared cleanup helper for failed/interrupted casts diff --git a/modules/actionbar.lua b/modules/actionbar.lua index 896ee80f..802b0f83 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -807,10 +807,28 @@ pfUI:RegisterModule("actionbar", function () -- create the main event and update handler for pfUI actionbars local bars = CreateFrame("Frame", "pfActionBar", UIParent) - for event in pairs(special_events) do bars:RegisterEvent(event) end - for event in pairs(global_events) do bars:RegisterEvent(event) end - for event in pairs(aura_events) do bars:RegisterEvent(event) end - for event in pairs(pet_events) do bars:RegisterEvent(event) end + + -- The only unit events in the tables above; both concern the player alone. + -- A registration keeps its kind, so these have to go in unit-filtered from + -- the start -- RegisterUnitEvent over a plain registration stays plain. + local event_units = { + ["UNIT_INVENTORY_CHANGED"] = "player", + ["UNIT_PET"] = "player", + } + + local function RegisterBarEvent(event) + local unit = event_units[event] + if unit then + bars:RegisterUnitEvent(event, unit) + else + bars:RegisterEvent(event) + end + end + + for event in pairs(special_events) do RegisterBarEvent(event) end + for event in pairs(global_events) do RegisterBarEvent(event) end + for event in pairs(aura_events) do RegisterBarEvent(event) end + for event in pairs(pet_events) do RegisterBarEvent(event) end -- refresh actionbar buttons on event bars:SetScript("OnEvent", BarsEvent) diff --git a/modules/buff.lua b/modules/buff.lua index beff5dc3..4bd730e5 100644 --- a/modules/buff.lua +++ b/modules/buff.lua @@ -164,7 +164,7 @@ pfUI:RegisterModule("buff", function () pfUI.buff = CreateFrame("Frame", "pfGlobalBuffFrame", UIParent) pfUI.buff:RegisterEvent("PLAYER_AURAS_CHANGED") pfUI.buff:RegisterEvent("PLAYER_EQUIPMENT_CHANGED") - pfUI.buff:RegisterEvent("UNIT_MODEL_CHANGED") + pfUI.buff:RegisterUnitEvent("UNIT_MODEL_CHANGED", "player") pfUI.buff:RegisterEvent("BUFF_UPDATE_DURATION_SELF") pfUI.buff:RegisterEvent("DEBUFF_UPDATE_DURATION_SELF") pfUI.buff:SetScript("OnEvent", function() diff --git a/modules/castbar.lua b/modules/castbar.lua index fb998cc1..d52e7ba0 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -322,15 +322,21 @@ pfUI:RegisterModule("castbar", function () -- casts only ever fire arg1=="player" -- when the bar's unit resolves to the -- player (target=self). PLAYER_TARGET/FOCUS_CHANGED re-polls so a unit -- already mid-cast when it becomes the target/focus still shows. - cb:RegisterEvent("UNIT_SPELLCAST_START") - cb:RegisterEvent("UNIT_SPELLCAST_STOP") - cb:RegisterEvent("UNIT_SPELLCAST_FAILED") - cb:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED") - cb:RegisterEvent("UNIT_SPELLCAST_DELAYED") - cb:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") - cb:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START") - cb:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP") - cb:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE") + -- Filter to this bar's unit, plus "player" for the target/focus bars: the + -- player's own casts only ever fire arg1=="player", so a self-targeted cast + -- has to reach them too (nil for the player bar itself, which the filter + -- skips). This only narrows what arrives -- the arg1/UnitIsUnit test below + -- still decides whether the bar acts on it. + local selfunit = unitstr ~= "player" and "player" or nil + cb:RegisterUnitEvent("UNIT_SPELLCAST_START", unitstr, selfunit) + cb:RegisterUnitEvent("UNIT_SPELLCAST_STOP", unitstr, selfunit) + cb:RegisterUnitEvent("UNIT_SPELLCAST_FAILED", unitstr, selfunit) + cb:RegisterUnitEvent("UNIT_SPELLCAST_INTERRUPTED", unitstr, selfunit) + cb:RegisterUnitEvent("UNIT_SPELLCAST_DELAYED", unitstr, selfunit) + cb:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", unitstr, selfunit) + cb:RegisterUnitEvent("UNIT_SPELLCAST_CHANNEL_START", unitstr, selfunit) + cb:RegisterUnitEvent("UNIT_SPELLCAST_CHANNEL_STOP", unitstr, selfunit) + cb:RegisterUnitEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", unitstr, selfunit) if unitstr == "target" then cb:RegisterEvent("PLAYER_TARGET_CHANGED") elseif unitstr == "focus" then diff --git a/modules/combopoints.lua b/modules/combopoints.lua index 09c52a20..2704c302 100644 --- a/modules/combopoints.lua +++ b/modules/combopoints.lua @@ -52,7 +52,7 @@ pfUI:RegisterModule("combopoints", function () -- combo if class == "DRUID" or class == "ROGUE" then local combo = CreateFrame("Frame") - combo:RegisterEvent("UNIT_COMBO_POINTS") + combo:RegisterUnitEvent("UNIT_COMBO_POINTS", "player") combo:RegisterEvent("PLAYER_COMBO_POINTS") combo:RegisterEvent("PLAYER_TARGET_CHANGED") combo:RegisterEvent("PLAYER_ENTERING_WORLD") diff --git a/modules/energytick.lua b/modules/energytick.lua index ad7d7fab..6324bd65 100644 --- a/modules/energytick.lua +++ b/modules/energytick.lua @@ -25,9 +25,9 @@ pfUI:RegisterModule("energytick", function() local energytick = CreateFrame("Frame", nil, pfUI.uf.player.power.bar) energytick:SetAllPoints(pfUI.uf.player.power.bar) energytick:RegisterEvent("PLAYER_ENTERING_WORLD") - energytick:RegisterEvent("UNIT_DISPLAYPOWER") - energytick:RegisterEvent("UNIT_ENERGY") - energytick:RegisterEvent("UNIT_MANA") + energytick:RegisterUnitEvent("UNIT_DISPLAYPOWER", "player") + energytick:RegisterUnitEvent("UNIT_ENERGY", "player") + energytick:RegisterUnitEvent("UNIT_MANA", "player") energytick:RegisterEvent("CHAT_MSG_SPELL_SELF_BUFF") energytick:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS") diff --git a/modules/minimap.lua b/modules/minimap.lua index 7351c225..0783a7b7 100644 --- a/modules/minimap.lua +++ b/modules/minimap.lua @@ -225,7 +225,7 @@ pfUI:RegisterModule("minimap", function () pfUI.minimap.pvpicon = CreateFrame("Frame", nil, pfUI.minimap) pfUI.minimap.pvpicon:Hide() pfUI.minimap.pvpicon:RegisterEvent("UPDATE_FACTION") - pfUI.minimap.pvpicon:RegisterEvent("UNIT_FACTION") + pfUI.minimap.pvpicon:RegisterUnitEvent("UNIT_FACTION", "player") pfUI.minimap.pvpicon:SetFrameStrata("HIGH") pfUI.minimap.pvpicon:SetSize(16, 16) pfUI.minimap.pvpicon:SetAlpha(.5) diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 63394b0a..6c784b32 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -490,7 +490,7 @@ local nameplates = CreateFrame("Frame", "pfNameplates", UIParent) nameplates:RegisterEvent("PLAYER_ENTERING_WORLD") nameplates:RegisterEvent("PLAYER_TARGET_CHANGED") nameplates:RegisterEvent("PLAYER_LOGOUT") -nameplates:RegisterEvent("UNIT_COMBO_POINTS") +nameplates:RegisterUnitEvent("UNIT_COMBO_POINTS", "player") nameplates:RegisterEvent("PLAYER_COMBO_POINTS") nameplates:RegisterEvent("ZONE_CHANGED_NEW_AREA") nameplates:RegisterEvent("RAID_ROSTER_UPDATE") diff --git a/modules/panel.lua b/modules/panel.lua index 6cb38aa8..6db455d8 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -486,7 +486,7 @@ pfUI:RegisterModule("panel", function() do -- Ammo local widget = CreateFrame("Frame", "pfPanelWidgetAmmo", UIParent) widget:RegisterEvent("PLAYER_ENTERING_WORLD") - widget:RegisterEvent("UNIT_INVENTORY_CHANGED") + widget:RegisterUnitEvent("UNIT_INVENTORY_CHANGED", "player") widget:RegisterEvent("BAG_UPDATE_DELAYED") widget.Tooltip = function() if GetInventoryItemQuality("player", 0) then diff --git a/modules/swingtimer.lua b/modules/swingtimer.lua index 2c868131..77674945 100644 --- a/modules/swingtimer.lua +++ b/modules/swingtimer.lua @@ -816,7 +816,7 @@ pfUI:RegisterModule("swingtimer", function () events:RegisterEvent("PLAYER_REGEN_DISABLED") events:RegisterEvent("PLAYER_REGEN_ENABLED") events:RegisterEvent("ACTIONBAR_SLOT_CHANGED") - events:RegisterEvent("UNIT_DIED") + events:RegisterUnitEvent("UNIT_DIED", UnitGUID("player")) events:RegisterEvent("SPELL_QUEUE_EVENT") events:RegisterEvent("START_AUTOATTACK") events:RegisterEvent("STOP_AUTOATTACK") diff --git a/modules/xpbar.lua b/modules/xpbar.lua index c8565913..4e42f8e5 100644 --- a/modules/xpbar.lua +++ b/modules/xpbar.lua @@ -363,9 +363,9 @@ end b:EnableMouse(true) b:RegisterEvent("FACTION_STANDING_CHANGED") - b:RegisterEvent("UNIT_PET") - b:RegisterEvent("UNIT_LEVEL") - b:RegisterEvent("UNIT_PET_EXPERIENCE") + b:RegisterUnitEvent("UNIT_PET", "player") + b:RegisterUnitEvent("UNIT_LEVEL", "player") + b:RegisterUnitEvent("UNIT_PET_EXPERIENCE", "player", "pet") b:RegisterEvent("PLAYER_ENTERING_WORLD") b:RegisterEvent("UPDATE_EXHAUSTION") b:RegisterEvent("PLAYER_XP_UPDATE")