summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels Breuker <niels.breuker@hotmail.nl>2023-03-12 21:14:29 +0100
committerNiels Breuker <niels.breuker@hotmail.nl>2023-03-12 21:14:29 +0100
commit79d40b816e95af51a7216739dafcff003728fb47 (patch)
tree31f71c38f4afa7a3e86e1e4828dd739d49f692fc
parentRenamed VSCode -> LLS (diff)
downloadcuberite-79d40b816e95af51a7216739dafcff003728fb47.tar
cuberite-79d40b816e95af51a7216739dafcff003728fb47.tar.gz
cuberite-79d40b816e95af51a7216739dafcff003728fb47.tar.bz2
cuberite-79d40b816e95af51a7216739dafcff003728fb47.tar.lz
cuberite-79d40b816e95af51a7216739dafcff003728fb47.tar.xz
cuberite-79d40b816e95af51a7216739dafcff003728fb47.tar.zst
cuberite-79d40b816e95af51a7216739dafcff003728fb47.zip
-rw-r--r--Server/Plugins/APIDump/_preload.lua22
-rw-r--r--Server/Plugins/APIDump/main_APIDump.lua2
2 files changed, 23 insertions, 1 deletions
diff --git a/Server/Plugins/APIDump/_preload.lua b/Server/Plugins/APIDump/_preload.lua
new file mode 100644
index 000000000..becc691c4
--- /dev/null
+++ b/Server/Plugins/APIDump/_preload.lua
@@ -0,0 +1,22 @@
+
+-- _preload.lua
+
+-- First thing executed when the plugin loads. Replaces the global environment (_G) with an empty table
+-- with __index set to the old environment. This way any function or variable that is created globally by the plugin
+-- won't be reported as new or undocumented.
+
+
+
+
+
+local newEnv, oldEnv = {}, _G
+local setmetatable = setmetatable
+for k, v in pairs(_G) do
+ newEnv[k] = v;
+ oldEnv[k] = nil;
+end
+_G = setmetatable(oldEnv, {__index = newEnv});
+
+
+
+
diff --git a/Server/Plugins/APIDump/main_APIDump.lua b/Server/Plugins/APIDump/main_APIDump.lua
index 7396f98d2..5d6f5255f 100644
--- a/Server/Plugins/APIDump/main_APIDump.lua
+++ b/Server/Plugins/APIDump/main_APIDump.lua
@@ -136,7 +136,7 @@ local function CreateAPITables()
return res;
end
- for i, v in pairs(_G) do
+ for i, v in pairs(getmetatable(_G).__index) do
if (
(v ~= _G) and -- don't want the global namespace
(v ~= _G.packages) and -- don't want any packages