summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-07-29 13:13:03 +0200
committerAlexander Harkness <bearbin@gmail.com>2013-07-29 13:13:03 +0200
commit53e22b11857fed62e2313d6d84d90f88ed412ffb (patch)
treec61e56725da7dff0154d566722651e2c39c9d6c6 /MCServer/Plugins/ProtectionAreas/HookHandlers.lua
parentWebAdmin: Removed the duplicate memory usage querying (diff)
downloadcuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.gz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.bz2
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.lz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.xz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.zst
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.zip
Diffstat (limited to 'MCServer/Plugins/ProtectionAreas/HookHandlers.lua')
-rw-r--r--MCServer/Plugins/ProtectionAreas/HookHandlers.lua278
1 files changed, 139 insertions, 139 deletions
diff --git a/MCServer/Plugins/ProtectionAreas/HookHandlers.lua b/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
index 18fd4fa03..ded64d298 100644
--- a/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
+++ b/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
@@ -1,139 +1,139 @@
-
--- HookHandlers.lua
--- Implements the handlers for individual hooks
-
-
-
-
-
---- Registers all the hooks that the plugin needs to know about
-function InitializeHooks(a_Plugin)
- local PlgMgr = cRoot:Get():GetPluginManager();
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_DISCONNECT);
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_LEFT_CLICK);
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_MOVING);
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_RIGHT_CLICK);
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_SPAWNED);
-end
-
-
-
-
-
---- Called by MCS when a player's connectino is lost - either they disconnected or timed out
-function OnDisconnect(a_Player, a_Reason)
- -- Remove the player's cProtectionArea object
- 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;
-
- return false;
-end;
-
-
-
-
-
---- Called by MCS whenever a player enters a world (is spawned)
-function OnPlayerSpawned(a_Player)
- -- Create a new cPlayerAreas object for this player
- if (g_PlayerAreas[a_Player:GetUniqueID()] == nil) then
- LoadPlayerAreas(a_Player);
- end;
-
- return false;
-end
-
-
-
-
-
---- Called by MCS whenever a player is moving (at most once every tick)
-function OnPlayerMoving(a_Player)
- local PlayerID = a_Player:GetUniqueID();
-
- -- If for some reason we don't have a cPlayerAreas object for this player, load it up
- local PlayerAreas = g_PlayerAreas[PlayerID];
- if (PlayerAreas == nil) then
- LoadPlayerAreas(a_Player);
- return false;
- end;
-
- -- If the player is outside their areas' safe space, reload
- if (not(PlayerAreas:IsInSafe(a_Player:GetPosX(), a_Player:GetPosZ()))) then
- LoadPlayerAreas(a_Player);
- end
- return false;
-end
-
-
-
-
-
---- Called by MCS when a player left-clicks
-function OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status)
- -- If the player has lclked with the wand; regardless of their permissions, let's set the coords:
- if (cConfig:IsWand(a_Player:GetEquippedItem())) then
- -- BlockFace < 0 means "use item", for which the coords are not given by the client
- if (a_BlockFace < 0) then
- return true;
- end
-
- -- Convert the clicked coords into the block space
- a_BlockX, a_BlockY, a_BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
- -- Set the coords in the CommandState
- GetCommandStateForPlayer(a_Player):SetCoords1(a_BlockX, a_BlockZ);
- a_Player:SendMessage(string.format(g_Msgs.Coords1Set, a_BlockX, a_BlockZ));
- return true;
- end;
-
- -- 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_BlockZ)) then
- a_Player:SendMessage(g_Msgs.NotAllowedToDig);
- return true;
- end
-
- -- Allow interaction
- return false;
-end
-
-
-
-
-
---- Called by MCS when a player right-clicks
-function OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_Status)
-
- -- BlockFace < 0 means "use item", for which the coords are not given by the client
- if (a_BlockFace < 0) then
- return true;
- end
-
- -- Convert the clicked coords into the block space
- a_BlockX, a_BlockY, a_BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
- -- If the player has rclked with the wand; regardless of their permissions, let's set the coords
- if (cConfig:IsWand(a_Player:GetEquippedItem())) then
- -- Set the coords in the CommandState
- GetCommandStateForPlayer(a_Player):SetCoords2(a_BlockX, a_BlockZ);
- a_Player:SendMessage(string.format(g_Msgs.Coords2Set, a_BlockX, a_BlockZ));
- return true;
- end;
-
- -- 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_BlockZ)) then
- a_Player:SendMessage(g_Msgs.NotAllowedToBuild);
- return true;
- end
-
- -- Allow interaction
- return false;
-end
-
-
-
-
+
+-- HookHandlers.lua
+-- Implements the handlers for individual hooks
+
+
+
+
+
+--- Registers all the hooks that the plugin needs to know about
+function InitializeHooks(a_Plugin)
+ local PlgMgr = cRoot:Get():GetPluginManager();
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_DISCONNECT);
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_LEFT_CLICK);
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_MOVING);
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_RIGHT_CLICK);
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_SPAWNED);
+end
+
+
+
+
+
+--- Called by MCS when a player's connectino is lost - either they disconnected or timed out
+function OnDisconnect(a_Player, a_Reason)
+ -- Remove the player's cProtectionArea object
+ 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;
+
+ return false;
+end;
+
+
+
+
+
+--- Called by MCS whenever a player enters a world (is spawned)
+function OnPlayerSpawned(a_Player)
+ -- Create a new cPlayerAreas object for this player
+ if (g_PlayerAreas[a_Player:GetUniqueID()] == nil) then
+ LoadPlayerAreas(a_Player);
+ end;
+
+ return false;
+end
+
+
+
+
+
+--- Called by MCS whenever a player is moving (at most once every tick)
+function OnPlayerMoving(a_Player)
+ local PlayerID = a_Player:GetUniqueID();
+
+ -- If for some reason we don't have a cPlayerAreas object for this player, load it up
+ local PlayerAreas = g_PlayerAreas[PlayerID];
+ if (PlayerAreas == nil) then
+ LoadPlayerAreas(a_Player);
+ return false;
+ end;
+
+ -- If the player is outside their areas' safe space, reload
+ if (not(PlayerAreas:IsInSafe(a_Player:GetPosX(), a_Player:GetPosZ()))) then
+ LoadPlayerAreas(a_Player);
+ end
+ return false;
+end
+
+
+
+
+
+--- Called by MCS when a player left-clicks
+function OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status)
+ -- If the player has lclked with the wand; regardless of their permissions, let's set the coords:
+ if (cConfig:IsWand(a_Player:GetEquippedItem())) then
+ -- BlockFace < 0 means "use item", for which the coords are not given by the client
+ if (a_BlockFace < 0) then
+ return true;
+ end
+
+ -- Convert the clicked coords into the block space
+ a_BlockX, a_BlockY, a_BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+
+ -- Set the coords in the CommandState
+ GetCommandStateForPlayer(a_Player):SetCoords1(a_BlockX, a_BlockZ);
+ a_Player:SendMessage(string.format(g_Msgs.Coords1Set, a_BlockX, a_BlockZ));
+ return true;
+ end;
+
+ -- 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_BlockZ)) then
+ a_Player:SendMessage(g_Msgs.NotAllowedToDig);
+ return true;
+ end
+
+ -- Allow interaction
+ return false;
+end
+
+
+
+
+
+--- Called by MCS when a player right-clicks
+function OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_Status)
+
+ -- BlockFace < 0 means "use item", for which the coords are not given by the client
+ if (a_BlockFace < 0) then
+ return true;
+ end
+
+ -- Convert the clicked coords into the block space
+ a_BlockX, a_BlockY, a_BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+
+ -- If the player has rclked with the wand; regardless of their permissions, let's set the coords
+ if (cConfig:IsWand(a_Player:GetEquippedItem())) then
+ -- Set the coords in the CommandState
+ GetCommandStateForPlayer(a_Player):SetCoords2(a_BlockX, a_BlockZ);
+ a_Player:SendMessage(string.format(g_Msgs.Coords2Set, a_BlockX, a_BlockZ));
+ return true;
+ end;
+
+ -- 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_BlockZ)) then
+ a_Player:SendMessage(g_Msgs.NotAllowedToBuild);
+ return true;
+ end
+
+ -- Allow interaction
+ return false;
+end
+
+
+
+