update LibElvUIPlugin

This commit is contained in:
Crum
2018-01-21 21:34:46 -06:00
parent ed64ac7202
commit 8d353ec83b
@@ -5,7 +5,7 @@ if not lib then return end
--Cache global variables --Cache global variables
--Lua functions --Lua functions
local pairs, tonumber = pairs, tonumber local pairs, tonumber = pairs, tonumber
local format, gsub, strmatch, strsplit = string.format, string.gsub, string.match, string.split local format, gsub, strmatch, strsplit = format, gsub, strmatch, strsplit
--WoW API / Variables --WoW API / Variables
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
local GetAddOnMetadata = GetAddOnMetadata local GetAddOnMetadata = GetAddOnMetadata
@@ -63,7 +63,7 @@ end
-- Registers a module with the given name and option callback, pulls version info from metadata -- Registers a module with the given name and option callback, pulls version info from metadata
-- --
function lib:RegisterPlugin(name,callback, isLib) function lib:RegisterPlugin(name, callback, isLib)
local plugin = {} local plugin = {}
plugin.name = name plugin.name = name
plugin.version = name == MAJOR and MINOR or GetAddOnMetadata(name, "Version") plugin.version = name == MAJOR and MINOR or GetAddOnMetadata(name, "Version")
@@ -85,8 +85,8 @@ function lib:RegisterPlugin(name,callback, isLib)
if not lib.ConfigFrame then if not lib.ConfigFrame then
local configFrame = CreateFrame("Frame") local configFrame = CreateFrame("Frame")
configFrame:RegisterEvent("ADDON_LOADED") configFrame:RegisterEvent("ADDON_LOADED")
configFrame:SetScript("OnEvent", function(self, event, addon) configFrame:SetScript("OnEvent", function()
if addon == "ElvUI_Config" then if arg1 == "ElvUI_Config" then
for _, PlugIn in pairs(lib.plugins) do for _, PlugIn in pairs(lib.plugins) do
if PlugIn.callback then if PlugIn.callback then
PlugIn.callback() PlugIn.callback()
@@ -147,17 +147,17 @@ local function SendPluginVersionCheck(self)
end end
end end
function lib:VersionCheck(event, prefix, message, channel, sender) function lib:VersionCheck()
if not ElvUI[1].global.general.versionCheck then return end if not ElvUI[1].global.general.versionCheck then return end
local E = ElvUI[1] local E = ElvUI[1]
if event == "CHAT_MSG_ADDON" then if event == "CHAT_MSG_ADDON" then
if not (prefix == lib.prefix and sender and message and not strmatch(message, "^%s-$")) then return end if not (arg1 == lib.prefix and arg4 and arg1 and not strmatch(arg1, "^%s-$")) then return end
if sender == E.myname then return end if arg4 == E.myname then return end
if not E["pluginRecievedOutOfDateMessage"] then if not E["pluginRecievedOutOfDateMessage"] then
local name, version, plugin, Pname local name, version, plugin, Pname
for _, p in pairs({strsplit(";",message)}) do for _, p in pairs({strsplit(";", arg2)}) do
if not strmatch(p, "^%s-$") then if not strmatch(p, "^%s-$") then
name, version = strmatch(p, "([%w_]+)=([%d%p]+)") name, version = strmatch(p, "([%w_]+)=([%d%p]+)")
if lib.plugins[name] then if lib.plugins[name] then
@@ -196,7 +196,7 @@ function lib:GeneratePluginList()
if plugin.name ~= MAJOR then if plugin.name ~= MAJOR then
author = GetAddOnMetadata(plugin.name, "Author") author = GetAddOnMetadata(plugin.name, "Author")
Pname = GetAddOnMetadata(plugin.name, "Title") or plugin.name Pname = GetAddOnMetadata(plugin.name, "Title") or plugin.name
color = plugin.old and E:RGBToHex(1,0,0) or E:RGBToHex(0,1,0) color = plugin.old and E:RGBToHex(1, 0, 0) or E:RGBToHex(0, 1, 0)
list = list .. Pname list = list .. Pname
if author then if author then
list = list .. " ".. INFO_BY .." " .. author list = list .. " ".. INFO_BY .." " .. author
@@ -212,7 +212,7 @@ function lib:GeneratePluginList()
end end
function lib:SendPluginVersionCheck(message) function lib:SendPluginVersionCheck(message)
if (not message) or strmatch(message, "^%s-$") then return end if not message or strmatch(message, "^%s-$") then return end
local ChatType local ChatType
if GetNumRaidMembers() > 1 then if GetNumRaidMembers() > 1 then
@@ -227,11 +227,11 @@ function lib:SendPluginVersionCheck(message)
if msgLength > maxChar then if msgLength > maxChar then
local delay, splitMessage = 0 local delay, splitMessage = 0
for _ = 1, ceil(msgLength/maxChar) do for _ = 1, ceil(msgLength / maxChar) do
splitMessage = strmatch(strsub(message, 1, maxChar), ".+;") splitMessage = strmatch(strsub(message, 1, maxChar), ".+;")
if splitMessage then -- incase the string is over `maxChar` but doesnt contain `;` if splitMessage then -- incase the string is over `maxChar` but doesnt contain `;`
message = gsub(message, "^"..gsub(splitMessage, '([%-%.%+%[%]%(%)%$%^%%%?%*])','%%%1'), "") message = gsub(message, "^"..gsub(splitMessage, "([%-%.%+%[%]%(%)%$%^%%%?%*])","%%%1"), "")
ElvUI[1]:Delay(delay, SendAddonMessage, lib.prefix, splitMessage, ChatType) ElvUI[1]:Delay(delay, SendAddonMessage, lib.prefix, splitMessage, ChatType)
delay = delay + 1 delay = delay + 1
end end