diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-08 18:47:03 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-08 18:47:03 +0200 |
commit | 01260be5721003a95664c31885fdecaed873024a (patch) | |
tree | 5e074b2460512a45685757b3e07fa5c0b86444e7 /MCServer/Plugins/ProtectionAreas/CommandHandlers.lua | |
parent | ProtectionAreas: ProtList works directly above the DB, displays areas' IDs and creators. ProtAdd and ProtAddCoords commands show the ID of the new area (diff) | |
download | cuberite-01260be5721003a95664c31885fdecaed873024a.tar cuberite-01260be5721003a95664c31885fdecaed873024a.tar.gz cuberite-01260be5721003a95664c31885fdecaed873024a.tar.bz2 cuberite-01260be5721003a95664c31885fdecaed873024a.tar.lz cuberite-01260be5721003a95664c31885fdecaed873024a.tar.xz cuberite-01260be5721003a95664c31885fdecaed873024a.tar.zst cuberite-01260be5721003a95664c31885fdecaed873024a.zip |
Diffstat (limited to 'MCServer/Plugins/ProtectionAreas/CommandHandlers.lua')
-rw-r--r-- | MCServer/Plugins/ProtectionAreas/CommandHandlers.lua | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua b/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua index eec1f8042..4ce0b2f35 100644 --- a/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua +++ b/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua @@ -219,6 +219,48 @@ end +--- Lists all allowed users for a particular area
+function HandleListUsers(a_Split, a_Player)
+ -- Command syntax: ProtListUsers AreaID
+ if (#a_Split ~= 2) then
+ a_Player:SendMessage("Expected AreaID as a parameter");
+ end
+
+ -- Get the general info about the area
+ local AreaID = a_Split[2];
+ local WorldName = a_Player:GetWorld():GetName();
+ local MinX, MinZ, MaxX, MaxZ, CreatorName = g_Storage:GetArea(AreaID, WorldName);
+ if (MinX == nil) then
+ a_Player:SendMessage("No such area: " .. AreaID);
+ return true;
+ end
+
+ -- Send the header
+ a_Player:SendMessage(
+ "Area ID " .. AreaID .. ": {" ..
+ MinX .. ", " .. MinZ .. "} - {" ..
+ MaxX .. ", " .. MaxZ .. "} " ..
+ "Created by " .. CreatorName .. "; allowed users:"
+ );
+
+ -- List and count the allowed users
+ local NumUsers = 0;
+ g_Storage:ForEachUserInArea(AreaID, WorldName,
+ function(UserName)
+ a_Player:SendMessage(" " .. UserName);
+ NumUsers = NumUsers + 1;
+ end
+ );
+
+ -- Send the footer
+ a_Player:SendMessage("End of area " .. AreaID .. " user list, total " .. NumUsers .. " users");
+
+ return true;
+end
+
+
+
+
function HandleRemoveUser(a_Split, a_Player)
-- Command syntax: ProtRemUser AreaID UserName
@@ -235,7 +277,12 @@ function HandleRemoveUser(a_Split, a_Player) end
-- Remove the user from the DB
- g_Storage:RemoveUser(AreaID, a_Split[3], a_Player:GetWorld():GetName());
+ local UserName = a_Split[3];
+ g_Storage:RemoveUser(AreaID, UserName, a_Player:GetWorld():GetName());
+
+ -- Send confirmation
+ a_Player:SendMessage("Removed " .. UserName .. " from area " .. AreaID);
+
return true;
end
|