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