From 632cc8b3286036e59d3d9eda675b94b4f31e7101 Mon Sep 17 00:00:00 2001 From: F16Gaming Date: Tue, 8 May 2012 18:41:30 +0200 Subject: [PATCH] Updates to CommandManager, PlayerManager and locales. Cleaned up some whitespace in files. Moved alias "accept" from AcceptLFG command to AcceptInvite command. Disabled AcceptLFG command (unless if in debug) since the function it relies on is protected. The Kick command now takes an override parameter to be able to kick "protected" users (friends/guildies). Fixed readycheck command, normal users are now able to utilize !rc accept/deny while still being unable to issue new ready checks. Added new locales. --- CommandManager.lua | 47 +++++++++--- PlayerManager.lua | 9 ++- locales/enUS.lua | 213 ++++++++++++++++++++++++++-------------------------- locales/svSE.lua | 213 ++++++++++++++++++++++++++-------------------------- 4 files changed, 258 insertions(+), 224 deletions(-) diff --git a/CommandManager.lua b/CommandManager.lua index 0e8f421..d597786 100644 --- a/CommandManager.lua +++ b/CommandManager.lua @@ -1,18 +1,18 @@ --[[ * Copyright (c) 2011-2012 by Adam Hellberg. - * + * * This file is part of Command. - * + * * Command is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Command is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Command. If not, see . --]] @@ -343,7 +343,7 @@ CM:Register({"ban"}, PM.Access.Groups.Admin.Level, function(args, sender, isChat return PM:BanUser(player) end, "CM_BAN_HELP") -CM:Register({"acceptinvite", "acceptinv", "join", "joingroup"}, PM.Access.Groups.User.Level, function(args, sender, isChat) +CM:Register({"accept", "acceptinvite", "acceptinv", "join", "joingroup"}, PM.Access.Groups.User.Level, function(args, sender, isChat) if not StaticPopup_Visible("PARTY_INVITE") then return false, "CM_ACCEPTINVITE_NOTACTIVE" elseif GT:IsInGroup() then @@ -388,7 +388,13 @@ CM:Register({"kick"}, PM.Access.Groups.Op.Level, function(args, sender, isChat) return false, "CM_KICK_USAGE" end local player = PM:GetOrCreatePlayer(args[1]) - return PM:Kick(player, sender, args[2]) + local reason = args[2] + local override = args[3] ~= nil + if (reason:lower() == "override" or reason:lower() == "true") and #args == 2 then + reason = nil + override = true + end + return PM:Kick(player, sender, reason, override) end, "CM_KICK_HELP") CM:Register({"kingme", "givelead"}, PM.Access.Groups.Op.Level, function(args, sender, isChat) @@ -464,9 +470,17 @@ CM:Register({"leavelfg", "cancellfg", "cancel", "leavelfd", "cancellfd"}, PM.Acc return QM:Cancel() end, "CM_LEAVELFG_HELP") -CM:Register({"acceptlfg", "accept", "acceptlfd", "joinlfg", "joinlfd"}, PM.Access.Groups.User.Level, function(args, sender, isChat) - if not QM.QueuedByCommand then +-- So apparently Blizzard does not allow accepting invites without HW event... Making this command useless... +-- I'm keeping this command here for the future, if there will ever be a way to make this work. +CM:Register({"acceptlfg", "acceptlfd", "joinlfg", "joinlfd"}, PM.Access.Groups.User.Level, function(args, sender, isChat) + if not C.Settings.DEBUG then + return false, "CM_ERR_DISABLED" + end + local exists = (select(1, GetLFGProposal())) + if not QM.QueuedByCommand or then return false, "CM_ACCEPTLFG_FAIL" + elseif not exists then + return false, "CM_ACCEPTLFG_NOEXIST" end return QM:Accept() end, "CM_ACCEPTLFG_HELP") @@ -579,9 +593,11 @@ CM:Register({"toggledebug", "td", "debug", "d"}, PM.Access.Local, function(args, return C:ToggleDebug() end, "CM_TOGGLEDEBUG_HELP") -CM:Register({"readycheck", "rc"}, PM.Access.Groups.Op.Level, function(args, sender, isChat) +CM:Register({"readycheck", "rc"}, PM.Access.Groups.User.Level, function(args, sender, isChat) if #args <= 0 then - if GT:IsGroupLeader() or GT:IsRaidLeaderOrAssistant() then + if PM:GetAccess(sender) > PM.Access.Groups.Op.Level then + return "CM_ERR_NOACCESS", {sender.Info.Name, PM.Access.Groups.Op.Level, PM:GetAccess(sender)} + elseif GT:IsGroupLeader() or GT:IsRaidLeaderOrAssistant() then C.Data.ReadyCheckRunning = true local name = tostring(sender.Info.Name) DoReadyCheck() @@ -737,6 +753,9 @@ CM:Register({"raidwarning", "rw", "raid_warning"}, PM.Access.Groups.User.Level, end end Chat:SendMessage(msg, "RAID_WARNING") + if isChat then + return nil -- "CM_RAIDWARNING_SENT" + end return "CM_RAIDWARNING_SENT" end, "CM_RAIDWARNING_HELP") @@ -778,7 +797,11 @@ SlashCmdList[C.Name:upper()] = function(msg, editBox) end C.Logger:Normal(s) end - else - C.Logger:Error(tostring(err)) + elseif arg then + local s = l[arg] + if type(errArg) == "table" then + s = s:format(unpack(errArg)) + end + C.Logger:Error(s) end end diff --git a/PlayerManager.lua b/PlayerManager.lua index 9c831bf..e2ef7ae 100644 --- a/PlayerManager.lua +++ b/PlayerManager.lua @@ -621,18 +621,23 @@ end --- Kick a player from the group. -- @param player Player object of the player to kick. -- @param sender Player object of the player who requested the kick. +-- @param reason Optional reason for the kick. +-- @param override True to kick even if target is friend. -- @return String stating the result of the kick, false if error. -- @return Error message if unsuccessful, nil otherwise. -- -function PM:Kick(player, sender, reason) +function PM:Kick(player, sender, reason, override) if player.Info.Name == UnitName("player") then return false, "PM_KICK_SELF" - elseif self:IsFriend(player) or self:IsBNFriend(player) then + elseif (self:IsFriend(player) or self:IsBNFriend(player)) and not override then return false, "PM_KICK_FRIEND" elseif not GT:IsInGroup(player.Info.Name) then return false, "PM_ERR_NOTINGROUP", {player.Info.Name} end if GT:IsGroupLeader() or GT:IsRaidLeaderOrAssistant() then + if GT:IsRaidAssistant() and GT:IsRaidAssistant(player.Info.Name) then + return false, "PM_KICK_TARGETASSIST", {player.Info.Name} + end KickName = player.Info.Name KickSender = sender.Info.Name KickReason = reason or L("PM_KICK_DEFAULTREASON"):format(KickSender) diff --git a/locales/enUS.lua b/locales/enUS.lua index 7c414f2..678ad14 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -1,18 +1,18 @@ --[[ * Copyright (c) 2011-2012 by Adam Hellberg. - * + * * This file is part of Command. - * + * * Command is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Command is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Command. If not, see . --]] @@ -26,18 +26,18 @@ local L = { LOCALE_UPDATE = "Set new locale to: %s", LOCALE_PI_ACTIVE = "Player independent locale settings is now active.", LOCALE_PI_INACTIVE = "Player independent locale settings is now inactive.", - + ------------- -- General -- ------------- - + YES = "Yes", NO = "No", - + ---------- -- Core -- ---------- - + ADDON_LOAD = "AddOn loaded! Use /cmd help or !help for help.", SVARS_OUTDATED = "Saved Variables out of date, resetting...", NEWVERSION_NOTICE = "\124cffFF0000A new version of \124cff00FFFF%s\124cffFF0000 is available! \124cffFFFF00Check the site you downloaded from for the updated version.", @@ -45,128 +45,130 @@ local L = { DISABLED = "AddOn \124cffFF0000disabled\124r.", DEBUGENABLED = "Debugging \124cff00FF00enabled\124r.", DEBUGDISABLED = "Debugging \124cffFF0000disabled\124r.", - + --------------- -- AddonComm -- --------------- - + AC_ERR_PREFIX = "[FATAL] Failed to register AddOn prefix %q. Maximum number of prefixes reached on client.", AC_ERR_MSGTYPE = "Invalid message type specified: %s", AC_ERR_MALFORMED_DATA = "Malformed data received from %s. Their AddOn is probably outdated.", AC_ERR_MALFORMED_DATA_SEND = "[AddonComm] Malformed data detected (\"%s\"). Aborting Send...", - + AC_GROUP_NORESP = "No response from group, running updater...", AC_GROUP_R_UPDATE = "Updated group members, controller: %s", AC_GROUP_LEFT = "Left group, resetting group variables...", AC_GROUP_WAIT = "Waiting for group response...", AC_GROUP_REMOVE = "Detected that %s is no longer in the group, removing and updating group members...", AC_GROUP_SYNC = "Detected group handlers out of date! Sending sync message...", - + AC_GUILD_NORESP = "No response from guild, running updater...", AC_GUILD_R_UPDATE = "Updated guild members, controller: %s", AC_GUILD_WAIT = "Waiting for guild response...", - + ----------------- -- ChatManager -- ----------------- - + CHAT_ERR_CMDCHAR = "Command char has to be of type string.", CHAT_CMDCHAR_SUCCESS = "Successfully set the command char to: %s", CHAT_HANDLE_NOTCONTROLLER = "Not controller instance for \124cff00FFFF%s\124r, aborting.", - + -------------------- -- CommandManager -- -------------------- - + CM_ERR_NOTALLOWED = "%s is not allowed to be used, %s.", CM_ERR_NOACCESS = "You do not have permission to use that command, %s. Required access level: %d. Your access level: %d.", CM_ERR_NOTREGGED = "%q is not a registered command.", CM_ERR_NOCMDCHAR = "No command character specified.", CM_ERR_NOCHAT = "This command is not allowed to be used from the chat.", CM_ERR_CHATONLY = "This command can only be used from the chat.", - + CM_ERR_DISABLED = "This command has been permanently disabled.", + CM_NO_HELP = "No help available.", - + CM_DEFAULT_HELP = "Prints this help message.", CM_DEFAULT_CHAT = "Type !commands for a listing of commands available.", CM_DEFAULT_END = "End of help message.", - + CM_COMMANDS_HELP = "Print all registered commands.", - + CM_VERSION_HELP = "Print the version of Command.", CM_VERSION = "%s", - + CM_SET_HELP = "Control the settings of Command.", CM_SET_USAGE = "Usage: set cmdchar|groupinvite|setlocale|locale", CM_SET_GROUPINVITE_USAGE = "Usage: set groupinvite enable|disable|