summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-07 18:28:37 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-07 18:28:37 +0200
commit9790a6817cb4f1b4821de9af2630558cb5df882f (patch)
treeed9fd86bef0a74f0fcdc9b9bed12bb49c274b146 /MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua
parentProtectionAreas: Newly added areas are stored in the DB (diff)
downloadcuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar
cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.gz
cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.bz2
cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.lz
cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.xz
cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.zst
cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.zip
Diffstat (limited to 'MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua')
-rw-r--r--MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua36
1 files changed, 33 insertions, 3 deletions
diff --git a/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua b/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua
index 603b7a87f..744ea7e9c 100644
--- a/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua
+++ b/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua
@@ -1,6 +1,6 @@
-- ProtectionAreas.lua
--- Defines the main plugin entrypoint
+-- Defines the main plugin entrypoint, as well as some utility functions
@@ -26,8 +26,38 @@ function Initialize(a_Plugin)
InitializeHooks(a_Plugin);
InitializeCommandHandlers();
- -- TODO: We might be reloading, so there may be players already present in the server
- -- Reload areas for all present players
+ -- We might be reloading, so there may be players already present in the server; reload all of them
+ local function ReloadPlayers(a_World)
+ ReloadAllPlayersInWorld(a_World:GetName());
+ end
+ cRoot:Get():ForEachWorld(ReloadPlayers);
return true;
end
+
+
+
+
+
+--- Loads a cPlayerAreas object from the DB for the player, and assigns it to the player map
+function LoadPlayerAreas(a_Player)
+ local PlayerID = a_Player:GetUniqueID();
+ local PlayerX = math.floor(a_Player:GetPosX());
+ local PlayerZ = math.floor(a_Player:GetPosZ());
+ local WorldName = a_Player:GetWorld():GetName();
+ g_PlayerAreas[PlayerID] = g_Storage:LoadPlayerAreas(a_Player:GetName(), PlayerX, PlayerZ, WorldName);
+end
+
+
+
+
+
+function ReloadAllPlayersInWorld(a_WorldName)
+ local World = cRoot:Get():GetWorld(a_WorldName);
+ World:ForEachPlayer(LoadPlayerAreas);
+end
+
+
+
+
+