From a982b9b5ace6baab7dda4d7d905907009919dfea Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 14 Mar 2014 16:07:22 +0100
Subject: APIDump: Trigger the dump manually.
Fixes #715. The dump can be triggerred by issuing an "api" console command, or in the webadmin.
---
MCServer/Plugins/APIDump/main_APIDump.lua | 90 ++++++++++++++++++++++---------
1 file changed, 64 insertions(+), 26 deletions(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua
index bd509dcb6..40b37f62c 100644
--- a/MCServer/Plugins/APIDump/main_APIDump.lua
+++ b/MCServer/Plugins/APIDump/main_APIDump.lua
@@ -9,22 +9,6 @@
-- Global variables:
g_Plugin = nil;
g_PluginFolder = "";
-g_TrackedPages = {}; -- List of tracked pages, to be checked later whether they exist. Each item is an array of referring pagenames.
-g_Stats = -- Statistics about the documentation
-{
- NumTotalClasses = 0,
- NumUndocumentedClasses = 0,
- NumTotalFunctions = 0,
- NumUndocumentedFunctions = 0,
- NumTotalConstants = 0,
- NumUndocumentedConstants = 0,
- NumTotalVariables = 0,
- NumUndocumentedVariables = 0,
- NumTotalHooks = 0,
- NumUndocumentedHooks = 0,
- NumTrackedLinks = 0,
- NumInvalidLinks = 0,
-}
@@ -33,15 +17,34 @@ g_Stats = -- Statistics about the documentation
function Initialize(Plugin)
g_Plugin = Plugin;
-
- Plugin:SetName("APIDump");
- Plugin:SetVersion(1);
+ g_PluginFolder = Plugin:GetLocalFolder();
LOG("Initialising " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
- g_PluginFolder = Plugin:GetLocalFolder();
+ cPluginManager:BindConsoleCommand("api", HandleCmdApi, "Dumps the Lua API docs into the API/ subfolder")
+ g_Plugin:AddWebTab("APIDump", HandleWebAdminDump)
+ -- TODO: Add a WebAdmin tab that has a Dump button
+ return true
+end
+
+
+
+
+
+function HandleCmdApi(a_Split)
+ DumpApi()
+end
+
+
+
+
+
+function DumpApi()
+ LOG("Dumping the API...")
-- Load the API descriptions from the Classes and Hooks subfolders:
+ -- This needs to be done each time the command is invoked because the export modifies the tables' contents
+ dofile(g_PluginFolder .. "/APIDesc.lua")
if (g_APIDesc.Classes == nil) then
g_APIDesc.Classes = {};
end
@@ -51,6 +54,24 @@ function Initialize(Plugin)
LoadAPIFiles("/Classes/", g_APIDesc.Classes);
LoadAPIFiles("/Hooks/", g_APIDesc.Hooks);
+ -- Reset the stats:
+ g_TrackedPages = {}; -- List of tracked pages, to be checked later whether they exist. Each item is an array of referring pagenames.
+ g_Stats = -- Statistics about the documentation
+ {
+ NumTotalClasses = 0,
+ NumUndocumentedClasses = 0,
+ NumTotalFunctions = 0,
+ NumUndocumentedFunctions = 0,
+ NumTotalConstants = 0,
+ NumUndocumentedConstants = 0,
+ NumTotalVariables = 0,
+ NumUndocumentedVariables = 0,
+ NumTotalHooks = 0,
+ NumUndocumentedHooks = 0,
+ NumTrackedLinks = 0,
+ NumInvalidLinks = 0,
+ }
+
-- dump all available API functions and objects:
-- DumpAPITxt();
@@ -58,7 +79,6 @@ function Initialize(Plugin)
DumpAPIHtml();
LOG("APIDump finished");
-
return true
end
@@ -67,6 +87,9 @@ end
function LoadAPIFiles(a_Folder, a_DstTable)
+ assert(type(a_Folder) == "string")
+ assert(type(a_DstTable) == "table")
+
local Folder = g_PluginFolder .. a_Folder;
for idx, fnam in ipairs(cFile:GetFolderContents(Folder)) do
local FileName = Folder .. fnam;
@@ -317,6 +340,11 @@ end
function DumpAPIHtml()
LOG("Dumping all available functions and constants to API subfolder...");
+ -- Create the output folder
+ if not(cFile:IsFolder("API")) then
+ cFile:CreateFolder("API");
+ end
+
LOG("Copying static files..");
cFile:CreateFolder("API/Static");
local localFolder = g_Plugin:GetLocalFolder();
@@ -366,11 +394,6 @@ function DumpAPIHtml()
ReadDescriptions(API);
ReadHooks(Hooks);
- -- Create the output folder
- if not(cFile:IsFolder("API")) then
- cFile:CreateFolder("API");
- end
-
-- Create a "class index" file, write each class as a link to that file,
-- then dump class contents into class-specific file
LOG("Writing HTML files...");
@@ -1428,3 +1451,18 @@ end
+
+function HandleWebAdminDump(a_Request)
+ if (a_Request.PostParams["Dump"] ~= nil) then
+ DumpApi()
+ end
+ return
+ [[
+ Pressing the button will generate the API dump on the server. Note that this can take some time.
+
+ ]]
+end
+
+
+
+
--
cgit v1.2.3
From dc1049da3cd8dbf77ba96caf75550711ca0fba86 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 14 Mar 2014 16:08:25 +0100
Subject: Ignoring all config and SQLite files in the output folder.
---
MCServer/.gitignore | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
(limited to 'MCServer')
diff --git a/MCServer/.gitignore b/MCServer/.gitignore
index 0fd04ef59..64f062ef7 100644
--- a/MCServer/.gitignore
+++ b/MCServer/.gitignore
@@ -19,10 +19,8 @@ schematics
*.pdb
memdump*
*.grab
-Galleries.cfg
-Galleries.example.cfg
-Galleries.sqlite
-ProtectionAreas.sqlite
+*.cfg
+*.sqlite
helgrind.log
valgrind.log
motd.txt
--
cgit v1.2.3
From 0442c41c872badfcc1a7a22c293161cc752623b8 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 15 Mar 2014 07:50:39 +0100
Subject: Added cCuboid:Assign(OtherCuboid) API function.
---
MCServer/Plugins/APIDump/Classes/Geometry.lua | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/Classes/Geometry.lua b/MCServer/Plugins/APIDump/Classes/Geometry.lua
index 6f95c4cbf..78cd94f0c 100644
--- a/MCServer/Plugins/APIDump/Classes/Geometry.lua
+++ b/MCServer/Plugins/APIDump/Classes/Geometry.lua
@@ -63,12 +63,16 @@ return
{
constructor =
{
- { Params = "OtheCuboid", Return = "cCuboid", Notes = "Creates a new Cuboid object as a copy of OtherCuboid" },
+ { Params = "OtherCuboid", Return = "cCuboid", Notes = "Creates a new Cuboid object as a copy of OtherCuboid" },
{ Params = "{{Vector3i|Point1}}, {{Vector3i|Point2}}", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." },
{ Params = "X, Y, Z", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified point as both its corners (the cuboid has a size of 1 in each direction)." },
{ Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." },
},
- Assign = { Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "", Notes = "Assigns all the coords stored in the cuboid. Sort-state is ignored." },
+ Assign =
+ {
+ { Params = "SrcCuboid", Return = "", Notes = "Copies all the coords from the src cuboid to this cuboid. Sort-state is ignored." },
+ { Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "", Notes = "Assigns all the coords to the specified values. Sort-state is ignored." },
+ },
ClampX = { Params = "MinX, MaxX", Return = "", Notes = "Clamps both X coords into the range provided. Sortedness-agnostic." },
ClampY = { Params = "MinY, MaxY", Return = "", Notes = "Clamps both Y coords into the range provided. Sortedness-agnostic." },
ClampZ = { Params = "MinZ, MaxZ", Return = "", Notes = "Clamps both Z coords into the range provided. Sortedness-agnostic." },
--
cgit v1.2.3
From 62ed305f0760039e645d305a56b41d0ec5080ee0 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 15 Mar 2014 07:51:33 +0100
Subject: APIDump: Fixed missing return statement.
---
MCServer/Plugins/APIDump/main_APIDump.lua | 1 +
1 file changed, 1 insertion(+)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua
index 40b37f62c..4ed692b52 100644
--- a/MCServer/Plugins/APIDump/main_APIDump.lua
+++ b/MCServer/Plugins/APIDump/main_APIDump.lua
@@ -33,6 +33,7 @@ end
function HandleCmdApi(a_Split)
DumpApi()
+ return true
end
--
cgit v1.2.3
From d364c7befce884cac2347459512376937d2b8e69 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 15 Mar 2014 08:23:06 +0100
Subject: APIDump: Documented a forgotten cCuboid constructor.
---
MCServer/Plugins/APIDump/Classes/Geometry.lua | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/APIDump/Classes/Geometry.lua b/MCServer/Plugins/APIDump/Classes/Geometry.lua
index 78cd94f0c..9887bfb89 100644
--- a/MCServer/Plugins/APIDump/Classes/Geometry.lua
+++ b/MCServer/Plugins/APIDump/Classes/Geometry.lua
@@ -53,7 +53,7 @@ return
{
Desc = [[
cCuboid offers some native support for integral-boundary cuboids. A cuboid internally consists of
- two {{Vector3i}}s. By default the cuboid doesn't make any assumptions about the defining points,
+ two {{Vector3i}}-s. By default the cuboid doesn't make any assumptions about the defining points,
but for most of the operations in the cCuboid class, the p1 member variable is expected to be the
minima and the p2 variable the maxima. The Sort() function guarantees this condition.
@@ -63,6 +63,7 @@ return
{
constructor =
{
+ { Params = "", Return = "cCuboid", Notes = "Creates a new Cuboid object with all-zero coords" },
{ Params = "OtherCuboid", Return = "cCuboid", Notes = "Creates a new Cuboid object as a copy of OtherCuboid" },
{ Params = "{{Vector3i|Point1}}, {{Vector3i|Point2}}", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." },
{ Params = "X, Y, Z", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified point as both its corners (the cuboid has a size of 1 in each direction)." },
--
cgit v1.2.3
From 4a5bea159f13b0f72ac16513a8f5b4b90e5b0ca8 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 15 Mar 2014 08:36:49 +0100
Subject: Debuggers: Added a test for WE selection API.
This tests mc-server/WorldEdit#34.
---
MCServer/Plugins/Debuggers/Debuggers.lua | 40 +++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
(limited to 'MCServer')
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index f99c48242..d2c9a2a49 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -56,7 +56,8 @@ function Initialize(Plugin)
PM:BindCommand("/sched", "debuggers", HandleSched, "- Schedules a simple countdown using cWorld:ScheduleTask()");
PM:BindCommand("/cs", "debuggers", HandleChunkStay, "- Tests the ChunkStay Lua integration for the specified chunk coords");
PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings")
- PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one");
+ PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one")
+ PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z")
Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers)
Plugin:AddWebTab("StressTest", HandleRequest_StressTest)
@@ -1298,6 +1299,43 @@ end
+function HandleWESel(a_Split, a_Player)
+ -- Check if the selection is a cuboid:
+ local IsCuboid = cPluginManager:CallPlugin("WorldEdit", "IsPlayerSelectionCuboid")
+ if (IsCuboid == nil) then
+ a_Player:SendMessage(cCompositeChat():SetMessageType(mtFailure):AddTextPart("Cannot adjust selection, WorldEdit is not loaded"))
+ return true
+ elseif (IsCuboid == false) then
+ a_Player:SendMessage(cCompositeChat():SetMessageType(mtFailure):AddTextPart("Cannot adjust selection, the selection is not a cuboid"))
+ return true
+ end
+
+ -- Get the selection:
+ local SelCuboid = cCuboid()
+ local IsSuccess = cPluginManager:CallPlugin("WorldEdit", "GetPlayerCuboidSelection", a_Player, SelCuboid)
+ if not(IsSuccess) then
+ a_Player:SendMessage(cCompositeChat():SetMessageType(mtFailure):AddTextPart("Cannot adjust selection, WorldEdit reported failure while getting current selection"))
+ return true
+ end
+
+ -- Adjust the selection:
+ local NumBlocks = tonumber(a_Split[2] or "1") or 1
+ SelCuboid:Expand(NumBlocks, NumBlocks, 0, 0, NumBlocks, NumBlocks)
+
+ -- Set the selection:
+ local IsSuccess = cPluginManager:CallPlugin("WorldEdit", "SetPlayerCuboidSelection", a_Player, SelCuboid)
+ if not(IsSuccess) then
+ a_Player:SendMessage(cCompositeChat():SetMessageType(mtFailure):AddTextPart("Cannot adjust selection, WorldEdit reported failure while setting new selection"))
+ return true
+ end
+ a_Player:SendMessage(cCompositeChat():SetMessageType(mtInformation):AddTextPart("Successfully adjusted the selection by " .. NumBlocks .. " block(s)"))
+ return true
+end
+
+
+
+
+
function OnPlayerJoined(a_Player)
-- Test composite chat chaining:
a_Player:SendMessage(cCompositeChat()
--
cgit v1.2.3