diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-06 22:42:42 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-06 22:42:42 +0200 |
commit | 6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9 (patch) | |
tree | 0012765f0fc3d86719b956e57b79db5aa33da5b4 /MCServer/Plugins/ProtectionAreas/CommandHandlers.lua | |
parent | ProtectionAreas: Added cStorage initialization (diff) | |
download | cuberite-6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9.tar cuberite-6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9.tar.gz cuberite-6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9.tar.bz2 cuberite-6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9.tar.lz cuberite-6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9.tar.xz cuberite-6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9.tar.zst cuberite-6cb76856ff95bdc56d15b9dee6dc80dfbc755fd9.zip |
Diffstat (limited to 'MCServer/Plugins/ProtectionAreas/CommandHandlers.lua')
-rw-r--r-- | MCServer/Plugins/ProtectionAreas/CommandHandlers.lua | 33 |
1 files changed, 32 insertions, 1 deletions
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
|