From 9a25f76697c2cf9c48e0ae7ff63b574436e45478 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 26 May 2013 19:21:24 +0000 Subject: ProtectionAreas: missed 2 files git-svn-id: http://mc-server.googlecode.com/svn/trunk@1517 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/ProtectionAreas/CommandState.lua | 89 +++++++++++++++++++++++ MCServer/Plugins/ProtectionAreas/Config.lua | 33 +++++++++ 2 files changed, 122 insertions(+) create mode 100644 MCServer/Plugins/ProtectionAreas/CommandState.lua create mode 100644 MCServer/Plugins/ProtectionAreas/Config.lua (limited to 'MCServer/Plugins/ProtectionAreas') diff --git a/MCServer/Plugins/ProtectionAreas/CommandState.lua b/MCServer/Plugins/ProtectionAreas/CommandState.lua new file mode 100644 index 000000000..f9d0e28db --- /dev/null +++ b/MCServer/Plugins/ProtectionAreas/CommandState.lua @@ -0,0 +1,89 @@ + +-- CommandState.lua + +-- Implements the cCommandState class representing a command state for each VIP player + +--[[ +The command state holds internal info, such as the coords they selected using the wand +The command state needs to be held in a per-entity manner, so that we can support multiple logins +from the same account (just for the fun of it) +The OOP class implementation follows the PiL 16.1 + +Also, a global table g_CommandStates is the map of PlayerEntityID -> cCommandState +--]] + + + + + +cCommandState = { + -- Default coords + m_Coords1 = {x = 0, y = 0, z = 0}; + m_Coords2 = {x = 0, y = 0, z = 0}; +}; + +g_CommandStates = {}; + + + + + +function cCommandState:new(obj) + obj = obj or {}; + setmetatable(obj, self); + self.__index = self; + return obj; +end + + + + + +--- Returns the current coord pair as a cCuboid object +function cCommandState.GetCurrentCuboid() + local res = cCuboid( + self.Coords1.x, self.Coords1.y, self.Coords1.z, + self.Coords2.x, self.Coords2.y, self.Coords2.z + ); + res:Sort(); + return res; +end + + + + +--- Sets the first set of coords (upon rclk with a wand) +function cCommandState:SetCoords1(a_BlockX, a_BlockY, a_BlockZ) + self.m_Coords1.x = a_BlockX; + self.m_Coords1.y = a_BlockY; + self.m_Coords1.z = a_BlockZ; +end + + + + + +--- Sets the second set of coords (upon lclk with a wand) +function cCommandState:SetCoords2(a_BlockX, a_BlockY, a_BlockZ) + self.m_Coords2.x = a_BlockX; + self.m_Coords2.y = a_BlockY; + self.m_Coords2.z = a_BlockZ; +end + + + + + +--- Returns the cCommandState for the specified player; creates one if not existant +function GetCommandStateForPlayer(a_Player) + local res = g_CommandStates[a_Player:GetUniqueID()]; + if (res == nil) then + res = cCommandState:new(); + g_CommandStates[a_Player:GetUniqueID()] = res; + end + return res; +end; + + + + diff --git a/MCServer/Plugins/ProtectionAreas/Config.lua b/MCServer/Plugins/ProtectionAreas/Config.lua new file mode 100644 index 000000000..c9b131f5c --- /dev/null +++ b/MCServer/Plugins/ProtectionAreas/Config.lua @@ -0,0 +1,33 @@ + +-- Config.lua + +-- Implements the cConfig class that holds the general plugin configuration + + + + + +cConfig = { + m_Wand = cItem(E_ITEM_STICK, 1, 1); -- TODO: Make this configurable by loading it from an INI file +}; + + + + + +--- Returns true if a_Item is the wand tool item +function cConfig:IsWand(a_Item) + return ( + (a_Item.m_ItemType == self.m_Wand.m_ItemType) and + (a_Item.m_ItemDamage == self.m_Wand.m_ItemDamage) + ); +end + + + + + +--- Returns the wand tool item as a cItem object +function cConfig:GetWandItem() + return self.m_Wand; +end \ No newline at end of file -- cgit v1.2.3