From bcba1c643dbdec701592c73463a246f1af973731 Mon Sep 17 00:00:00 2001 From: ccuser44 <68124053+ccuser44@users.noreply.github.com> Date: Thu, 16 Mar 2023 23:37:26 +0200 Subject: [PATCH] Create `/version` command (#250) Co-authored-by: Mat --- CONTRIBUTORS | 1 + Info.lua | 37 +++++++++++++++++++++++++++++++++++-- README.md | 3 +++ cmd_version.lua | 13 +++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 cmd_version.lua diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9884f97..cad774c 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -8,6 +8,7 @@ as provided in the LICENSE file. 36451 bearbin (Alexander Harkness) Bond-009 +ccuser44 daniel0916 Etmix Howaner diff --git a/Info.lua b/Info.lua index c08a7ef..a1372e2 100644 --- a/Info.lua +++ b/Info.lua @@ -11,6 +11,14 @@ g_PluginInfo = Commands = { + ["/about"] = + { + Alias = "/abt", + Permission = "core.version", + Handler = HandleVersionCommand, + HelpString = "Shows the version of the server software.", + }, + ["/ban"] = { Permission = "core.ban", @@ -661,7 +669,15 @@ g_PluginInfo = }, }, }, - + + ["/version"] = + { + Alias = "/ver", + Permission = "core.version", + Handler = HandleVersionCommand, + HelpString = "Shows the version of the server software.", + }, + ["/viewdistance"] = { Permission = "core.viewdistance", @@ -759,6 +775,12 @@ g_PluginInfo = ConsoleCommands = { + ["about"] = + { + Handler = HandleVersionCommand, + HelpString = "Shows the version of the server software.", + }, + ["ban"] = { Handler = HandleConsoleBan, @@ -1287,7 +1309,13 @@ g_PluginInfo = }, }, }, - + + ["version"] = + { + Handler = HandleVersionCommand, + HelpString = "Shows the version of the server software.", + }, + ["weather"] = { Handler = HandleConsoleWeather, @@ -1445,6 +1473,11 @@ g_PluginInfo = Description = "Allows players to manage the whitelist.", RecommendedGroups = "admins", }, + + ["core.version"] = + { + Description = "Shows the version of the server software.", + }, }, -- Permissions } -- g_PluginInfo diff --git a/README.md b/README.md index 9903fa9..ad58dec 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Implements some of the basic commands needed to run a simple server. ### General | Command | Permission | Description | | ------- | ---------- | ----------- | +|/about | core.version | Shows the server software version.| |/ban | core.ban | Bans a player.| |/clear | core.clear | Clears the inventory of a player.| |/difficulty | core.difficulty | Changes the difficulty level of the world you're located in.| @@ -55,6 +56,7 @@ Implements some of the basic commands needed to run a simple server. |/unrank | core.unrank | Add a player to the default rank.| |/unsafegive | core.give.unsafe | Gives an item to a player, even if the item is blacklisted.| |/unsafeitem | core.item.unsafe | Gives your player an item, even if the item is blacklisted.| +|/version | core.version | Shows the server software version.| |/viewdistance | core.viewdistance | Changes your view distance.| |/weather | core.weather | Changes the world's weather.| |/whitelist | | Manages the whitelist.| @@ -113,6 +115,7 @@ Implements some of the basic commands needed to run a simple server. | core.tps | | `/tps` | | | core.unban | | `/unban` | | | core.unrank | | `/deop`, `/unrank` | | +| core.version | | `/version`, `/about` | | | core.viewdistance | | `/viewdistance` | | | core.weather | Allows players to change the weather. | `/weather` | admins | | core.whitelist | Allows players to manage the whitelist. | `/whitelist off`, `/whitelist list`, `/whitelist remove`, `/whitelist on`, `/whitelist add` | admins | diff --git a/cmd_version.lua b/cmd_version.lua new file mode 100644 index 0000000..b649f7c --- /dev/null +++ b/cmd_version.lua @@ -0,0 +1,13 @@ +function HandleVersionCommand(Split, Player) + -- Send output to player: + Response = SendMessage(Player, string.format( + "This server is running Cuberite %s - %s (%s - %s) with Lua version %s and SQLite version %s.", + cRoot:GetBuildSeriesName(), + cRoot:GetBuildID(), + cRoot:GetBuildCommitID(), + cRoot:GetBuildDateTime(), + _VERSION, + sqlite3.version() + )) + return true, Response +end