From 5bdb7f97f3a3d1a238492ea4979155e9323be5ca Mon Sep 17 00:00:00 2001 From: Meow <30401521+me0wg4ming@users.noreply.github.com> Date: Sat, 28 Feb 2026 08:29:04 +0100 Subject: [PATCH] version push - read the readme for more details version push - read the readme for more details --- README.md | 75 +++++++++++++++++++++++++++++++- libs/libdebuff.lua | 106 ++++++++++++++++++++++++++++++++++++++++++--- pfUI-tbc.toc | 2 +- pfUI.toc | 2 +- 4 files changed, 175 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4afa34a7..81b8abf6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pfUI - Turtle WoW Edition -[![Version](https://img.shields.io/badge/version-7.7.0-blue.svg)](https://github.com/me0wg4ming/pfUI) +[![Version](https://img.shields.io/badge/version-7.8.0-blue.svg)](https://github.com/me0wg4ming/pfUI) [![Turtle WoW](https://img.shields.io/badge/Turtle%20WoW-1.18.0-brightgreen.svg)](https://turtlecraft.gg/) [![SuperWoW](https://img.shields.io/badge/SuperWoW-Required-purple.svg)](https://github.com/balakethelock/SuperWoW) [![Nampower](https://img.shields.io/badge/Nampower-Required-purple.svg)](https://gitea.com/avitasia/nampower) @@ -14,6 +14,79 @@ This version includes significant performance improvements, DLL-enhanced feature --- +## 🎯 What's New in Version 7.8.0 + +### 🔗 libdebuff External Hook System (libs/libdebuff.lua) + +Full event hook system exposed on `pfUI` global — external addons from other creators can now register callbacks for all events processed by libdebuff without registering duplicate event listeners. + +**Usage:** +```lua +-- Register a hook (key = your addon name, value = callback function) +pfUI.libdebuff_spell_go_other_hooks["myaddon"] = function(spellId, casterGuid, targetGuid) + -- fired when any other unit completes a spell cast +end + +-- Unregister +pfUI.libdebuff_spell_go_other_hooks["myaddon"] = nil +``` + +**Available Hooks:** + +| Hook Table | Callback Signature | Fired When | +|---|---|---| +| `pfUI.libdebuff_spell_go_hooks` | `fn(spellId, arg1..arg7)` | `SPELL_GO_SELF` processed (your own casts) | +| `pfUI.libdebuff_spell_go_other_hooks` | `fn(spellId, casterGuid, targetGuid)` | `SPELL_GO_OTHER` processed | +| `pfUI.libdebuff_spell_start_self_hooks` | `fn(spellId, casterGuid, targetGuid, castTime)` | `SPELL_START_SELF` processed | +| `pfUI.libdebuff_spell_start_other_hooks` | `fn(spellId, casterGuid, targetGuid, castTime)` | `SPELL_START_OTHER` processed | +| `pfUI.libdebuff_spell_failed_other_hooks` | `fn(casterGuid, spellId)` | `SPELL_FAILED_OTHER` processed | +| `pfUI.libdebuff_spell_cast_hooks` | `fn(success, spellId, castType, targetGuid)` | `SPELL_CAST_EVENT` processed (your own casts) | +| `pfUI.libdebuff_aura_cast_on_self_hooks` | `fn(spellId, casterGuid, targetGuid)` | `AURA_CAST_ON_SELF` processed | +| `pfUI.libdebuff_aura_cast_on_other_hooks` | `fn(spellId, casterGuid, targetGuid)` | `AURA_CAST_ON_OTHER` processed | +| `pfUI.libdebuff_debuff_added_other_hooks` | `fn(guid, luaSlot, spellId, stackCount)` | `DEBUFF_ADDED_OTHER` processed | +| `pfUI.libdebuff_debuff_removed_other_hooks` | `fn(guid, luaSlot, spellId, stackCount)` | `DEBUFF_REMOVED_OTHER` processed | +| `pfUI.libdebuff_unit_health_hooks` | `fn(unitToken)` | `UNIT_HEALTH` processed | +| `pfUI.libdebuff_unit_died_hooks` | `fn(guid)` | `UNIT_DIED` processed (real death only, not Feign Death) | +| `pfUI.libdebuff_player_target_changed_hooks` | `fn()` | `PLAYER_TARGET_CHANGED` processed | + +### 📖 libdebuff Public API (pfUI.api.libdebuff) + +For direct data access, `pfUI.api.libdebuff` exposes the following methods: + +```lua +local libdebuff = pfUI.api.libdebuff + +-- Get debuff info for a unit by display slot (equivalent to UnitDebuff) +-- Returns: texture, stacks, debuffType, duration, timeleft, caster, spellId +libdebuff:UnitDebuff(unit, displaySlot) + +-- Check if you have a specific debuff on a unit (by name or spellId) +-- Returns: texture, stacks, debuffType, duration, timeleft, spellId +libdebuff:UnitOwnDebuff(unit, id) + +-- Get the best/most recent aura cast info for a spell on a target +-- Returns: { casterGuid, rank, time } +libdebuff:GetBestAuraCast(guid, spellName) + +-- Get all enhanced debuff data for a target GUID (Nampower path) +-- Returns table of active debuffs with full metadata +libdebuff:GetEnhancedDebuffs(targetGUID) + +-- Get the spell icon texture for a spellId +-- Returns: texture path string or nil +libdebuff:GetSpellIcon(spellId) + +-- Get duration info for a debuff effect +-- Returns: duration in seconds +libdebuff:GetDuration(effect, rank) + +-- Get the maximum known rank for a debuff effect +-- Returns: rank number +libdebuff:GetMaxRank(effect) +``` + +--- + ## 🎯 What's New in Version 7.7.0 (February 25, 2026) 🗡️ Swingtimer Overhaul (swingtimer.lua) diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index b43dfd87..25a0d8dd 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -164,6 +164,39 @@ local recentCasts = pfUI.libdebuff_recent_casts -- Callbacks fired after SPELL_GO_SELF is processed: fn(spellId, arg1, arg2, arg3, arg4, arg5, arg6, arg7) pfUI.libdebuff_spell_go_hooks = pfUI.libdebuff_spell_go_hooks or {} +-- Callbacks fired after SPELL_GO_OTHER is processed: fn(spellId, casterGuid, targetGuid) +pfUI.libdebuff_spell_go_other_hooks = pfUI.libdebuff_spell_go_other_hooks or {} + +-- Callbacks fired after SPELL_START_SELF is processed: fn(spellId, casterGuid, targetGuid, castTime) +pfUI.libdebuff_spell_start_self_hooks = pfUI.libdebuff_spell_start_self_hooks or {} + +-- Callbacks fired after SPELL_START_OTHER is processed: fn(spellId, casterGuid, targetGuid, castTime) +pfUI.libdebuff_spell_start_other_hooks = pfUI.libdebuff_spell_start_other_hooks or {} + +-- Callbacks fired after SPELL_FAILED_OTHER is processed: fn(casterGuid, spellId) +pfUI.libdebuff_spell_failed_other_hooks = pfUI.libdebuff_spell_failed_other_hooks or {} + +-- Callbacks fired after AURA_CAST_ON_SELF is processed: fn(spellId, casterGuid, targetGuid) +pfUI.libdebuff_aura_cast_on_self_hooks = pfUI.libdebuff_aura_cast_on_self_hooks or {} + +-- Callbacks fired after AURA_CAST_ON_OTHER is processed: fn(spellId, casterGuid, targetGuid) +pfUI.libdebuff_aura_cast_on_other_hooks = pfUI.libdebuff_aura_cast_on_other_hooks or {} + +-- Callbacks fired after DEBUFF_ADDED_OTHER is processed: fn(guid, luaSlot, spellId, stackCount) +pfUI.libdebuff_debuff_added_other_hooks = pfUI.libdebuff_debuff_added_other_hooks or {} + +-- Callbacks fired after DEBUFF_REMOVED_OTHER is processed: fn(guid, luaSlot, spellId, stackCount) +pfUI.libdebuff_debuff_removed_other_hooks = pfUI.libdebuff_debuff_removed_other_hooks or {} + +-- Callbacks fired after UNIT_HEALTH is processed: fn(unitToken) +pfUI.libdebuff_unit_health_hooks = pfUI.libdebuff_unit_health_hooks or {} + +-- Callbacks fired after PLAYER_TARGET_CHANGED is processed: fn() +pfUI.libdebuff_player_target_changed_hooks = pfUI.libdebuff_player_target_changed_hooks or {} + +-- Callbacks fired after UNIT_DIED is processed: fn(guid) +pfUI.libdebuff_unit_died_hooks = pfUI.libdebuff_unit_died_hooks or {} + -- Callbacks fired after SPELL_CAST_EVENT is processed: fn(success, spellId, castType, targetGuid) pfUI.libdebuff_spell_cast_hooks = pfUI.libdebuff_spell_cast_hooks or {} local AURA_CAST_DEDUPE_WINDOW = 0.1 -- Ignore duplicates within 100ms @@ -1129,6 +1162,7 @@ if hasNampower then frame:RegisterEvent("SPELL_GO_SELF") frame:RegisterEvent("SPELL_GO_OTHER") frame:RegisterEvent("SPELL_FAILED_OTHER") + frame:RegisterEvent("UNIT_DIED") frame:RegisterEvent("SPELL_CAST_EVENT") frame:RegisterEvent("AURA_CAST_ON_SELF") frame:RegisterEvent("AURA_CAST_ON_OTHER") @@ -1155,7 +1189,12 @@ if hasNampower then if guid and UnitIsDead and UnitIsDead(guid) then CleanupUnit(guid) end - + if pfUI.libdebuff_unit_health_hooks then + for _, fn in pairs(pfUI.libdebuff_unit_health_hooks) do + fn(arg1) + end + end + elseif event == "SPELL_START_SELF" or event == "SPELL_START_OTHER" then local itemId = arg1 local spellId = arg2 @@ -1208,7 +1247,17 @@ if hasNampower then endTime = castTime and (GetTime() + castTime / 1000) or nil, event = "START" } - + + if event == "SPELL_START_SELF" and pfUI.libdebuff_spell_start_self_hooks then + for _, fn in pairs(pfUI.libdebuff_spell_start_self_hooks) do + fn(spellId, casterGuid, arg4, castTime) + end + elseif event == "SPELL_START_OTHER" and pfUI.libdebuff_spell_start_other_hooks then + for _, fn in pairs(pfUI.libdebuff_spell_start_other_hooks) do + fn(spellId, casterGuid, arg4, castTime) + end + end + elseif event == "SPELL_GO_SELF" or event == "SPELL_GO_OTHER" then local itemId = arg1 local spellId = arg2 @@ -1275,14 +1324,33 @@ if hasNampower then fn(spellId, arg1, arg2, arg3, arg4, arg5, arg6, arg7) end end - + + -- Fire registered SPELL_GO_OTHER hooks + if event == "SPELL_GO_OTHER" and pfUI.libdebuff_spell_go_other_hooks then + for _, fn in pairs(pfUI.libdebuff_spell_go_other_hooks) do + fn(spellId, casterGuid, targetGuid) + end + end + + elseif event == "UNIT_DIED" then + if pfUI.libdebuff_unit_died_hooks then + for _, fn in pairs(pfUI.libdebuff_unit_died_hooks) do + fn(arg1) + end + end + elseif event == "SPELL_FAILED_OTHER" then local casterGuid = arg1 if casterGuid and pfUI.libdebuff_casts[casterGuid] then pfUI.libdebuff_casts[casterGuid] = nil end - + if pfUI.libdebuff_spell_failed_other_hooks then + for _, fn in pairs(pfUI.libdebuff_spell_failed_other_hooks) do + fn(casterGuid, arg2) + end + end + elseif event == "SPELL_CAST_EVENT" then -- Capture combo points BEFORE they're consumed -- This event fires when YOU cast a spell (before server processes it) @@ -1579,7 +1647,16 @@ if hasNampower then caster = "player", stacks = 1 } - + if event == "AURA_CAST_ON_SELF" and pfUI.libdebuff_aura_cast_on_self_hooks then + for _, fn in pairs(pfUI.libdebuff_aura_cast_on_self_hooks) do + fn(spellId, casterGuid, targetGuid) + end + elseif event == "AURA_CAST_ON_OTHER" and pfUI.libdebuff_aura_cast_on_other_hooks then + for _, fn in pairs(pfUI.libdebuff_aura_cast_on_other_hooks) do + fn(spellId, casterGuid, targetGuid) + end + end + elseif event == "DEBUFF_ADDED_OTHER" then local guid = arg1 local displaySlot = arg2 -- Display slot (1-16), compacted @@ -1711,7 +1788,12 @@ if hasNampower then if pfUI.nameplates and pfUI.nameplates.OnAuraUpdate then pfUI.nameplates:OnAuraUpdate(guid) end - + if pfUI.libdebuff_debuff_added_other_hooks then + for _, fn in pairs(pfUI.libdebuff_debuff_added_other_hooks) do + fn(arg1, arg2, arg3, arg4) + end + end + elseif event == "DEBUFF_REMOVED_OTHER" then local guid = arg1 local displaySlot = arg2 -- Display slot (1-16), compacted @@ -1800,7 +1882,12 @@ if hasNampower then if pfUI.nameplates and pfUI.nameplates.OnAuraUpdate then pfUI.nameplates:OnAuraUpdate(guid) end - + if pfUI.libdebuff_debuff_removed_other_hooks then + for _, fn in pairs(pfUI.libdebuff_debuff_removed_other_hooks) do + fn(arg1, arg2, arg3, arg4) + end + end + elseif event == "PLAYER_TARGET_CHANGED" then if not UnitExists then return end local _, targetGuid = UnitExists("target") @@ -1812,6 +1899,11 @@ if hasNampower then -- Cleanup expired timers for new target CleanupExpiredTimers(targetGuid) end + if pfUI.libdebuff_player_target_changed_hooks then + for _, fn in pairs(pfUI.libdebuff_player_target_changed_hooks) do + fn() + end + end end -- Periodic cleanup diff --git a/pfUI-tbc.toc b/pfUI-tbc.toc index b4693821..c4693fb7 100644 --- a/pfUI-tbc.toc +++ b/pfUI-tbc.toc @@ -3,7 +3,7 @@ ## Author: Shagu - modfied by me0wg4ming ## Notes: A complete user interface replacement. ## Notes-ruRU: Полная замена пользовательского интерфейса. -## Version: 7.7.0 +## Version: 7.8.0 ## SavedVariables: pfUI_profiles, pfUI_addon_profiles, pfUI_cache, pfUI_throttle ## SavedVariablesPerCharacter: pfUI_config, pfUI_init, pfUI_playerDB diff --git a/pfUI.toc b/pfUI.toc index 78221aae..9bc25284 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -3,7 +3,7 @@ ## Author: Shagu - modfied by me0wg4ming ## Notes: A complete user interface replacement. ## Notes-ruRU: Полная замена пользовательского интерфейса. -## Version: 7.7.0 +## Version: 7.8.0 ## SavedVariables: pfUI_profiles, pfUI_addon_profiles, pfUI_cache, pfUI_throttle ## SavedVariablesPerCharacter: pfUI_config, pfUI_init, pfUI_playerDB