Fixed PlayerManager using one player table for ALL realms.
F16Gaming [04-01-12 - 16:31]
Fixed PlayerManager using one player table for ALL realms.
PlayerManager now has a separate Players DB for each realm.
Added command to set/toggle PlayerIndependent setting in LocaleManager.
diff --git a/CommandManager.lua b/CommandManager.lua
index 6282547..26af309 100644
--- a/CommandManager.lua
+++ b/CommandManager.lua
@@ -221,6 +221,14 @@ CM:Register({"set", "s"}, PM.Access.Groups.Admin.Level, function(args, sender, i
return L:ResetLocale()
elseif sub:match("^u.*m") then -- Use master
return L:UseMasterLocale()
+ elseif sub:match("^p.*i") then -- Player Independent
+ local enabled = tostring(args[3]):lower()
+ if enabled:match("^[eay]") then
+ return L:EnablePlayerIndependent()
+ elseif enabled:match("^[dn]") then
+ return L:DisablePlayerIndependent()
+ end
+ return L:TogglePlayerIndependent()
end
return false, "CM_SET_LOCALE_USAGE"
end
diff --git a/LocaleManager.lua b/LocaleManager.lua
index 6bad1fe..ee0aff6 100644
--- a/LocaleManager.lua
+++ b/LocaleManager.lua
@@ -141,3 +141,23 @@ end
function LM:UseMasterLocale()
return self:SetLocale(self.Master)
end
+
+function LM:SetPlayerIndependent(active)
+ self.Settings.PLAYER_INDEPENDENT = active
+ if self.Settings.PLAYER_INDEPENDENT then
+ return "LOCALE_PI_ACTIVE"
+ end
+ return "LOCALE_PI_INACTIVE"
+end
+
+function LM:EnablePlayerIndependent()
+ return self:SetPlayerIndependent(true)
+end
+
+function LM:DisablePlayerIndependent()
+ return self:SetPlayerIndependent(false)
+end
+
+function LM:TogglePlayerIndependent()
+ return self:SetPlayerIndependent(not self.Settings.PLAYER_INDEPENDENT)
+end
diff --git a/PlayerManager.lua b/PlayerManager.lua
index da17f11..d72b1b6 100644
--- a/PlayerManager.lua
+++ b/PlayerManager.lua
@@ -38,6 +38,7 @@ local log
-- @field Access Table containing all available access groups.
--
C.PlayerManager = {
+ VarVersion = 1,
Access = {
Min = 0,
Max = 4,
@@ -165,9 +166,18 @@ function PM:LoadSavedVars()
C.Global["PLAYER_MANAGER"] = {}
end
self.Data = C.Global["PLAYER_MANAGER"]
+ if not self.Data.VERSION or self.Data.VERSION < self.VarVersion then
+ if type(self.Data.PLAYERS) == "table" and not self.Data.VERSION then
+ wipe(self.Data.PLAYERS)
+ end
+ self.Data.VERSION = self.VarVersion
+ end
if type(self.Data.PLAYERS) ~= "table" then
self.Data.PLAYERS = {}
end
+ if type(self.Data.PLAYERS[GetRealmName()]) ~= "table" then
+ self.Data.PLAYERS[GetRealmName()] = {}
+ end
if type(self.Data.LIST_MODE) ~= "number" then
self.Data.LIST_MODE = MODE_BLACKLIST
end
@@ -193,7 +203,7 @@ function PM:LoadSavedVars()
self.Access.Groups[k].Allow = v.Allow
self.Access.Groups[k].Deny = v.Deny
end
- Players = self.Data.PLAYERS
+ Players = self.Data.PLAYERS[GetRealmName()]
List = self.Data.LIST
end
diff --git a/locales/enUS.lua b/locales/enUS.lua
index 120a83e..7d6d904 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -24,6 +24,8 @@ local L = {
LOCALE_NOT_LOADED = "The specified locale has not been loaded.",
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 --
diff --git a/locales/svSE.lua b/locales/svSE.lua
index 77529fd..3a1c174 100644
--- a/locales/svSE.lua
+++ b/locales/svSE.lua
@@ -17,8 +17,6 @@
* along with Command. If not, see <http://www.gnu.org/licenses/>.
--]]
-local LM = Command.LocaleManager
-
local L = {
-------------------
-- LocaleManager --
@@ -26,6 +24,8 @@ local L = {
LOCALE_NOT_LOADED = "Det specifierade språket är inte initialiserat.",
LOCALE_UPDATE = "Nytt språk inställt till: %s",
+ LOCALE_PI_ACTIVE = "Språkinställningar per-användare är nu aktivt.",
+ LOCALE_PI_INACTIVE = "Språkinställningar per-användare är nu inaktivt.",
-------------
-- General --
@@ -445,4 +445,4 @@ local L = {
RM_ANNOUNCE_WINNER = "%s with a roll of %d."
}
-LM:Register("svSE", L)
+Command.LocaleManager:Register("svSE", L)