summaryrefslogtreecommitdiffstats
path: root/MCServer
diff options
context:
space:
mode:
Diffstat (limited to 'MCServer')
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua6
-rw-r--r--MCServer/Plugins/APIDump/Hooks/OnServerPing.lua50
m---------MCServer/Plugins/Core0
3 files changed, 55 insertions, 1 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index e6ee4ca10..9bc6299d9 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1984,6 +1984,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
HOOK_PLAYER_USING_ITEM = { Notes = "Called when the player is about to right-click with a usable item in their hand." },
HOOK_POST_CRAFTING = { Notes = "Called after a valid recipe has been chosen for the current contents of the crafting grid. Plugins may modify the recipe." },
HOOK_PRE_CRAFTING = { Notes = "Called before a recipe is searched for the current contents of the crafting grid. Plugins may provide a recipe and cancel the built-in search." },
+ HOOK_SERVER_PING = { Notes = "Called when a client pings the server from the server list. Plugins may change the favicon, server description, players online and maximum players values." },
HOOK_SPAWNED_ENTITY = { Notes = "Called after an entity is spawned in a {{cWorld|world}}. The entity is already part of the world." },
HOOK_SPAWNED_MONSTER = { Notes = "Called after a mob is spawned in a {{cWorld|world}}. The mob is already part of the world." },
HOOK_SPAWNING_ENTITY = { Notes = "Called just before an entity is spawned in a {{cWorld|world}}." },
@@ -2033,8 +2034,10 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
AddGroupToRank = { Params = "GroupName, RankName", Return = "bool", Notes = "Adds the specified group to the specified rank. Returns true on success, false on failure - if the group name or the rank name is not found." },
AddPermissionToGroup = { Params = "Permission, GroupName", Return = "bool", Notes = "Adds the specified permission to the specified group. Returns true on success, false on failure - if the group name is not found." },
AddRank = { Params = "RankName, MsgPrefix, MsgSuffix, MsgNameColorCode", Return = "", Notes = "Adds a new rank of the specified name and with the specified message visuals. Logs an info message and does nothing if the rank already exists." },
+ ClearPlayerRanks = { Params = "", Return = "", Notes = "Removes all player ranks from the database. Note that this doesn't change the cPlayer instances for the already connected players, you need to update all the instances manually." },
GetAllGroups = { Params = "", Return = "array-table of groups' names", Notes = "Returns an array-table containing the names of all the groups that are known to the manager." },
GetAllPermissions = { Params = "", Return = "array-table of permissions", Notes = "Returns an array-table containing all the permissions that are known to the manager." },
+ GetAllPlayers = { Params = "", Return = "array-table of uuids", Notes = "Returns the short uuids of all defined players, sorted by the players' names (case insensitive)." },
GetAllRanks = { Params = "", Return = "array-table of ranks' names", Notes = "Returns an array-table containing the names of all the ranks that are known to the manager." },
GetDefaultRank = { Params = "", Return = "string", Notes = "Returns the name of the default rank. " },
GetGroupPermissions = { Params = "GroupName", Return = "array-table of permissions", Notes = "Returns an array-table containing the permissions that the specified group contains." },
@@ -2042,6 +2045,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
GetPlayerMsgVisuals = { Params = "PlayerUUID", Return = "MsgPrefix, MsgSuffix, MsgNameColorCode", Notes = "Returns the message visuals assigned to the player. If the player is not explicitly assigned a rank, the default rank's visuals are returned. If there is an error, no value is returned at all." },
GetPlayerPermissions = { Params = "PlayerUUID", Return = "array-table of permissions", Notes = "Returns the permissions that the specified player is assigned through their rank. Returns the default rank's permissions if the player has no explicit rank assigned to them. Returns an empty array on error." },
GetPlayerRankName = { Params = "PlayerUUID", Return = "RankName", Notes = "Returns the name of the rank that is assigned to the specified player. An empty string (NOT the default rank) is returned if the player has no rank assigned to them." },
+ GetPlayerName = { Params = "PlayerUUID", Return = "PlayerName", Notes = "Returns the last name that the specified player has, for a player in the ranks database. An empty string is returned if the player isn't in the database." },
GetRankGroups = { Params = "RankName", Return = "array-table of groups' names", Notes = "Returns an array-table of the names of all the groups that are assigned to the specified rank. Returns an empty table if there is no such rank." },
GetRankPermissions = { Params = "RankName", Return = "array-table of permissions", Notes = "Returns an array-table of all the permissions that are assigned to the specified rank through its groups. Returns an empty table if there is no such rank." },
GetRankVisuals = { Params = "RankName", Return = "MsgPrefix, MsgSuffix, MsgNameColorCode", Notes = "Returns the message visuals for the specified rank. Returns no value if the specified rank does not exist." },
@@ -2814,7 +2818,7 @@ end
Globals =
{
Desc = [[
- These functions are available directly, without a class instance. Any plugin cal call them at any
+ These functions are available directly, without a class instance. Any plugin can call them at any
time.
]],
Functions =
diff --git a/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua b/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua
new file mode 100644
index 000000000..6d2325fe6
--- /dev/null
+++ b/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua
@@ -0,0 +1,50 @@
+return
+{
+ HOOK_SERVER_PING =
+ {
+ CalledWhen = "Client pings the server from the server list.",
+ DefaultFnName = "OnServerPing", -- also used as pagename
+ Desc = [[
+ A plugin may implement an OnServerPing() function and register it as a Hook to process pings from
+ clients in the server server list. It can change the logged in players and player capacity, as well
+ as the server description and the favicon, that are displayed to the client in the server list.
+ ]],
+ Params = {
+ { Name = "ClientHandle", Type = "{{cClientHandle}}", Notes = "The client handle that pinged the server" },
+ { Name = "ServerDescription", Type = "string", Notes = "The server description" },
+ { Name = "OnlinePlayersCount", Type = "number", Notes = "The number of players currently on the server" },
+ { Name = "MaxPlayersCount", Type = "number", Notes = "The current player cap for the server" },
+ { Name = "Favicon", Type = "string", Notes = "The base64 encoded favicon to be displayed in the server list for compatible clients" },
+ },
+ Returns = [[
+ The plugin can return whether to continue processing of the hook with other plugins, the server description to
+ be displayed to the client, the currently online players, the player cap and the base64/png favicon data, in that order.
+ ]],
+ CodeExamples = {
+ {
+ Title = "Change information returned to the player",
+ Desc = "Tells the client that the server description is 'test', there are one more players online than there actually are, and that the player cap is zero. It also changes the favicon data.",
+ Code = [[
+function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
+ -- Change Server Description
+ ServerDescription = "Test"
+
+ -- Change online / max players
+ OnlinePlayers = OnlinePlayers + 1
+ MaxPlayers = 0
+
+ -- Change favicon
+ if (cFile:IsFile("my-favicon.png")) then
+ local FaviconData = cFile:ReadWholeFile("my-favicon.png")
+ if (FaviconData != "") then
+ Favicon = Base64Encode(FaviconData)
+ end
+ end
+
+ return false, ServerDescription, OnlinePlayers, MaxPlayers, Favicon
+end
+ ]],
+ },
+ },
+ }, -- HOOK_SERVER_PING
+}
diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core
-Subproject 9de86060388b515642c55d58b44b4281285efc0
+Subproject 3a0e0597b7a24c44bf87ec90beb9be48d0b9970