Skip to content

Commit

Permalink
Fixed a call in the API 2.0 using a deprecated call from the Open Rai…
Browse files Browse the repository at this point in the history
…d Library
  • Loading branch information
Tercioo committed Apr 26, 2022
1 parent 3afc9ce commit d4f50e7
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 22 deletions.
74 changes: 60 additions & 14 deletions Libs/LibOpenRaid/Deprecated.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,110 @@ end

local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")

local spamLimit = {}

local showDeprecatedMessage = function(deprecatedCall, newCall)
local debugTrace = debugstack(3, 1, 1)
if (debugTrace:find("AddOns\\WeakAuras")) then
local auraName = debugTrace:gsub("%[string \"Error in: ", ""):gsub("':'.*", "")
openRaidLib.DeprecatedMessage("|cFFEEEEEE" .. deprecatedCall .. "|r is deprecated|cFFEEEEEE, please use " .. newCall .. "\nFrom a weakaura named: " .. auraName .. "")
else
debugTrace = debugTrace:gsub("%[.-%]", "")
debugTrace = debugTrace:gsub("\n", "")
openRaidLib.DeprecatedMessage("|cFFEEEEEE" .. deprecatedCall .. "|r is deprecated|cFFEEEEEE, please use " .. newCall .. "\nFrom line" .. debugTrace .. "")
end
end

--> deprecated: 'RequestAllPlayersInfo' has been replaced by 'RequestAllData'
function openRaidLib.RequestAllPlayersInfo()
openRaidLib.DeprecatedMessage("openRaidLib.RequestAllPlayersInfo() is deprecated, please use openRaidLib.RequestAllData().")
if (not spamLimit["openRaidLib.RequestAllData"]) then
spamLimit["openRaidLib.RequestAllData"] = true
showDeprecatedMessage("openRaidLib.RequestAllPlayersInfo()", "openRaidLib.RequestAllData()")
end
end

--> deprecated: 'playerInfoManager' has been replaced by 'UnitInfoManager'
openRaidLib.playerInfoManager = {}
local deprecatedMetatable = {
__newindex = function()
openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager table is deprecated, please use openRaidLib.UnitInfoManager.")
if (not spamLimit["openRaidLib.UnitInfoManager"]) then
openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager table is deprecated, please use openRaidLib.UnitInfoManager.")
showDeprecatedMessage("", "")
spamLimit["openRaidLib.UnitInfoManager"] = true
end
return
end,
__index = function(t, key)
return rawget(t, key) or openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager table is deprecated, please use openRaidLib.UnitInfoManager.")

return rawget(t, key) or showDeprecatedMessage("openRaidLib.playerInfoManager", "openRaidLib.UnitInfoManager")
end,
}
function openRaidLib.playerInfoManager.GetPlayerInfo()
openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager.GetPlayerInfo(unitName) is deprecated, please use openRaidLib.GetUnitInfo(unitId).")
if (not spamLimit["openRaidLib.playerInfoManager.GetPlayerInfo"]) then
showDeprecatedMessage("openRaidLib.playerInfoManager.GetPlayerInfo(unitName)", "openRaidLib.GetUnitInfo(unitId)")
spamLimit["openRaidLib.playerInfoManager.GetPlayerInfo"] = true
end
end
function openRaidLib.playerInfoManager.GetAllPlayersInfo()
openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager.GetAllPlayersInfo() is deprecated, please use openRaidLib.GetAllUnitsInfo().")
if (not spamLimit["openRaidLib.playerInfoManager.GetAllPlayersInfo"]) then
showDeprecatedMessage("openRaidLib.playerInfoManager.GetAllPlayersInfo()", "openRaidLib.GetAllUnitsInfo()")
spamLimit["openRaidLib.playerInfoManager.GetAllPlayersInfo"] = true
end
end
setmetatable(openRaidLib.playerInfoManager, deprecatedMetatable)

--> deprecated: 'gearManager' has been replaced by 'GearManager'
openRaidLib.gearManager = {}
local deprecatedMetatable = {
__newindex = function()
openRaidLib.DeprecatedMessage("openRaidLib.gearManager table is deprecated, please use openRaidLib.GearManager (the G is in upper case).")
if (not spamLimit["openRaidLib.gearManager__newindex"]) then
showDeprecatedMessage("openRaidLib.gearManager", "openRaidLib.GearManager")
spamLimit["openRaidLib.gearManager__newindex"] = true
end
return
end,
__index = function(t, key)
return rawget(t, key) or openRaidLib.DeprecatedMessage("openRaidLib.gearManager table is deprecated, please use openRaidLib.GearManager (the G is in upper case).")
return rawget(t, key) or showDeprecatedMessage("openRaidLib.gearManager", "openRaidLib.GearManager")
end,
}
function openRaidLib.gearManager.GetAllPlayersGear()
openRaidLib.DeprecatedMessage("openRaidLib.gearManager.GetAllPlayersGear() is deprecated, please use openRaidLib.GetAllUnitsGear().")
if (not spamLimit["openRaidLib.gearManager.GetAllPlayersGear"]) then
showDeprecatedMessage("openRaidLib.gearManager.GetAllPlayersGear()", "openRaidLib.GetAllUnitsGear()")
spamLimit["openRaidLib.gearManager.GetAllPlayersGear"] = true
end
end
function openRaidLib.gearManager.GetPlayerGear()
openRaidLib.DeprecatedMessage("openRaidLib.gearManager.GetPlayerGear() is deprecated, please use openRaidLib.GetUnitGear(unitId).")
if (not spamLimit["openRaidLib.gearManager.GetPlayerGear"]) then
showDeprecatedMessage("openRaidLib.gearManager.GetPlayerGear()", "openRaidLib.GetUnitGear(unitId)")
spamLimit["openRaidLib.gearManager.GetPlayerGear"] = true
end
end
setmetatable(openRaidLib.gearManager, deprecatedMetatable)

