summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-08 17:06:24 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-08 17:06:24 +0200
commit2b232f547197ff061c395bf24030f489a58d9e0c (patch)
tree7b49d0c74d7fd2bfa0cf9c392ee71488a75cf520 /MCServer/Plugins/ProtectionAreas/CommandHandlers.lua
parentProtectionAreas: The areas are now read from the DB (once) (diff)
downloadcuberite-2b232f547197ff061c395bf24030f489a58d9e0c.tar
cuberite-2b232f547197ff061c395bf24030f489a58d9e0c.tar.gz
cuberite-2b232f547197ff061c395bf24030f489a58d9e0c.tar.bz2
cuberite-2b232f547197ff061c395bf24030f489a58d9e0c.tar.lz
cuberite-2b232f547197ff061c395bf24030f489a58d9e0c.tar.xz
cuberite-2b232f547197ff061c395bf24030f489a58d9e0c.tar.zst
cuberite-2b232f547197ff061c395bf24030f489a58d9e0c.zip
Diffstat (limited to 'MCServer/Plugins/ProtectionAreas/CommandHandlers.lua')
-rw-r--r--MCServer/Plugins/ProtectionAreas/CommandHandlers.lua30
1 files changed, 13 insertions, 17 deletions
diff --git a/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua b/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua
index 18ab29f68..eec1f8042 100644
--- a/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua
+++ b/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua
@@ -44,8 +44,8 @@ function HandleAddArea(a_Split, a_Player)
end
-- Add the area to the storage
- g_Storage:AddArea(Cuboid, a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames);
- a_Player:SendMessage("Area added");
+ local AreaID = g_Storage:AddArea(Cuboid, a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames);
+ a_Player:SendMessage("Area added, ID " .. AreaID);
-- Reload all currently logged in players
ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
@@ -81,8 +81,8 @@ function HandleAddAreaCoords(a_Split, a_Player)
end
-- Add the area to the storage
- g_Storage:AddArea(Cuboid, a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames);
- a_Player:SendMessage("Area added");
+ local AreaID = g_Storage:AddArea(Cuboid, a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames);
+ a_Player:SendMessage("Area added, ID = " .. AreaID);
-- Reload all currently logged in players
ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
@@ -195,24 +195,20 @@ function HandleListAreas(a_Split, a_Player)
a_Player:SendMessage("Listing protection areas intersecting block column {" .. x .. ", " .. z .. "}:");
-- List areas intersecting the coords
- local Areas = g_PlayerAreas[a_Player:GetUniqueID()]
- Areas:ForEachArea(
- function(a_Cuboid, a_IsAllowed)
- if (not(a_Cuboid:IsInside(x, 1, z))) then
- -- This cuboid doesn't intersect the column
- return;
- end
- -- Column intersected, send to the player
- local Coords = "{" ..
- a_Cuboid.p1.x .. ", " .. a_Cuboid.p1.z .. "} - {" ..
- a_Cuboid.p2.x .. ", " .. a_Cuboid.p2.z .. "} ";
+ local PlayerName = a_Player:GetName();
+ local WorldName = a_Player:GetWorld():GetName();
+ g_Storage:ForEachArea(x, z, WorldName,
+ function(AreaID, MinX, MinZ, MaxX, MaxZ, CreatorName)
+ local Coords = AreaID .. ": {" ..
+ MinX .. ", " .. MinZ .. "} - {" ..
+ MaxX .. ", " .. MaxZ .. "} ";
local Allowance;
- if (a_IsAllowed) then
+ if (g_Storage:IsAreaAllowed(AreaID, PlayerName, WorldName)) then
Allowance = "Allowed";
else
Allowance = "NOT allowed";
end
- a_Player:SendMessage(" " .. Coords .. Allowance);
+ a_Player:SendMessage(" " .. Coords .. Allowance .. ", Created by " .. CreatorName);
end
);