Quantcast

Additions and bug fixes.

F16Gaming [10-28-11 - 19:24]
Additions and bug fixes.

ADDED: Commands to toggle list mode.
FIXED: Typos on access levels in CommandManager.
FIXED: Should now load properly.
FIXED: All methods used by CommandManager should now return a message at all times.
Filename
Command.lua
CommandManager.lua
EventHandler.lua
PlayerManager.lua
diff --git a/Command.lua b/Command.lua
index 1342a28..4758597 100644
--- a/Command.lua
+++ b/Command.lua
@@ -32,6 +32,7 @@
 Command = {
 	Name = "Command",
 	Version = GetAddOnMetadata("Command", "Version"),
+	Loaded = false,
 	VarVersion = 2,
 	Global = {},
 	Settings = {},
@@ -83,6 +84,7 @@ function C:LoadSavedVars()
 	PM:Init()
 	Cmd:Init()
 	self.Global.VERSION = self.VarVersion
+	self.Loaded = true
 end

 --- Control AddOn state.
@@ -90,24 +92,28 @@ end
 --
 function C:SetEnabled(enabled)
 	self.Settings.ENABLED = enabled
+	if self.Settings.ENABLED then
+		return "AddOn \124cff00FF00enabled\124r."
+	end
+	return "AddOn \124cffFF0000disabled\124r."
 end

 --- Enable AddOn.
 --
 function C:Enable()
-	self:SetEnabled(true)
+	return self:SetEnabled(true)
 end

 --- Disable AddOn.
 --
 function C:Disable()
-	self:SetEnabled(false)
+	return self:SetEnabled(false)
 end

 --- Toggle AddOn on and off.
 --
 function C:Toggle()
-	self:SetEnabled(not self.Enabled)
+	return self:SetEnabled(not self.Enabled)
 end

 --- Control debugging state.
@@ -116,22 +122,26 @@ end
 function C:SetDebug(enabled)
 	self.Settings.DEBUG = enabled
 	log:SetDebug(enabled)
+	if self.Settings.DEBUG then
+		return "Debugging \124cff00FF00enabled\124r."
+	end
+	return "Debugging \124cffFF0000disabled\124r."
 end

 --- Enable debugging.
 --
 function C:EnableDebug()
-	self:SetDebug(true)
+	return self:SetDebug(true)
 end

 --- Disable debugging.
 --
 function C:DisableDebug()
-	self:SetDebug(false)
+	return self:SetDebug(false)
 end

 --- Toggle debugging.
 --
 function C:ToggleDebug()
-	self:SetDebug(not self.Settings.DEBUG)
+	return self:SetDebug(not self.Settings.DEBUG)
 end
diff --git a/CommandManager.lua b/CommandManager.lua
index c59472d..8e2b805 100644
--- a/CommandManager.lua
+++ b/CommandManager.lua
@@ -292,14 +292,18 @@ CM:Register({"convert", "conv"}, PM.Access.Groups.Op.Level, function(args, sende
 	end
 end)

-CM:Register({"list"}, PM.Access.Admin, function(args, sender, isChat)
+CM:Register({"list"}, PM.Access.Groups.Admin.Level, function(args, sender, isChat)
 	if not args[1] then
 		return false, "Missing argument: command name"
 	end
-	return PM:List(args[1]:lower())
+	return PM:ListToggle(args[1]:lower())
 end)

-CM:Register({"groupallow", "gallow"}, PM.Access.Admin, function(args, sender, isChat)
+CM:Register({"listmode", "lm", "lmode"}, PM.Access.Groups.Admin.Level, function(args, sender, isChat)
+	return PM:ToggleListMode()
+end)
+
+CM:Register({"groupallow", "gallow"}, PM.Access.Groups.Admin.Level, function(args, sender, isChat)
 	if #args <= 1 then
 		return false, "Usage: groupallow <groupname> <commandname>"
 	end
@@ -308,7 +312,7 @@ CM:Register({"groupallow", "gallow"}, PM.Access.Admin, function(args, sender, is
 	return PM:GroupAccess(group, cmd, true)
 end)

-CM:Register({"groupdeny", "deny"}, PM.Access.Admin, function(args, sender, isChat)
+CM:Register({"groupdeny", "deny"}, PM.Access.Groups.Admin.Level, function(args, sender, isChat)
 	if #args <= 1 then
 		return false, "Usage: groupdeny <groupname> <commandname>"
 	end
@@ -317,7 +321,7 @@ CM:Register({"groupdeny", "deny"}, PM.Access.Admin, function(args, sender, isCha
 	return PM:GroupAccess(group, cmd, false)
 end)

-CM:Register({"resetgroupaccess", "groupaccessreset", "removegroupaccess", "groupaccessremove", "rga", "gar"}, PM.Access.Admin, function(args, sender, isChat)
+CM:Register({"resetgroupaccess", "groupaccessreset", "removegroupaccess", "groupaccessremove", "rga", "gar"}, PM.Access.Groups.Admin.Level, function(args, sender, isChat)
 	if #args <= 1 then
 		return false, "Usage: resetgroupaccess <groupname> <commandname>"
 	end
@@ -326,7 +330,7 @@ CM:Register({"resetgroupaccess", "groupaccessreset", "removegroupaccess", "group
 	return PM:GroupAccessRemove(group, cmd)
 end)

-CM:Register({"userallow", "uallow"}, PM.Access.Admin, function(args, sender, isChat)
+CM:Register({"userallow", "uallow"}, PM.Access.Groups.Admin.Level, function(args, sender, isChat)
 	if #args <= 1 then
 		return false, "Usage: userallow <playername> <commandname>"
 	end
@@ -335,7 +339,7 @@ CM:Register({"userallow", "uallow"}, PM.Access.Admin, function(args, sender, isC
 	return PM:PlayerAccess(player, cmd, true)
 end)

-CM:Register({"userdeny", "udeny"}, PM.Access.Admin, function(args, sender, isChat)
+CM:Register({"userdeny", "udeny"}, PM.Access.Groups.Admin.Level, function(args, sender, isChat)
 	if #args <= 1 then
 		return false, "Usage: userdeny <playername> <commandname>"
 	end
diff --git a/EventHandler.lua b/EventHandler.lua
index 5201060..2b2d2df 100644
--- a/EventHandler.lua
+++ b/EventHandler.lua
@@ -27,7 +27,7 @@ local CES = C.Extensions.String
 -- @param ... Event arguments.
 --
 function C:OnEvent(frame, event, ...)
-	if not self.Settings.ENABLED then return end
+	if self.Loaded and not self.Settings.ENABLED then return end
 	if not self.Events[event] then return end
 	if CES:StartsWith(event, "CHAT_MSG_") then
 		self.Events[event](self, event, ...)
diff --git a/PlayerManager.lua b/PlayerManager.lua
index 3872f56..db4b17a 100644
--- a/PlayerManager.lua
+++ b/PlayerManager.lua
@@ -579,11 +579,22 @@ function PM:IsListed(command)
 	return List[command]
 end

+--- Set the state of an item on the list.
+-- @param command Command name to modify.
+-- @param list True to list it, false to not list it.
+--
+function PM:List(command, list)
+	if list then
+		return self:ListAdd(command)
+	end
+	return self:ListRemove(command)
+end
+
 --- Dynamically add or remove an item from the list.
 -- @param command Name of command to list.
 --
-function PM:List(command)
-	List[command] = not self:IsListed(command)
+function PM:ListToggle(command)
+	return self:List(command, not self:IsListed(command))
 end

 --- Add a command to the blacklist/whitelist.