--> deprecated: 'cooldownManager' has been replaced by 'CooldownManager'
openRaidLib.cooldownManager = {}
local deprecatedMetatable = {
__newindex = function()
openRaidLib.DeprecatedMessage("openRaidLib.cooldownManager table is deprecated, please use openRaidLib.CooldownManager (the C is in upper case).")
if (not spamLimit["openRaidLib.cooldownManager__newindex"]) then
showDeprecatedMessage("openRaidLib.cooldownManager", "openRaidLib.CooldownManager")
spamLimit["openRaidLib.cooldownManager__newindex"] = true
end
return
end,
__index = function(t, key)
return rawget(t, key) or openRaidLib.DeprecatedMessage("openRaidLib.cooldownManager table is deprecated, please use openRaidLib.CooldownManager (the C is in upper case).")
return rawget(t, key) or showDeprecatedMessage("openRaidLib.cooldownManager", "openRaidLib.CooldownManager")
end,
}
function openRaidLib.cooldownManager.GetAllPlayersCooldown()
openRaidLib.DeprecatedMessage("openRaidLib.cooldownManager.GetAllPlayersCooldown() is deprecated, please use openRaidLib.GetAllUnitsCooldown().")
if (not spamLimit["openRaidLib.cooldownManager.GetAllPlayersCooldown"]) then
showDeprecatedMessage("openRaidLib.cooldownManager.GetAllPlayersCooldown()", "openRaidLib.GetAllUnitsCooldown()")
spamLimit["openRaidLib.cooldownManager.GetAllPlayersCooldown"] = true
end
end
function openRaidLib.cooldownManager.GetPlayerCooldowns()
openRaidLib.DeprecatedMessage("openRaidLib.cooldownManager.GetPlayerCooldowns() is deprecated, please use openRaidLib.GetUnitCooldowns(unitId).")
if (not spamLimit["openRaidLib.cooldownManager.GetPlayerCooldowns"]) then
showDeprecatedMessage("openRaidLib.cooldownManager.GetPlayerCooldowns()", "openRaidLib.GetUnitCooldowns(unitId)")
spamLimit["openRaidLib.cooldownManager.GetPlayerCooldowns"] = true
end
end
setmetatable(openRaidLib.cooldownManager, deprecatedMetatable)
12 changes: 8 additions & 4 deletions Libs/LibOpenRaid/LibOpenRaid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
--[=[
Please refer to the docs.txt within this file folder for a guide on how to use this library.
If you get lost on implementing the lib, be free to contact Tercio on Details! discord: https://discord.gg/AGSzAZX or email to [email protected]
UnitID:
UnitID use: "player", "target", "raid18", "party3", etc...
Expand All @@ -26,18 +27,21 @@ Change Log:
TODO:
- need to finish the CheckForSpellsAdeedOrRemoved(), need to send the comm, need to create the local callbacks
- create comm to add or remove a cooldown from an unit
- add unit_connected through comm to know if a unit disconnected
- add into gear info how many tier set parts the player has
- keystone info (portion of the logic is implemented, need to share the information)
- add unit_connected through comm to know if a unit disconnected, do the lib realy need this? I don't think so
- raid lockouts normal-heroic-mythic
- soulbind character (covenant choise) - probably not used in 10.0
- add into gear info how many tier set parts the player has
- (bug) after a /reload, it is not starting new tickers for spells under cooldown
BUGS:
- after a /reload, it is not starting new tickers for spells under cooldown
--]=]



local major = "LibOpenRaid-1.0"
local CONST_LIB_VERSION = 31
local CONST_LIB_VERSION = 32
LIB_OPEN_RAID_CAN_LOAD = false

--declae the library within the LibStub
Expand Down
6 changes: 3 additions & 3 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

local version, build, date, tocversion = GetBuildInfo()

_detalhes.build_counter = 9778
_detalhes.alpha_build_counter = 9778 --if this is higher than the regular counter, use it instead
_detalhes.bcc_counter = 32
_detalhes.build_counter = 9779
_detalhes.alpha_build_counter = 9779 --if this is higher than the regular counter, use it instead
_detalhes.bcc_counter = 33
_detalhes.dont_open_news = true
_detalhes.game_version = version
_detalhes.userversion = version .. _detalhes.build_counter
Expand Down
2 changes: 1 addition & 1 deletion functions/api2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ function Details.UnitInfo (unitId, segment)

local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
if (openRaidLib) then
playerInfo = openRaidLib.playerInfoManager.GetPlayerInfo(unitName)
playerInfo = openRaidLib.GetUnitInfo(unitName)
end

unitInfo.class = playerObject.classe or class or "UNKNOW"
Expand Down
14 changes: 14 additions & 0 deletions startup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ function Details:StartMeUp() --I'll never stop!
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> initialize

C_Timer.After(2, function()
--test libOpenRaid deprecated code
--[=[
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
openRaidLib.playerInfoManager.GetPlayerInfo()
openRaidLib.RequestAllPlayersInfo()
openRaidLib.playerInfoManager.GetAllPlayersInfo()
openRaidLib.gearManager.GetAllPlayersGear()
openRaidLib.gearManager.GetPlayerGear()
openRaidLib.cooldownManager.GetAllPlayersCooldown()
openRaidLib.cooldownManager.GetPlayerCooldowns()
--]=]
end)

--build frames
--plugin container
self:CreatePluginWindowContainer()
Expand Down

0 comments on commit d4f50e7

Please sign in to comment.