From 0cfa0c45610cbe5c7ae6a03034f81416699247c4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 12:23:01 +0200 Subject: APIDump: Improved error handling in API file loader. --- MCServer/Plugins/APIDump/main_APIDump.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua index 52199740b..a25bab9cf 100644 --- a/MCServer/Plugins/APIDump/main_APIDump.lua +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -27,10 +27,14 @@ local function LoadAPIFiles(a_Folder, a_DstTable) -- We only want .lua files from the folder: if (cFile:IsFile(FileName) and fnam:match(".*%.lua$")) then local TablesFn, Err = loadfile(FileName); - if (TablesFn == nil) then + if (type(TablesFn) ~= "function") then LOGWARNING("Cannot load API descriptions from " .. FileName .. ", Lua error '" .. Err .. "'."); else local Tables = TablesFn(); + if (type(Tables) ~= "table") then + LOGWARNING("Cannot load API descriptions from " .. FileName .. ", returned object is not a table (" .. type(Tables) .. ")."); + break + end for k, cls in pairs(Tables) do a_DstTable[k] = cls; end -- cgit v1.2.3 From 13452d3ab92c1cc12201caf60782fd7f7c4314f7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 12:23:22 +0200 Subject: APIDump: Updated the OnDisconnect hook docs. Ref.: #655. --- MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua b/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua index a3301a8c6..204cb63d2 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua @@ -2,23 +2,33 @@ return { HOOK_DISCONNECT = { - CalledWhen = "A player has explicitly disconnected.", + CalledWhen = [[ + A client has disconnected, either by explicitly sending the disconnect packet (in older protocols) or + their connection was terminated + ]], DefaultFnName = "OnDisconnect", -- also used as pagename Desc = [[ - This hook is called when a client is about to be disconnected from the server, for whatever reason. - -

Note that this hook will be removed after <1.7 protocol support is removed, as it was originally a hook for - the client sending the server a disconnect packet, which no longer happens.

+ This hook is called when a client has disconnected from the server, for whatever reason. It is also + called when the client sends the Disconnect packet (only in pre-1.7 protocols). This hook is not called + for server ping connections.

+

+ Note that the hook is called even for connections to players who failed to auth. In such a case there's + no {{cPlayer}} object associated with the client.

+

+ See also the {{OnHandshake|HOOK_HANDSHAKE}} hook which is called when the client connects (and presents + a handshake message, so that they are not just status-pinging). If you need to store a per-player + object, use the {{OnPlayerJoined|HOOK_PLAYER_JOINED}} and {{OnPlayerDestroyed|HOOK_PLAYER_DESTROYED}} + hooks instead, those are guaranteed to have the {{cPlayer}} object associated. ]], Params = { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has disconnected" }, + { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client who has disconnected" }, { Name = "Reason", Type = "string", Notes = "The reason that the client has sent in the disconnect packet" }, }, Returns = [[ If the function returns false or no value, MCServer calls other plugins' callbacks for this event. If the function returns true, no other plugins are called for this event. In either case, - the player is disconnected. + the client is disconnected. ]], }, -- HOOK_DISCONNECT } -- cgit v1.2.3 From 27a9fa31108aef4313a45f4c716f2f1551537236 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 May 2014 23:28:48 +0100 Subject: Updated Core --- MCServer/Plugins/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index 5c8557d4f..3790f78d3 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit 5c8557d4fdfa580c100510cde07a1a778ea2e244 +Subproject commit 3790f78d3f7503ff33a423b8e73e81a275562783 -- cgit v1.2.3 From 2194238ef0b376353e7260df5a964976d0b72c5f Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 26 May 2014 17:17:54 +0100 Subject: Update main.css --- MCServer/Plugins/APIDump/main.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.css b/MCServer/Plugins/APIDump/main.css index aa26bd186..0a779bfb8 100644 --- a/MCServer/Plugins/APIDump/main.css +++ b/MCServer/Plugins/APIDump/main.css @@ -39,7 +39,8 @@ pre body { - min-width: 800px; + min-width: 400px; + max-width: 900px; width: 95%; margin: 10px auto; background-color: white; -- cgit v1.2.3 From e06f786f1151e1934890a2555de080b1a6860ec4 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 27 May 2014 20:24:04 +0100 Subject: Stuff. --- MCServer/Plugins/APIDump/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.css b/MCServer/Plugins/APIDump/main.css index 0a779bfb8..8041e0d01 100644 --- a/MCServer/Plugins/APIDump/main.css +++ b/MCServer/Plugins/APIDump/main.css @@ -40,7 +40,7 @@ pre body { min-width: 400px; - max-width: 900px; + max-width: 1200px; width: 95%; margin: 10px auto; background-color: white; -- cgit v1.2.3 From fa78379f5a8a1eede69f36b225d684723b0bf3ae Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 2 Jun 2014 11:45:32 +0200 Subject: Updated OnProjectileHitBlock documentation. --- MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua index 1588d420c..67d670d0a 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua @@ -10,6 +10,11 @@ return Params = { { Name = "ProjectileEntity", Type = "{{cProjectileEntity}}", Notes = "The projectile that hit an entity." }, + { Name = "BlockX", Type = "number", Notes = "The X-coord where the projectile hit." }, + { Name = "BlockY", Type = "number", Notes = "The Y-coord where the projectile hit." }, + { Name = "BlockZ", Type = "number", Notes = "The Z-coord where the projectile hit." }, + { Name = "BlockFace", Type = "number", Notes = "The side of the block where the projectile hit." }, + { Name = "BlockHitPos", Type = "Vector3d", Notes = "The exact position where the projectile hit." }, Returns = [[ If the function returns false or no value, the next plugin's callback is called. If the function -- cgit v1.2.3 From 4c757de9ff58ddab07fa2a337a1359b707480288 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 2 Jun 2014 11:54:45 +0200 Subject: Added OnProjectileHitBlock example in Debuggers --- MCServer/Plugins/Debuggers/Debuggers.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 064d5d772..534426d25 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -29,7 +29,8 @@ function Initialize(Plugin) PM:AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); PM:AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded); PM:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage); - PM:AddHook(cPluginManager.HOOK_PLAYER_JOINED, OnPlayerJoined) + PM:AddHook(cPluginManager.HOOK_PLAYER_JOINED, OnPlayerJoined); + PM:AddHook(cPluginManager.HOOK_PROJECTILE_HIT_BLOCK, OnProjectileHitBlock); -- _X: Disabled so that the normal operation doesn't interfere with anything -- PM:AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); @@ -1379,3 +1380,14 @@ end + +function OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockHitPos) + local BlockX, BlockY, BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace) + local World = a_Projectile:GetWorld() + + World:SetBlock(BlockX, BlockY, BlockZ, E_BLOCK_FIRE, 0) +end + + + + -- cgit v1.2.3 From 8cf4e806ba53aea8161f4110e8c3c67d215539eb Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 2 Jun 2014 13:49:05 +0200 Subject: APIDump: Fixed crash --- MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua index 67d670d0a..72cf85821 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnProjectileHitBlock.lua @@ -14,7 +14,7 @@ return { Name = "BlockY", Type = "number", Notes = "The Y-coord where the projectile hit." }, { Name = "BlockZ", Type = "number", Notes = "The Z-coord where the projectile hit." }, { Name = "BlockFace", Type = "number", Notes = "The side of the block where the projectile hit." }, - { Name = "BlockHitPos", Type = "Vector3d", Notes = "The exact position where the projectile hit." + { Name = "BlockHitPos", Type = "Vector3d", Notes = "The exact position where the projectile hit." }, }, Returns = [[ If the function returns false or no value, the next plugin's callback is called. If the function -- cgit v1.2.3 From c5d1ca7dac284bdce84fe42cc0932a432587d553 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sun, 8 Jun 2014 20:54:41 +0100 Subject: Small change for easier understanding. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1423d64bc..40bfe79ac 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1969,7 +1969,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); BroadcastChatSuccess = { Params = "Message", Return = "", Notes = "Prepends Green [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For success messages." }, BroadcastChatWarning = { Params = "Message", Return = "", Notes = "Prepends Rose [WARN] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For concerning events, such as plugin reload etc." }, CreateAndInitializeWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Creates a new world and initializes it. If there is a world whith the same name it returns nil." }, - FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for the given player." }, + FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for all players with names partially (or fully) matching the name string provided." }, ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature:

