From 6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 6 Jun 2013 20:42:42 +0000 Subject: ProtectionAreas: Newly added areas are stored in the DB git-svn-id: http://mc-server.googlecode.com/svn/trunk@1560 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- .../Plugins/ProtectionAreas/CommandHandlers.lua | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins/ProtectionAreas/CommandHandlers.lua') diff --git a/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua b/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua index 21049a517..cc2e18b21 100644 --- a/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua +++ b/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua @@ -25,7 +25,38 @@ function HandleAddArea(a_Split, a_Player) return true; end - -- TODO: Add the area to the storage and reload all currently logged in players + -- Get the cuboid that the player had selected + local CmdState = GetCommandStateForPlayer(a_Player); + if (CmdState == nil) then + a_Player:SendMessage("Cannot add area, internal plugin error (CmdState == nil)"); + return true; + end + local Cuboid = CmdState:GetCurrentCuboid(); + if (Cuboid == nil) then + a_Player:SendMessage("Cannot add area, internal plugin error (Cuboid == nil)"); + return true; + end + + -- If the cuboid hasn't been assigned, give the player an error message and bail out + if ( + (Cuboid.p1.x == 0) and (Cuboid.p1.y == 0) and (Cuboid.p1.z == 0) and + (Cuboid.p1.x == 0) and (Cuboid.p1.y == 0) and (Cuboid.p1.z == 0) + ) then + a_Player:SendMessage("Cannot add area, no area has been selected. Use a ProtWand lclk / rclk to select area first"); + return true; + end + + -- Put all allowed players into a table: + AllowedNames = {}; + for i = 2, #a_Split do + table.insert(AllowedNames, a_Split[i]); + end + + -- Add the area to the storage + g_Storage:AddArea(Cuboid, a_Player:GetName(), AllowedNames); + a_Player:SendMessage("Area added"); + + -- TODO: Reload all currently logged in players return true; end -- cgit v1.2.3