Quantcast

Bug fixes.

F16Gaming [10-28-11 - 23:57]
Bug fixes.

ADDED: HasCommand method to CommandManager.
FIXED: HandleMessage will now return if the command sent was invalid (prevents unnecessary "Unregistered Command" spam).
FIXED: Toggling AddOn's enabled state should now work properly.
FIXED: Toggling debugging should now work properly.
Filename
ChatManager.lua
Command.lua
CommandManager.lua
diff --git a/ChatManager.lua b/ChatManager.lua
index 6ca9fe6..d3065b1 100644
--- a/ChatManager.lua
+++ b/ChatManager.lua
@@ -164,6 +164,7 @@ function CM:HandleMessage(msg, sender, channel, target, isBN)
 	self.LastChannel = channel
 	self.LastTarget = target
 	local cmd = self:ParseCommand(args[1])
+	if not CCM:HasCommand(cmd) then return end
 	local t = {}
 	if #args > 1 then
 		for i=2,#args do
diff --git a/Command.lua b/Command.lua
index 4758597..40985ea 100644
--- a/Command.lua
+++ b/Command.lua
@@ -53,7 +53,6 @@ function C:Init()
 	PM = self.PlayerManager
 	log = self.Logger
 	self:LoadSavedVars()
-	log.Settings.Debug = self.Settings.DEBUG
 end

 --- Load the saved variables.
@@ -83,6 +82,7 @@ function C:LoadSavedVars()
 	CM:Init()
 	PM:Init()
 	Cmd:Init()
+	log:SetDebug(self.Settings.DEBUG)
 	self.Global.VERSION = self.VarVersion
 	self.Loaded = true
 end
@@ -113,7 +113,7 @@ end
 --- Toggle AddOn on and off.
 --
 function C:Toggle()
-	return self:SetEnabled(not self.Enabled)
+	return self:SetEnabled(not self.Settings.ENABLED)
 end

 --- Control debugging state.
diff --git a/CommandManager.lua b/CommandManager.lua
index 8e2b805..13e7df0 100644
--- a/CommandManager.lua
+++ b/CommandManager.lua
@@ -65,6 +65,15 @@ function CM:Register(command, access, func)
 	end
 end

+--- Check whether or not a command is registered.
+-- This does NOT take aliases into account.
+-- @param command Command name to check.
+--
+function CM:HasCommand(command)
+	if self.Commands[command] then return true end
+	return false
+end
+
 --- Gets the callback for a command by name.
 -- @param command Name of the command to get.
 -- @return Callback for the command.