summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-04 23:05:33 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-04 23:05:33 +0200
commitf746d17424a071c15fd5b92bc521ce832ba15a07 (patch)
tree85fce40aa5d92dc03c360c916e277c5bf2f35ee6 /MCServer/Plugins/ProtectionAreas/HookHandlers.lua
parentAdded script to generate cloc statistics (diff)
downloadcuberite-f746d17424a071c15fd5b92bc521ce832ba15a07.tar
cuberite-f746d17424a071c15fd5b92bc521ce832ba15a07.tar.gz
cuberite-f746d17424a071c15fd5b92bc521ce832ba15a07.tar.bz2
cuberite-f746d17424a071c15fd5b92bc521ce832ba15a07.tar.lz
cuberite-f746d17424a071c15fd5b92bc521ce832ba15a07.tar.xz
cuberite-f746d17424a071c15fd5b92bc521ce832ba15a07.tar.zst
cuberite-f746d17424a071c15fd5b92bc521ce832ba15a07.zip
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/ProtectionAreas/HookHandlers.lua26
1 files changed, 19 insertions, 7 deletions
diff --git a/MCServer/Plugins/ProtectionAreas/HookHandlers.lua b/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
index 4f1e3755e..d0748a8a4 100644
--- a/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
+++ b/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
@@ -21,7 +21,7 @@ end
function OnDisconnect(a_Player, a_Reason)
-- Remove the player's cProtectionArea object
-- TODO: What if there are two players with the same name? need to check
- g_PlayerAreas[a_Player:GetName()] = nil;
+ g_PlayerAreas[a_Player:GetUniqueID()] = nil;
-- If the player is a VIP, they had a command state, remove that as well
g_CommandStates[a_Player:GetUniqueID()] = nil;
@@ -34,10 +34,12 @@ end;
function OnPlayerJoined(a_Player)
- -- Create a new cProtectionArea for this player
- g_PlayerAreas[a_Player:GetName()] = cPlayerAreas:new();
-
- -- TODO: Load the protection areas for this player
+ -- Create a new cPlayerAreas object for this player
+ local PlayerName = a_Player:GetName();
+ local PlayerID = a_Player:GetUniqueID();
+ if (g_PlayerAreas[PlayerID] == nil) then
+ g_PlayerAreas[PlayerID] = g_Storage:LoadPlayerAreas(PlayerName);
+ end;
return false;
end
@@ -63,8 +65,13 @@ function OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
return true;
end;
- -- TODO: Check the player areas to see whether to disable this action
+ -- Check the player areas to see whether to disable this action
+ local Areas = g_PlayerAreas[a_Player:GetUniqueID()];
+ if not(Areas:CanInteractWithBlock(a_BlockX, a_BlockY, a_BlockZ)) then
+ return true;
+ end
+ -- Allow interaction
return false;
end
@@ -89,8 +96,13 @@ function OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
return true;
end;
- -- TODO: Check the player areas to see whether to disable this action
+ -- Check the player areas to see whether to disable this action
+ local Areas = g_PlayerAreas[a_Player:GetUniqueID()];
+ if not(Areas:CanInteractWithBlock(a_BlockX, a_BlockY, a_BlockZ)) then
+ return true;
+ end
+ -- Allow interaction
return false;
end