function Callback({{cPlayer|cPlayer}})
" }, ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world. The callback function has the following signature:
function Callback({{cWorld|cWorld}})
" }, GetCraftingRecipes = { Params = "", Return = "{{cCraftingRecipe|cCraftingRecipe}}", Notes = "Returns the CraftingRecipes object" }, -- cgit v1.2.3 From bd25069c25574f96ebf02de7360131bfe3504f04 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 11 Jun 2014 13:21:57 +0100 Subject: Update APIDesc.lua --- MCServer/Plugins/APIDump/APIDesc.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 40bfe79ac..1f43a6172 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2294,10 +2294,13 @@ end IsGameModeCreative = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmCreative." }, IsGameModeSurvival = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmSurvival." }, IsPVPEnabled = { Params = "", Return = "bool", Notes = "Returns whether PVP is enabled in the world settings." }, - IsWeatherRain = { Params = "", Return = "bool", Notes = "Returns true if the current weather is rain." }, - IsWeatherStorm = { Params = "", Return = "bool", Notes = "Returns true if the current weather is a storm." }, + IsWeatherRain = { Params = "", Return = "bool", Notes = "Returns true if the current world is raining." }, + IsWeatherRainAt = { Params = "BlockX, BlockZ", Return = "bool", Notes = "Returns true if the specified location is raining (takes into account biomes)." }, + IsWeatherStorm = { Params = "", Return = "bool", Notes = "Returns true if the current world is stormy." }, + IsWeatherStormAt = { Params = "BlockX, BlockZ", Return = "bool", Notes = "Returns true if the specified location is stormy (takes into account biomes)." }, IsWeatherSunny = { Params = "", Return = "bool", Notes = "Returns true if the current weather is sunny." }, - IsWeatherWet = { Params = "", Return = "bool", Notes = "Returns true if the current weather has any precipitation (rain or storm)." }, + IsWeatherWet = { Params = "", Return = "bool", Notes = "Returns true if the current world has any precipitation (rain or storm)." }, + IsWeatherWetAt = { Params = "BlockX, BlockZ", Return = "bool", Notes = "Returns true if the specified location has any precipitation (rain or storm) (takes into account biomes)." }, QueueBlockForTick = { Params = "BlockX, BlockY, BlockZ, TicksToWait", Return = "", Notes = "Queues the specified block to be ticked after the specified number of gameticks." }, QueueSaveAllChunks = { Params = "", Return = "", Notes = "Queues all chunks to be saved in the world storage thread" }, QueueSetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta, TickDelay", Return = "", Notes = "Queues the block to be set to the specified blocktype and meta after the specified amount of game ticks. Uses SetBlock() for the actual setting, so simulators are woken up and block entities are handled correctly." }, -- cgit v1.2.3 From 97bfccfdc0088705a4546d7d6369f3801946c1ba Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 11 Jun 2014 14:34:47 +0200 Subject: APIDump: Documented cBlockArea:GetCoordRange(). --- MCServer/Plugins/APIDump/APIDesc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 40bfe79ac..800d1170e 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -114,6 +114,7 @@ g_APIDesc = GetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ", Return = "NIBBLETYPE", Notes = "Returns the skylight at the specified absolute coords" }, GetBlockType = { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified absolute coords" }, GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified absolute coords" }, + GetCoordRange = {Params = "", Return = "MaxX, MaxY, MaxZ", Notes = "Returns the maximum relative coords in all 3 axes. See also GetSize()." }, GetDataTypes = { Params = "", Return = "number", Notes = "Returns the mask of datatypes that the object is currently holding" }, GetOrigin = { Params = "", Return = "OriginX, OriginY, OriginZ", Notes = "Returns the origin coords of where the area was read from." }, GetOriginX = { Params = "", Return = "number", Notes = "Returns the origin x-coord" }, @@ -124,7 +125,7 @@ g_APIDesc = GetRelBlockSkyLight = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "NIBBLETYPE", Notes = "Returns the skylight at the specified relative coords" }, GetRelBlockType = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" }, GetRelBlockTypeMeta = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" }, - GetSize = { Params = "", Return = "SizeX, SizeY, SizeZ", Notes = "Returns the size of the area in all 3 axes." }, + GetSize = { Params = "", Return = "SizeX, SizeY, SizeZ", Notes = "Returns the size of the area in all 3 axes. See also GetCoordRange()." }, GetSizeX = { Params = "", Return = "number", Notes = "Returns the size of the held data in the x-axis" }, GetSizeY = { Params = "", Return = "number", Notes = "Returns the size of the held data in the y-axis" }, GetSizeZ = { Params = "", Return = "number", Notes = "Returns the size of the held data in the z-axis" }, -- cgit v1.2.3 From c335b8d77346541799b9c62e4fc78ef217cc4f63 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 11 Jun 2014 13:34:49 +0100 Subject: Update APIDesc.lua --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1f43a6172..8442f6d80 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2299,6 +2299,7 @@ end IsWeatherStorm = { Params = "", Return = "bool", Notes = "Returns true if the current world is stormy." }, IsWeatherStormAt = { Params = "BlockX, BlockZ", Return = "bool", Notes = "Returns true if the specified location is stormy (takes into account biomes)." }, IsWeatherSunny = { Params = "", Return = "bool", Notes = "Returns true if the current weather is sunny." }, + IsWeatherSunnyAt = { Params = "BlockX, BlockZ", Return = "bool", Notes = "Returns true if the current weather is sunny at the specified location (takes into account biomes)." }, IsWeatherWet = { Params = "", Return = "bool", Notes = "Returns true if the current world has any precipitation (rain or storm)." }, IsWeatherWetAt = { Params = "BlockX, BlockZ", Return = "bool", Notes = "Returns true if the specified location has any precipitation (rain or storm) (takes into account biomes)." }, QueueBlockForTick = { Params = "BlockX, BlockY, BlockZ, TicksToWait", Return = "", Notes = "Queues the specified block to be ticked after the specified number of gameticks." }, -- cgit v1.2.3 From 3e7384d9210b726a12ec6244aa0419474f08c6d3 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Thu, 12 Jun 2014 15:01:24 +0100 Subject: Fix typo in handy_functions.lua --- MCServer/Plugins/Handy/handy_functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Handy/handy_functions.lua b/MCServer/Plugins/Handy/handy_functions.lua index c142ffd08..af43f663a 100644 --- a/MCServer/Plugins/Handy/handy_functions.lua +++ b/MCServer/Plugins/Handy/handy_functions.lua @@ -6,7 +6,7 @@ function GetHandyVersion() return HANDY_VERSION end -- Checks if handy is in proper version -function CheckForRequiedVersion( inVersion ) +function CheckForRequiredVersion( inVersion ) if( inVersion > HANDY_VERSION ) then return false end return true end @@ -213,4 +213,4 @@ end function BoolToString( inValue ) if( inValue == true ) then return 1 end return 0 -end \ No newline at end of file +end -- cgit v1.2.3 From 72043f5b0cc2e930c2a616d84a8fea25f7224c59 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 00:09:01 +0200 Subject: APIDump: Added the Info.lua article. Fixes #504. --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + MCServer/Plugins/APIDump/InfoFile.html | 246 +++++++++++++++++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 MCServer/Plugins/APIDump/InfoFile.html (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index c97e2dbf8..19ca971e2 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2934,6 +2934,7 @@ end { -- No sorting is provided for these, they will be output in the same order as defined here { FileName = "Writing-a-MCServer-plugin.html", Title = "Writing a MCServer plugin" }, + { FileName = "InfoFile.html", Title = "Using the Info.lua file" }, { FileName = "SettingUpDecoda.html", Title = "Setting up the Decoda Lua IDE" }, { FileName = "SettingUpZeroBrane.html", Title = "Setting up the ZeroBrane Studio Lua IDE" }, { FileName = "UsingChunkStays.html", Title = "Using ChunkStays" }, diff --git a/MCServer/Plugins/APIDump/InfoFile.html b/MCServer/Plugins/APIDump/InfoFile.html new file mode 100644 index 000000000..3fff06d20 --- /dev/null +++ b/MCServer/Plugins/APIDump/InfoFile.html @@ -0,0 +1,246 @@ + + + + MCServer - Info.lua file + + + + + + + +
+

