zzAddOn.lua: Skip NewAddOn when already added
This commit is contained in:
parent
ff7780f346
commit
b5adbf315d
|
@ -1,4 +1,4 @@
|
||||||
local lib = LibStub:NewLibrary("zzAddOn", 4)
|
local lib = LibStub:NewLibrary("zzAddOn", 5)
|
||||||
if not lib then return end
|
if not lib then return end
|
||||||
local config = LibStub:GetLibrary("zzConfig")
|
local config = LibStub:GetLibrary("zzConfig")
|
||||||
lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
|
lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
|
||||||
|
@ -90,6 +90,16 @@ end
|
||||||
function lib:NewAddOn(addonName, addonTable)
|
function lib:NewAddOn(addonName, addonTable)
|
||||||
local specs = self['specs']
|
local specs = self['specs']
|
||||||
local childName = specs['name']
|
local childName = specs['name']
|
||||||
|
if(lib['addons'][childName]) then
|
||||||
|
local oldchild = lib['addons'][childName]
|
||||||
|
local parent = oldchild:GetParent()
|
||||||
|
if(parent) then
|
||||||
|
print(format("Error: %s already loaded by %s", childName, parent['specs']['name']))
|
||||||
|
else
|
||||||
|
print(format("Error: %s already loaded", childName))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
if(type(childName) == 'string') then
|
if(type(childName) == 'string') then
|
||||||
self.GetAddOnTable = function() return addonTable end
|
self.GetAddOnTable = function() return addonTable end
|
||||||
lib['addons'][childName] = self
|
lib['addons'][childName] = self
|
||||||
|
@ -113,7 +123,7 @@ function lib:Embed(target)
|
||||||
target[name] = lib[name]
|
target[name] = lib[name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for target, _ in pairs(lib['addons']) do
|
for _, target in pairs(lib['addons']) do
|
||||||
lib:Embed(target)
|
lib:Embed(target)
|
||||||
end
|
end
|
||||||
lib['events']:RegisterEvent('ADDON_LOADED')
|
lib['events']:RegisterEvent('ADDON_LOADED')
|
||||||
|
|
Loading…
Reference in New Issue