summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/Debuggers/Debuggers.lua
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-02-15 16:27:40 +0100
committermadmaxoft <github@xoft.cz>2014-02-15 16:30:28 +0100
commit147b9ed69456bd38d7f9167ad0b3aa249e5ede45 (patch)
treee6079300329ffae19d65bffda68e214eb22aabd8 /MCServer/Plugins/Debuggers/Debuggers.lua
parentAdd more Sounds to Redstone Simulator (diff)
downloadcuberite-147b9ed69456bd38d7f9167ad0b3aa249e5ede45.tar
cuberite-147b9ed69456bd38d7f9167ad0b3aa249e5ede45.tar.gz
cuberite-147b9ed69456bd38d7f9167ad0b3aa249e5ede45.tar.bz2
cuberite-147b9ed69456bd38d7f9167ad0b3aa249e5ede45.tar.lz
cuberite-147b9ed69456bd38d7f9167ad0b3aa249e5ede45.tar.xz
cuberite-147b9ed69456bd38d7f9167ad0b3aa249e5ede45.tar.zst
cuberite-147b9ed69456bd38d7f9167ad0b3aa249e5ede45.zip
Diffstat (limited to 'MCServer/Plugins/Debuggers/Debuggers.lua')
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua89
1 files changed, 76 insertions, 13 deletions
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index 8345e2169..51b3a3a87 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -19,18 +19,18 @@ function Initialize(Plugin)
cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick2);
--]]
- cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USING_BLOCK, OnPlayerUsingBlock);
- cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USING_ITEM, OnPlayerUsingItem);
- cPluginManager:AddHook(cPluginManager.HOOK_TAKE_DAMAGE, OnTakeDamage);
- cPluginManager:AddHook(cPluginManager.HOOK_TICK, OnTick);
- cPluginManager:AddHook(cPluginManager.HOOK_CHAT, OnChat);
- cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity);
- cPluginManager:AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick);
- cPluginManager:AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated);
- cPluginManager:AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded);
- cPluginManager:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage);
-
- PM = cRoot:Get():GetPluginManager();
+ local PM = cPluginManager;
+ PM:AddHook(cPluginManager.HOOK_PLAYER_USING_BLOCK, OnPlayerUsingBlock);
+ PM:AddHook(cPluginManager.HOOK_PLAYER_USING_ITEM, OnPlayerUsingItem);
+ PM:AddHook(cPluginManager.HOOK_TAKE_DAMAGE, OnTakeDamage);
+ PM:AddHook(cPluginManager.HOOK_TICK, OnTick);
+ PM:AddHook(cPluginManager.HOOK_CHAT, OnChat);
+ PM:AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity);
+ PM:AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick);
+ PM:AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated);
+ PM:AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded);
+ PM:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage);
+
PM:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities");
PM:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "- Kills all the loaded entities");
PM:BindCommand("/wool", "debuggers", HandleWoolCmd, "- Sets all your armor to blue wool");
@@ -55,7 +55,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");
- Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers);
+ Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers)
+ Plugin:AddWebTab("StressTest", HandleRequest_StressTest)
-- Enable the following line for BlockArea / Generator interface testing:
-- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
@@ -1038,6 +1039,68 @@ end
+local g_Counter = 0
+local g_JavaScript =
+[[
+<script>
+function createXHR()
+{
+ var request = false;
+ try {
+ request = new ActiveXObject('Msxml2.XMLHTTP');
+ }
+ catch (err2)
+ {
+ try
+ {
+ request = new ActiveXObject('Microsoft.XMLHTTP');
+ }
+ catch (err3)
+ {
+ try
+ {
+ request = new XMLHttpRequest();
+ }
+ catch (err1)
+ {
+ request = false;
+ }
+ }
+ }
+ return request;
+}
+
+function RefreshCounter()
+{
+ var xhr = createXHR();
+ xhr.onreadystatechange = function()
+ {
+ if (xhr.readyState == 4)
+ {
+ document.getElementById("cnt").innerHTML = xhr.responseText;
+ }
+ };
+ xhr.open("POST", "/~webadmin/Debuggers/StressTest", true);
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ xhr.send("counter=true");
+}
+
+setInterval(RefreshCounter, 10)
+</script>
+]]
+
+function HandleRequest_StressTest(a_Request)
+ if (a_Request.PostParams["counter"]) then
+ g_Counter = g_Counter + 1
+ return tostring(g_Counter)
+ end
+ return g_JavaScript .. "<p>The counter below should be reloading as fast as possible</p><div id='cnt'>0</div>"
+end
+
+
+
+
+
function OnPluginMessage(a_Client, a_Channel, a_Message)
LOGINFO("Received a plugin message from client " .. a_Client:GetUsername() .. ": channel '" .. a_Channel .. "', message '" .. a_Message .. "'");