Fixes npe.

github@spradlin.dev [09-24-21 - 23:49]
Fixes npe.
Adds website/feedback links.
Filename
MuteBards2.lua
MuteBardsOptions.lua
diff --git a/MuteBards2.lua b/MuteBards2.lua
index 4fcda1c..2a95218 100644
--- a/MuteBards2.lua
+++ b/MuteBards2.lua
@@ -1,6 +1,6 @@
 MuteBards = MuteBards or {};
 MuteBards.name = "MuteBards2"
-MuteBards.Version = "2.0 r5"
+MuteBards.version = "2.0 r5"

 local savedVars = {}
 MuteBards.sv = savedVars; -- saved vars
@@ -57,7 +57,7 @@ function MuteBards2_OnCombatStateChange(event_id, inCombat)
 end

 function MuteBards:AddZone(zoneName, cb)
-  if (MuteBards:ContainsZone(zoneName)) then
+  if (self:ContainsZone(zoneName)) then
     d('Zone ' .. zoneName .. ' already in list');
     return;
   end
@@ -69,7 +69,7 @@ function MuteBards:AddZone(zoneName, cb)
 end

 function MuteBards:RemoveZone(zoneName, cb)
-  if (MuteBards:ContainsZone(zoneName)) then
+  if (self:ContainsZone(zoneName)) then
     for i, v in ipairs(getSVZones(savedVars)) do
       if (v:lower() == zoneName:lower()) then
         table.remove(getSVZones(savedVars), i);
@@ -89,8 +89,10 @@ function MuteBards:ContainsZone(zoneName)
     return false;
   end
   for i, v in ipairs(getSVZones(savedVars)) do
-    if (v:lower() == zoneName:lower()) then
-      return true;
+    if (v ~= nil and zoneName ~= nil) then -- protects against indexing nil on next line
+      if (v:lower() == zoneName:lower()) then
+        return true;
+      end
     end
   end
   return false;
diff --git a/MuteBardsOptions.lua b/MuteBardsOptions.lua
index cf7415c..ce91b66 100644
--- a/MuteBardsOptions.lua
+++ b/MuteBardsOptions.lua
@@ -3,7 +3,7 @@ local isInitialized = false;
 function MuteBards:InitSettingsPanel(svZones, svChar)

   local function refreshCallback()
-    MuteBards:Refresh();
+    self:Refresh();
   end

   local function getCurrentZoneName(sv)
@@ -15,10 +15,12 @@ function MuteBards:InitSettingsPanel(svZones, svChar)

   local panelData = {
     type = "panel",
-    name = "MuteBards 2.0",
-    displayName = "MuteBards 2.0",
-    author = "MadDachshund",
-    version = "2.0",
+    name = "Mute Bards 2",
+    displayName = "Mute Bards 2",
+    author = "@MadDachshund",
+    version = self.version,
+    website = "https://www.esoui.com/downloads/info3199-MuteBards2.html",
+    feedback = "https://www.esoui.com/downloads/info3199-MuteBards2.html#comments",
     slashCommand = "/mutebards", --(optional) will register a keybind to open to this panel
     registerForRefresh = true, --boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown)
     registerForDefaults = false, --boolean (optional) (will set all options controls back to default values)
@@ -51,7 +53,7 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
       disabled = function()  return getCurrentZoneName(svChar) == "UNKNOWN" end,
       func = function()
         if (getCurrentZoneName(svChar) ~= "UNKNOWN") then
-          MuteBards:AddZone(getCurrentZoneName(svChar), refreshCallback);
+          self:AddZone(getCurrentZoneName(svChar), refreshCallback);
         end
       end,
       width = "half", --or "half" (optional)
@@ -74,7 +76,7 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
       type = "button",
       name = "Add",
       func = function()
-        MuteBards:AddZone(zoneToAdd, refreshCallback);
+        self:AddZone(zoneToAdd, refreshCallback);
         zoneToAdd = "";
       end,
       width = "half", --or "half" (optional)
@@ -105,7 +107,7 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
       type = "button",
       name = "Remove",
       func = function()
-        MuteBards:RemoveZone(zoneToRemove, refreshCallback);
+        self:RemoveZone(zoneToRemove, refreshCallback);
         zoneToRemove = "";
       end,
       width = "half", --or "full" (optional)