Info.lua file

+

Contents

+ + + +
+

Introduction

+ +

For a long time MCServer plugins were plagued by poor documentation. The plugins worked, people who wrote them knew how to use them, but for anyone new to the plugin it was a terrible ordeal learning how to use it. Most of the times, the plugin authors only wrote what commands the plugin supported, sometimes not even that. Then, there was a call to action to put an end to this, to make documenting the plugins easy and at the same time centralized. Thus, the Info.lua file was born.

+ +

Most plugins have some parts that are the same across all the plugins. These are commands, console commands and their permissions. If a plugin implemented a command, it would practically copy & paste the same code over and over again. So it makes sense to extract only unique information, centralize it and automate all the parts around it. This was another reason for the Info.lua file - it is a central hub of commands, console commands and their permissions.

+ +

Last, but not least, we want to make a plugin repository on the web in the future, a repository that would store plugins, their descriptions, comments. It makes sense that the centralized information can be parsed by the repository automatically, so that advanced things, such as searching for a plugin based on a command, or determining whether two plugins collide command-wise, are possible.

+ +

After this file format has been devised, a tool has been written that allows for an easy generation of the documentation for the plugin in various formats. It outputs the documentation in a format that is perfect for pasting into the forum. It generates documentation in a Markup format to use in README.md on GitHub and similar sites. The clever thing is that you don't need to keep all those formats in sync manually - you edit the Info.lua file and this tool will re-generate the documentation for you.

+ +

So to sum up, the Info.lua file contains the plugins' commands, console commands, their permissions and possibly the overall plugin documentation, in a structured manner that can be parsed by a program, yet is human readable and editable.

+ + +
+

The overall structure

+ +

The file consist of a declaration of a single Lua table, g_PluginInfo. This table contains all the information, structured, as its members. Each member can be a structure by itself. The entire file is a valid Lua source file, so any tool that syntax-checks Lua source can syntax-check this file. The file is somewhat forward- and backward- compatible, in the sense that it can be extended in any way without breaking.

+

Here's a skeleton of the file:

+
+g_PluginInfo =
+{
+	Name = "Example Plugin",
+	Date = "2014-06-12",
+	Description = "This is an example plugin that shows how to use the Info.lua file",
+	
+	-- The following members will be documented in greater detail later:
+	AdditionalInformation = {},
+	Commands = {},
+	ConsoleCommands = {},
+	Permissions = {},
+}
+
+

As you can see, the structure is pretty straightforward. Note that the order of the elements inside the table is not important (Lua property).

+ +

The first few elements are for book-keeping. They declare the plugin's name, the date in ISO-format, representing the version of the plugin, and the description. The idea is that the description sums up what the plugin is all about, within some two or three sentences.

+ + +
+

AdditionalInformation table

+ +

This table is used for more detailed description of the plugin. If there is any non-trivial setup process, dependencies, describe them here. This is where the description should get detailed. Don't worry about using several paragraphs of text here, if it makes the plugin easier to understand.

