From 0d1152739c736d1cd50aeb1395314491ccf01168 Mon Sep 17 00:00:00 2001 From: F16Gaming Date: Fri, 10 Feb 2012 19:19:41 +0100 Subject: [PATCH] Fixed black/whitelist. --- CommandManager.lua | 4 +++- PlayerManager.lua | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CommandManager.lua b/CommandManager.lua index b99678e..b37a3de 100644 --- a/CommandManager.lua +++ b/CommandManager.lua @@ -133,7 +133,9 @@ function CM:HandleCommand(command, args, isChat, player) local cmd = self:GetCommand(command) if cmd then if isChat then - if not PM:HasAccess(player, cmd) then + if not PM:IsCommandAllowed(cmd) and player.Info.Name ~= UnitName("player") then + return false, ("%s is not allowed to be used, %s."):format(cmd.Name, player.Info.Name) + elseif not PM:HasAccess(player, cmd) then return false, ("You do not have permission to use that command, %s. Required access level: %d. Your access level: %d."):format(player.Info.Name, cmd.Access, PM:GetAccess(player)) end end diff --git a/PlayerManager.lua b/PlayerManager.lua index 44387c3..60b7fdd 100644 --- a/PlayerManager.lua +++ b/PlayerManager.lua @@ -377,10 +377,24 @@ function PM:HasAccess(player, command) if (List[command.Name] and self:GetListMode() == MODE_BLACKLIST) or (not List[command.Name] and self:GetListMode() == MODE_WHITELIST) then hasAccess = false end - if player.Info.Name == UnitName("player") then hasAccess = true end return hasAccess end +function PM:IsCommandAllowed(command) + local name + if type(command) == "table" then + name = command.Name + elseif type(command) == "string" then + name = command + else + return false + end + if (List[command.Name] and self:GetListMode() == MODE_BLACKLIST) or (not List[command.Name] and self:GetListMode() == MODE_WHITELIST) then + return false + end + return true +end + --- Set the access group of supplied player. -- @param player Player to modify. -- @param group Group name to set the player to. -- 1.7.9.5