From 08624348f4e84fdc9909eb5de4478443bad8cc8d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 23 Apr 2015 19:41:01 +0200 Subject: Implemented cPluginManager:DoWithPlugin(), fixed ForEachPlugin(). Both functions are exported as static. --- MCServer/Plugins/Debuggers/Debuggers.lua | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 01a5de81e..6580e9dbc 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -62,6 +62,7 @@ function Initialize(a_Plugin) -- TestRankMgr() TestFileExt() TestFileLastMod() + TestPluginInterface() local LastSelfMod = cFile:GetLastModificationTime(a_Plugin:GetLocalFolder() .. "/Debuggers.lua") LOG("Debuggers.lua last modified on " .. os.date("%Y-%m-%dT%H:%M:%S", LastSelfMod)) @@ -75,6 +76,18 @@ function Initialize(a_Plugin) ) --]] + -- Test the crash in #1889: + cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, + function (a_CBPlayer, a_CBEntity) + a_CBPlayer:GetWorld():DoWithEntityByID( -- This will crash the server in #1889 + a_CBEntity:GetUniqueID(), + function(Entity) + LOG("RightClicking an entity, crash #1889 fixed") + end + ) + end + ) + return true end; @@ -82,6 +95,27 @@ end; +function TestPluginInterface() + cPluginManager:DoWithPlugin("Core", + function (a_CBPlugin) + if (a_CBPlugin:GetStatus() == cPluginManager.psLoaded) then + LOG("Core plugin was found, version " .. a_CBPlugin:GetVersion()) + else + LOG("Core plugin is not loaded") + end + end + ) + + cPluginManager:ForEachPlugin( + function (a_CBPlugin) + LOG("Plugin in " .. a_CBPlugin:GetFolderName() .. " has an API name of " .. a_CBPlugin:GetName() .. " and status " .. a_CBPlugin:GetStatus()) + end + ) +end + + + + function TestFileExt() assert(cFile:ChangeFileExt("fileless_dir/", "new") == "fileless_dir/") assert(cFile:ChangeFileExt("fileless_dir/", ".new") == "fileless_dir/") -- cgit v1.2.3