+ +

The table should have the following layout:

+
+AdditionalInformation =
+{
+	{
+		Title = "Chapter 1",
+		Contents = "Describe one big aspect of the plugin here",
+	},
+	{
+		Title = "Chapter 2",
+		Contents = "Describe another big topic",
+	},
+}
+
+

The idea here is that the tool that is used to generate the documentation from the Info.lua file will create a linkified table of contents and then each of the information elements' contents. This information should be all that is needed to successfully configure, run and manage the plugin.

+ + +
+

Commands table

+ +

The commands table lists all the commands that the plugin implements, together with their handler functions, required permissions, help strings and further information. The table supports recursion, which allows plugins to create multi-word commands easily (such as "//schematic load" and "//schematic save"), each having its own separate handler.

+ +

The table uses structure similar to the following:

+
+Commands =
+{
+	["/cmd1"] =
+	{
+		HelpString = "Performs the first action",
+		Permission = "firstplugin.cmds.1",
+		Alias = "/c1",
+		Handler = HandleCmd1,
+		ParameterCombinations =
+		{
+			{
+				Params = "x y z",
+				Help = "Performs the first action at the specified coordinates",
+			},
+			{
+				Params = "-p",
+				Help = "Performs the first action at the player's coordinates",
+			}
+		},
+	},
+	["/cmd2"] =
+	{
+		Alias = {"/c2", "//c2" },
+		Subcommands =
+		{
+			sub1 =  -- This declares a "/cmd2 sub1" command
+			{
+				HelpString = "Performs the second action's first subcommand",
+				Permission = "firstplugin.cmds.2.1",
+				Alias = "1",
+				Handler = HandleCmd2Sub1,
+				ParameterCombinations =
+				{
+					{
+						Params = "x y z",
+						Help = "Performs the second action's first subcommand at the specified coordinates",
+					},
+					{
+						Params = "-p",
+						Help = "Performs the second action's first subcommand at the player's coordinates",
+					}
+				},
+			},
+			sub2 =  -- Declares a "/cmd2 sub2" command
+			{
+				HelpString = "Performs the second action's second subcommand",
+				Permission = "firstplugin.cmds.2.2",
+				Handler = HandleCmd2Sub2,
+			},
+		},
+	},
+}
+
+ +

Although it may seem overwhelming at first, there is a "method to this madness". Each element of the Commands table defines one command. Most commands start with a slash, so the special Lua syntax for table elements with non-standard names needs to be applied (["/cmd1"] =). The command can either specify subcommands, or a handler function (specifying both is UndefinedBehavior). Subcommands uses the same structure as the entire Commands table, recursively.

+ +

The permission element specifies that the command is only available with the specified permission. Note that the permission for subcommand's parent isn't checked when the subcommand is called. This means that specifying the permission for a command that has subcommands has no effect whatsoever, but is discouraged because we may add processing for that in the future.

+ +

The ParameterCombinations table is used only for generating the documentation, it lists the various combinations of parameters that the command supports. It's worth specifying even if the command supports only one combination, because that combination will get documented this way.

+ +

The Alias member specifies any possible aliases for the command. Each alias is registered separately and if there is a subcommand table, it is applied to all aliases, just as one would expect. You can specify either a single string as the value (if there's only one alias), or a table of strings for multiple aliases. Commands with no aliases do not need to specify this member at all.

+ + +
+

ConsoleCommands table

+ +

This table serves a purpose similar to that of the Commands table, only these commands are provided for the server console. Therefore, there are no permissions specified for these commands. Since most console commands don't use a leading slash, the command names don't need the special syntax. Also, the handler function doesn't receive the Player parameter.

+ +

Here's an example of a ConsoleCommands table:

+
+ConsoleCommands =
+{
+	concmd =
+	{
+		HelpString = "Performs the console action",
+		Subcommands =
+		{
+			sub1 =
+			{
+				HelpString = "Performs the console action's first subcommand",
+				Handler = HandleConCmdSub1,
+				ParameterCombinations =
+				{
+					{
+						Params = "x y z",
+						Help = "Performs the console action's first subcommand at the specified coordinates",
+					},
+				},
+			},
+			sub2 =
+			{
+				HelpString = "Performs the console action's second subcommand",
+				Handler = HandleConCmdSub2,
+			},
+		},
+	},
+}
+
+ + +
+

Permissions table

+ +

The purpose of this table is to document permissions that the plugin uses. The documentation generator automatically collects the permissions specified in the Command table; the Permissions table adds a description for these permissions and may declare other permissions that aren't specifically included in the Command table.

+ +
+Permissions =
+{
+	["firstplugin.cmd.1.1"] =
+	{
+		Description = "Allows the players to build high towers using the first action.",
+		RecommendedGroups = "players",
+	},
+	["firstplugin.cmd.2.1"] =
+	{
+		Description = "Allows the players to kill entities using the second action. Note that this may be misused to kill other players, too.",
+		RecommendedGroups = "admins, mods",
+	},
+}
+
+ +

The RecommendedGroup element lists, in plain English, the intended groups for which the permission should be enabled on a typical server. Plugin authors are advised to create reasonable defaults, prefering security to openness, so that admins using these settings blindly don't expose their servers to malicious users.

+ + +
+

Using the file in code

+ +

Just writing the Info.lua file and saving it to the plugin folder is not enough for it to actually be used. Your plugin needs to include the following boilerplate code, preferably in its Initialize() function:

+
+-- Use the InfoReg shared library to process the Info.lua file:
+dofile(cPluginManager:GetPluginsPath() .. "/InfoReg.lua")
+RegisterPluginInfoCommands()
+RegisterPluginInfoConsoleCommands()
+
+ +

Of course, if your plugin doesn't have any console commands, it doesn't need to call the RegisterPluginInfoConsoleCommands() function, and similarly if it doesn't have any in-game commands, it doesn't need to call the RegisterPluginInfoCommands() function.

+ + +
+

Examples

+ +

There are several plugins that already implement this approach. You can visit them for inspiration and to see what the generated documentation looks like:

+ + + +
+ + -- cgit v1.2.3 From b0f1707d50895d47634095592f68da63621f6507 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 13 Jun 2014 23:16:52 +0200 Subject: Fixed ChunkWorx stop button giving an error --- MCServer/Plugins/ChunkWorx/chunkworx_web.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua index 6c5eab676..9aec38b12 100644 --- a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua +++ b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua @@ -43,7 +43,7 @@ function HandleRequest_Generation( Request ) local Content = "" if (Request.PostParams["AGHRRRR"] ~= nil) then GENERATION_STATE = 0 - WW_instance:SaveAllChunks() + WW_instance:QueueSaveAllChunks() WW_instance:QueueUnloadUnusedChunks() LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED by admin") end -- cgit v1.2.3 From 5b2b6e06150b6299d1e19374be092c0858b0e3a8 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 12 Jun 2014 19:50:02 -0700 Subject: Pawn: renamed HandleEntityEffects to HandleEntityEffect Exported entity effect functions for ToLua and documented them in APIDesc.lua --- MCServer/Plugins/APIDump/APIDesc.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 19ca971e2..1dba08fe3 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1688,6 +1688,9 @@ a_Player:OpenWindow(Window); TakeDamage = { Return = "" }, KilledBy = { Return = "" }, GetHealth = { Return = "number" }, + AddEntityEffect = { Params = "EffectType, {{cEntityEffect}}", Return = "", Notes = "Applies an entity effect" }, + RemoveEntityEffect = { Params = "EffectType", Return = "", Notes = "Removes a currently applied entity effect" }, + ClearEntityEffects = { Return = "", Notes = "Removes all currently applied entity effects" }, }, Inherits = "cEntity", }, -- cPawn -- cgit v1.2.3 From a37d5410b4486dd95692076e3da0368a4ed23577 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 12:50:54 +0200 Subject: APIDump: Added OnEntityAddEffect hook documentation. --- .../Plugins/APIDump/Hooks/OnEntityAddEffect.lua | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua b/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua new file mode 100644 index 000000000..423a2200b --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua @@ -0,0 +1,34 @@ +return +{ + HOOK_ENTITY_ADD_EFFECT = + { + CalledWhen = "An entity effect is about to get added to an entity.", + DefaultFnName = "OnEntityAddEffect", -- also used as pagename + Desc = [[ + This hook is called whenever an entity effect is about to be added to an entity. The plugin may + disallow the addition by returning true.

+

Note that this hook only fires for adding the effect, but not for the actual effect application. See + also the {{OnEntityRemoveEffect|HOOK_ENTITY_REMOVE_EFFECT}} for notification about effects expiring / + removing, and {{OnEntityApplyEffect|HOOK_ENTITY_APPLY_EFFECT}} for the actual effect application to the + entity. + ]], + Params = + { + { Name = "Entity", Type = "{{cEntity}}", Notes = "The entity to which the effect is about to be added" }, + { Name = "EffectType", Type = "number", Notes = "The type of the effect to be added. One of the effXXX constants." }, + { Name = "EffectDuration", Type = "number", Notes = "The duration of the effect to be added, in ticks." }, + { Name = "EffectIntensity", Type = "number", Notes = "The intensity (level) of the effect to be added. " }, + { Name = "Originator", Type = "{{cEntity}}", Notes = "The entity who originated the effect (threw the potion, the cavespider that used poison bite, etc.) May be nil if there's no originator associated with the effect. " }, + { Name = "DistanceModifier", Type = "number", Notes = "The modifier for the effect intensity, based on distance. Used mainly for splash potions." }, + }, + Returns = [[ + If the plugin returns true, the effect will not be added and none of the remaining hook handlers will + be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally + the effect is added to the entity. + ]], + }, -- HOOK_EXECUTE_COMMAND +} + + + + -- cgit v1.2.3 From e0a9f37d909e9d82ccac88dae910ce21a7fdba6f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 18 Jun 2014 12:13:01 +0200 Subject: (Force)ExecuteCommand returns the CommandResult enums Exported and documented the CommandResult enums --- MCServer/Plugins/APIDump/APIDesc.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 19ca971e2..fe38d94c7 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1872,9 +1872,9 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); }, CallPlugin = { Params = "PluginName, FunctionName, [FunctionArgs...]", Return = "[FunctionRets]", Notes = "(STATIC) Calls the specified function in the specified plugin, passing all the given arguments to it. If it succeeds, it returns all the values returned by that function. If it fails, returns no value at all. Note that only strings, numbers, bools, nils and classes can be used for parameters and return values; tables and functions cannot be copied across plugins." }, DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." }, - ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." }, + ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." }, FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" }, - ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, + ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature:

function(Command, Permission, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, ForEachConsoleCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindConsoleCommand(). The CallbackFn has the following signature:
function (Command, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, Get = { Params = "", Return = "cPluginManager", Notes = "(STATIC) Returns the single instance of the plugin manager" }, @@ -1890,8 +1890,23 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); LogStackTrace = { Params = "", Return = "", Notes = "(STATIC) Logs a current stack trace of the Lua engine to the server console log. Same format as is used when the plugin fails." }, ReloadPlugins = { Params = "", Return = "", Notes = "Reloads all active plugins" }, }, + ConstantGroups= + { + CommandResult = + { + Include = "^cr.*", + TextBefore = [[ + Results that the (Force)ExecuteCommand return. This gives information if the command is executed or not and the reason. + ]], + }, + }, Constants = { + crBlocked = { Notes = "When a plugin stopped the command using the OnExecuteCommand hook" }, + crError = { Notes = "When the command handler for the given command results in an error" }, + crExecuted = { Notes = "When the command is successfully executed." }, + crNoPermission = { Notes = "When the player doesn't have permission to execute the given command." }, + crUnknownCommand = { Notes = "When the given command doesn't exist." }, HOOK_BLOCK_SPREAD = { Notes = "Called when a block spreads based on world conditions" }, HOOK_BLOCK_TO_PICKUPS = { Notes = "Called when a block has been dug and is being converted to pickups. The server has provided the default pickups and the plugins may modify them." }, HOOK_CHAT = { Notes = "Called when a client sends a chat message that is not a command. The plugin may modify the chat message" }, -- cgit v1.2.3 From 08fed2a213f40e963ef871664439d744faefffba Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 21 Jun 2014 22:13:35 +0200 Subject: Added cClientHandle::IsUUIDOnline function. Ref.: #771 --- MCServer/Plugins/APIDump/APIDesc.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 19ca971e2..06e333cf9 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -523,13 +523,16 @@ end Functions = { + GenerateOfflineUUID = { Params = "Username", Return = "string", Notes = "(STATIC) Generates an UUID based on the player name provided. This is used for the offline (non-auth) mode, when there's no UUID source. Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. Returns a 36-char UUID (with dashes)." }, GetLocale = { Params = "", Return = "Locale", Notes = "Returns the locale string that the client sends as part of the protocol handshake. Can be used to provide localized strings." }, GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" }, GetPlayer = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player object connected to this client. Note that this may be nil, for example if the player object is not yet spawned." }, GetUniqueID = { Params = "", Return = "number", Notes = "Returns the UniqueID of the client used to identify the client in the server" }, + GetUUID = { Params = "", Return = "string", Notes = "Returns the authentication-based UUID of the client. This UUID should be used to identify the player when persisting any player-related data." }, GetUsername = { Params = "", Return = "string", Notes = "Returns the username that the client has provided" }, GetViewDistance = { Params = "", Return = "number", Notes = "Returns the viewdistance (number of chunks loaded for the player in each direction)" }, HasPluginChannel = { Params = "ChannelName", Return = "bool", Notes = "Returns true if the client has registered to receive messages on the specified plugin channel." }, + IsUUIDOnline = { Params = "UUID", Return = "bool", Notes = "(STATIC) Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. Accepts both 32-char and 36-char UUIDs (with and without dashes). If the string given is not a valid UUID, returns false."}, Kick = { Params = "Reason", Return = "", Notes = "Kicks the user with the specified reason" }, SendPluginMessage = { Params = "Channel, Message", Return = "", Notes = "Sends the plugin message on the specified channel." }, SetLocale = { Params = "Locale", Return = "", Notes = "Sets the locale that MCServer keeps on record. Initially the locale is initialized in protocol handshake, this function allows plugins to override the stored value (but only server-side and only until the user disconnects)." }, -- cgit v1.2.3 From 43060927536979dc943b8a4018f03748f3f3833b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 24 Jun 2014 07:05:49 +0200 Subject: Debuggers: Fixed the Blaze rod query tool. --- MCServer/Plugins/Debuggers/Debuggers.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 534426d25..deb6a720b 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -346,7 +346,7 @@ end function OnUsingBlazeRod(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ) -- Magic rod of query: show block types and metas for both neighbors of the pointed face - local Type, Meta, Valid = Player:GetWorld():GetBlockTypeMeta(BlockX, BlockY, BlockZ, Type, Meta); + local Valid, Type, Meta = Player:GetWorld():GetBlockTypeMeta(BlockX, BlockY, BlockZ); if (Type == E_BLOCK_AIR) then Player:SendMessage(cChatColor.LightGray .. "Block {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}: air:" .. Meta); @@ -356,7 +356,7 @@ function OnUsingBlazeRod(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, Cur end local X, Y, Z = AddFaceDirection(BlockX, BlockY, BlockZ, BlockFace); - Valid, Type, Meta = Player:GetWorld():GetBlockTypeMeta(X, Y, Z, Type, Meta); + Valid, Type, Meta = Player:GetWorld():GetBlockTypeMeta(X, Y, Z); if (Type == E_BLOCK_AIR) then Player:SendMessage(cChatColor.LightGray .. "Block {" .. X .. ", " .. Y .. ", " .. Z .. "}: air:" .. Meta); else -- cgit v1.2.3 From 5a152435b3fa1452a842519e21ab0643020bc1ab Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 15:22:48 +0200 Subject: Add documentation. --- .../APIDump/Hooks/OnPlayerFoodLevelChange.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua new file mode 100644 index 000000000..4838573e5 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua @@ -0,0 +1,22 @@ +return +{ + HOOK_PLAYER_FOOD_LEVEL_CHANGE = + { + CalledWhen = "Called before the player food level changed. Plugin may override / refuse.", + DefaultFnName = "OnPlayerFoodLevelChange", -- also used as pagename + Desc = [[ + This hook is called just before the food level change. + The food level is not yet changed, plugins may choose to override the new food level or refuse the change. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who change the food level." }, + { Name = "NewFoodLevel", Type = "number", Notes = "The new food level." }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Afterwards, the + server change the food level from the player. If the function returns true, no + other callback is called for this event and the player's food level doesn't change. + ]], + }, -- HOOK_PLAYER_FOOD_LEVEL_CHANGE +}; -- cgit v1.2.3 From 5a888f0a51ffbab6a6bd8ef24ff53ddf40a66ceb Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 20:30:13 +0200 Subject: Change documentation --- .../Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua index 4838573e5..5a6fc862a 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua @@ -5,18 +5,23 @@ return CalledWhen = "Called before the player food level changed. Plugin may override / refuse.", DefaultFnName = "OnPlayerFoodLevelChange", -- also used as pagename Desc = [[ - This hook is called just before the food level change. - The food level is not yet changed, plugins may choose to override the new food level or refuse the change. + This hook is called before the food level changes. + The food level is not changed yet, plugins may choose + to override the new food level or refuse the change. ]], Params = { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who change the food level." }, - { Name = "NewFoodLevel", Type = "number", Notes = "The new food level." }, + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who changes the food level." }, + { Name = "NewFoodLevel", Type = "number", Notes = "The new food level. You can override it." }, }, Returns = [[ If the function returns false or no value, the next plugin's callback is called. Afterwards, the - server change the food level from the player. If the function returns true, no + server changes the food level of the player. If the function returns true, no other callback is called for this event and the player's food level doesn't change. ]], }, -- HOOK_PLAYER_FOOD_LEVEL_CHANGE }; + + + + -- cgit v1.2.3 From 835d00428c2af43050fa248ab988c431ec1be152 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 2 Jul 2014 14:49:08 +0200 Subject: Update documentation --- MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua index 5a6fc862a..53637d5f1 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua @@ -2,17 +2,17 @@ return { HOOK_PLAYER_FOOD_LEVEL_CHANGE = { - CalledWhen = "Called before the player food level changed. Plugin may override / refuse.", + CalledWhen = "Called before the player food level changed. Plugin may override", DefaultFnName = "OnPlayerFoodLevelChange", -- also used as pagename Desc = [[ This hook is called before the food level changes. The food level is not changed yet, plugins may choose - to override the new food level or refuse the change. + to refuse the change. ]], Params = { { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who changes the food level." }, - { Name = "NewFoodLevel", Type = "number", Notes = "The new food level. You can override it." }, + { Name = "NewFoodLevel", Type = "number", Notes = "The new food level." }, }, Returns = [[ If the function returns false or no value, the next plugin's callback is called. Afterwards, the -- cgit v1.2.3 From 20afd5d70ee61e969f4015f851c1d8f04cd02215 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 3 Jul 2014 17:53:57 +0200 Subject: APIDump: Updated OnWeatherChanging docs after latest code changes. --- MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua b/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua index d36164e8e..bb809af11 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua @@ -6,7 +6,7 @@ return DefaultFnName = "OnWeatherChanging", -- also used as pagename Desc = [[ This hook is called when the current weather has expired and a new weather is selected. Plugins may - override the new weather setting.

+ override the new weather being set.

The new weather setting is sent to the clients only after this hook has been processed.

@@ -19,9 +19,12 @@ return { Name = "Weather", Type = "number", Notes = "The newly selected weather. One of wSunny, wRain, wStorm" }, }, Returns = [[ - If the function returns false or no value, the server calls other plugins' callbacks and finally - sets the weather. If the function returns true, the server takes the second returned value (wSunny - by default) and sets it as the new weather. No other plugins' callbacks are called in this case. + The hook handler can return up to two values. If the first value is false or not present, the server + calls other plugins' callbacks and finally sets the weather. If it is true, the server doesn't call any + more callbacks for this hook. The second value returned is used as the new weather. If no value is + given, the weather from the parameters is used as the weather. Returning false as the first value and a + specific weather constant as the second value makes the server call the rest of the hook handlers with + the new weather value. ]], }, -- HOOK_WEATHER_CHANGING } -- cgit v1.2.3 From aa81a3ff3e2d9c66e699e244cab0b624167a9127 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 4 Jul 2014 14:29:19 +0200 Subject: Fixed ExecuteCommand description. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index fe38d94c7..412fcc405 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1872,7 +1872,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); }, CallPlugin = { Params = "PluginName, FunctionName, [FunctionArgs...]", Return = "[FunctionRets]", Notes = "(STATIC) Calls the specified function in the specified plugin, passing all the given arguments to it. If it succeeds, it returns all the values returned by that function. If it fails, returns no value at all. Note that only strings, numbers, bools, nils and classes can be used for parameters and return values; tables and functions cannot be copied across plugins." }, DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." }, - ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." }, + ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns a {{cPluginManager#CommandResult|CommandResult}} value." }, FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" }, ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature:

function(Command, Permission, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, -- cgit v1.2.3 From 546aab7b4a3e1fd28e912a9cb6507f04dbf7bd17 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 4 Jul 2014 15:36:29 +0200 Subject: Removed useless sentence in cPluginManager:ExecuteCommand description. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 412fcc405..271340090 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1872,7 +1872,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); }, CallPlugin = { Params = "PluginName, FunctionName, [FunctionArgs...]", Return = "[FunctionRets]", Notes = "(STATIC) Calls the specified function in the specified plugin, passing all the given arguments to it. If it succeeds, it returns all the values returned by that function. If it fails, returns no value at all. Note that only strings, numbers, bools, nils and classes can be used for parameters and return values; tables and functions cannot be copied across plugins." }, DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." }, - ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns a {{cPluginManager#CommandResult|CommandResult}} value." }, + ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions." }, FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" }, ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature:
function(Command, Permission, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, -- cgit v1.2.3 From 3b7e0969b98ecbd1d499a9ac2edd22a619ae5591 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 18:19:05 +0200 Subject: Debuggers: Added forced chunk ticking test. Ref.: #1160 --- MCServer/Plugins/Debuggers/Debuggers.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index deb6a720b..918204deb 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -31,6 +31,8 @@ function Initialize(Plugin) PM:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage); PM:AddHook(cPluginManager.HOOK_PLAYER_JOINED, OnPlayerJoined); PM:AddHook(cPluginManager.HOOK_PROJECTILE_HIT_BLOCK, OnProjectileHitBlock); + PM:AddHook(cPluginManager.HOOK_CHUNK_UNLOADING, OnChunkUnloading); + PM:AddHook(cPluginManager.HOOK_WORLD_STARTED, OnWorldStarted); -- _X: Disabled so that the normal operation doesn't interfere with anything -- PM:AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); @@ -1382,6 +1384,7 @@ end function OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockHitPos) + -- Test projectile hooks by setting the blocks they hit on fire: local BlockX, BlockY, BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace) local World = a_Projectile:GetWorld() @@ -1391,3 +1394,28 @@ end + +function OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ) + -- Do not let chunk [0, 0] unload, so that it continues ticking [cWorld:SetChunkAlwaysTicked() test] + if ((a_ChunkX == 0) and (a_ChunkZ == 0)) then + return true + end +end + + + + + +function OnWorldStarted(a_World) + -- Make the chunk [0, 0] in every world keep ticking [cWorld:SetChunkAlwaysTicked() test] + a_World:ChunkStay({{0, 0}}, nil, + function() + -- The chunk is loaded, make it always tick: + a_World:SetChunkAlwaysTicked(0, 0, true) + end + ) +end + + + + -- cgit v1.2.3 From d790a45c5025e33712d8dd21f9349716ae4ee7d1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 18:28:20 +0200 Subject: APIDump: Documented cWorld:SetChunkAlwaysTicked. Ref.: #1160 --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index baa9f0f37..ea9f38db4 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2340,6 +2340,7 @@ end { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the meta for the block at the specified coords." }, { Params = "{{Vector3i|BlockCoords}}, BlockMeta", Return = "", Notes = "Sets the meta for the block at the specified coords." }, }, + SetChunkAlwaysTicked = { Params = "ChunkX, ChunkZ, IsAlwaysTicked", Return = "", Notes = "Sets the chunk to always be ticked even when it doesn't contain any clients. IsAlwaysTicked set to true turns forced ticking on, set to false turns it off. Every call with 'true' should be paired with a later call with 'false', otherwise the ticking won't stop. Multiple actions can request ticking independently, the ticking will continue until the last call with 'false'. Note that when the chunk unloads, it loses the value of this flag." }, SetNextBlockTick = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Sets the blockticking to start at the specified block in the next tick." }, SetCommandBlockCommand = { Params = "BlockX, BlockY, BlockZ, Command", Return = "bool", Notes = "Sets the command to be executed in a command block at the specified coordinates. Returns if command was changed." }, SetCommandBlocksEnabled = { Params = "IsEnabled (bool)", Return = "", Notes = "Sets whether command blocks should be enabled on the (entire) server." }, -- cgit v1.2.3 From f1491ad1d1df3e0b4d22af8329c95106e794ba01 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 01:18:41 +0200 Subject: Fixed diamond mover plugin --- MCServer/Plugins/DiamondMover/DiamondMover.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/DiamondMover/DiamondMover.lua b/MCServer/Plugins/DiamondMover/DiamondMover.lua index 0fdd32250..d3e70acfc 100644 --- a/MCServer/Plugins/DiamondMover/DiamondMover.lua +++ b/MCServer/Plugins/DiamondMover/DiamondMover.lua @@ -22,6 +22,8 @@ function Initialize(Plugin) Plugin:SetVersion(1); cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_USED_ITEM, OnPlayerUsedItem); + + LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()); return true; end @@ -36,8 +38,8 @@ function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, Cu return false; end; - if (Player:HasPermission("diamondmover.move") == false) then - return true; + if (not Player:HasPermission("diamondmover.move")) then + return false; end; -- Rclk with a diamond to push in the direction the player is facing @@ -56,7 +58,7 @@ function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, Cu if (PlayerPitch > 70) then -- looking down BlockY = BlockY - 1; else - local PlayerRot = Player:GetRotation() + 180; -- Convert [-180, 180] into [0, 360] for simpler conditions + local PlayerRot = Player:GetYaw() + 180; -- Convert [-180, 180] into [0, 360] for simpler conditions if ((PlayerRot < 45) or (PlayerRot > 315)) then BlockZ = BlockZ - 1; else -- cgit v1.2.3 From 554e1c0dd3cedbcb4035d8ffa7351d56bee5dfb5 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 16:10:01 -0700 Subject: OnEntityAddEffect.lua: Removed Originator param --- MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua b/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua index 423a2200b..1d1658a6f 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua @@ -18,7 +18,6 @@ return { Name = "EffectType", Type = "number", Notes = "The type of the effect to be added. One of the effXXX constants." }, { Name = "EffectDuration", Type = "number", Notes = "The duration of the effect to be added, in ticks." }, { Name = "EffectIntensity", Type = "number", Notes = "The intensity (level) of the effect to be added. " }, - { Name = "Originator", Type = "{{cEntity}}", Notes = "The entity who originated the effect (threw the potion, the cavespider that used poison bite, etc.) May be nil if there's no originator associated with the effect. " }, { Name = "DistanceModifier", Type = "number", Notes = "The modifier for the effect intensity, based on distance. Used mainly for splash potions." }, }, Returns = [[ -- cgit v1.2.3 From fc6a5878df2615262eb53cb1ca4ccfcf1e299dc6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:45:45 +0200 Subject: Removed special character in APIDump --- MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua index 4c91ea89e..9a0e036b9 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua @@ -2,7 +2,7 @@ return { HOOK_PLAYER_USED_BLOCK = { - CalledWhen = "A player has just used a block (chest, furnace…). Notification only.", + CalledWhen = "A player has just used a block (chest, furnace...). Notification only.", DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename Desc = [[ This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a -- cgit v1.2.3 From 51b91befbd26b630cd2cecaec081edd03edfb5f3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 23:11:59 +0200 Subject: Added RemoveItem() function to the player inventory. --- MCServer/Plugins/Debuggers/Debuggers.lua | 40 ++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 918204deb..95b36e854 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -60,9 +60,10 @@ function Initialize(Plugin) PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace"); 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("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z") + 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("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z"); + PM:BindCommand("/rmitem", "debuggers", HandleRMItem, "- Remove the specified item from the inventory."); Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers) Plugin:AddWebTab("StressTest", HandleRequest_StressTest) @@ -533,7 +534,7 @@ function OnTakeDamage(Receiver, TDI) -- Receiver is cPawn -- TDI is TakeDamageInfo - LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)"); + -- LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)"); return false; end @@ -1105,6 +1106,37 @@ end +function HandleRMItem(a_Split, a_Player) + if ((#a_Split ~= 2) and (#a_Split ~= 3)) then + a_Player:SendMessage("Usage: /rmitem [Count]") + return true + end + + local Item = cItem() + if (not StringToItem(a_Split[2], Item)) then + a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item") + return true + end + + if (#a_Split == 3) then + local Count = tonumber(a_Split[3]) + if (Count == nil) then + a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number") + return true + end + + Item.m_ItemCount = Count + end + + local RemovedItems = a_Player:GetInventory():RemoveItem(Item) + a_Player:SendMessageSuccess("Removed " .. RemovedItems .. " Items!") + return true +end + + + + + function HandleRequest_Debuggers(a_Request) local FolderContents = cFile:GetFolderContents("./"); return "

The following objects have been returned by cFile:GetFolderContents():

  • " .. table.concat(FolderContents, "
  • ") .. "

"; -- cgit v1.2.3 From abe8a6bd4588892f27f779fd92beb941853c5583 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:48:06 +0200 Subject: APIDump: Documented RemoveItem(). --- MCServer/Plugins/APIDump/APIDesc.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0e626c580..e65da1d16 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1155,6 +1155,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" }, HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" }, HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" }, + RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the inventory, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." }, RemoveOneEquippedItem = { Params = "", Return = "", Notes = "Removes one item from the hotbar's currently selected slot" }, SetArmorSlot = { Params = "ArmorSlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified armor slot contents" }, SetEquippedSlotNum = { Params = "EquippedSlotNum", Return = "", Notes = "Sets the currently selected hotbar slot number" }, @@ -1384,6 +1385,7 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, { Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, }, + RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the grid, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." }, RemoveOneItem = { { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, -- cgit v1.2.3 From 0346ab15adaf73e4d7c4ee4cfb175d40e721adfe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:51:15 +0200 Subject: Debuggers: Optimized and commented the /rmitem handler. --- MCServer/Plugins/Debuggers/Debuggers.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 95b36e854..b402c1867 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -1107,18 +1107,21 @@ end function HandleRMItem(a_Split, a_Player) - if ((#a_Split ~= 2) and (#a_Split ~= 3)) then + -- Check params: + if (a_Split[2] == nil) then a_Player:SendMessage("Usage: /rmitem [Count]") return true end + -- Parse the item type: local Item = cItem() if (not StringToItem(a_Split[2], Item)) then a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item") return true end - if (#a_Split == 3) then + -- Parse the optional item count + if (a_Split[3] ~= nil) then local Count = tonumber(a_Split[3]) if (Count == nil) then a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number") @@ -1128,8 +1131,9 @@ function HandleRMItem(a_Split, a_Player) Item.m_ItemCount = Count end - local RemovedItems = a_Player:GetInventory():RemoveItem(Item) - a_Player:SendMessageSuccess("Removed " .. RemovedItems .. " Items!") + -- Remove the item: + local NumRemovedItems = a_Player:GetInventory():RemoveItem(Item) + a_Player:SendMessageSuccess("Removed " .. NumRemovedItems .. " Items!") return true end -- cgit v1.2.3