Make the server status message customizable (#7357)
authorSmallJoker <SmallJoker@users.noreply.github.com>
Sun, 1 Jul 2018 10:31:28 +0000 (12:31 +0200)
committerGitHub <noreply@github.com>
Sun, 1 Jul 2018 10:31:28 +0000 (12:31 +0200)
Remove now redundant setting show_statusline_on_connect
Improve documentation of `minetest.get_server_status`

builtin/game/chatcommands.lua
builtin/game/misc.lua
builtin/settingtypes.txt
doc/lua_api.txt
minetest.conf.example
src/defaultsettings.cpp
src/server.cpp

index d56f2112bd9632d94b7b5193bab0a0bedbc45795..4aef063de11b4de466bb7b378ffb82eef6a6a051 100644 (file)
@@ -799,7 +799,11 @@ core.register_chatcommand("rollback", {
 core.register_chatcommand("status", {
        description = "Show server status",
        func = function(name, param)
-               return true, core.get_server_status()
+               local status = core.get_server_status(name, false)
+               if status and status ~= "" then
+                       return true, status
+               end
+               return false, "This command was disabled by a mod or game"
        end,
 })
 
index 2e05cdc41a803367e1e19480b9d627d6407e8dc4..1d60f1958bd0c80967ba87477e09450e360120f6 100644 (file)
@@ -62,6 +62,12 @@ end
 core.register_on_joinplayer(function(player)
        local player_name = player:get_player_name()
        player_list[player_name] = player
+       if not minetest.is_singleplayer() then
+               local status = core.get_server_status(player_name, true)
+               if status and status ~= "" then
+                       core.chat_send_player(player_name, status)
+               end
+       end
        core.send_join_message(player_name)
 end)
 
index b43d66838cf796beb5e694bd8eb8d64e60efa33f..0b0ec4a4c01b404e9296f6e2befa6e28de76f1c3 100644 (file)
@@ -950,9 +950,6 @@ map-dir (Map directory) path
 #    Setting it to -1 disables the feature.
 item_entity_ttl (Item entity TTL) int 900
 
-#    If enabled, show the server status message on player connection.
-show_statusline_on_connect (Status message on connection) bool true
-
 #    Enable players getting damage and dying.
 enable_damage (Damage) bool false
 
index 9fb22556bdc2d5f41f6a9641bcf0e06fea7ec1ff..d7f45fb1b42a1a34f7b524fb54382462e102c11f 100644 (file)
@@ -3997,7 +3997,13 @@ These functions return the leftover itemstack.
       Negative delay cancels the current active shutdown.
       Zero delay triggers an immediate shutdown.
 * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
-* `minetest.get_server_status()`: returns server status string
+* `minetest.get_server_status(name, joined)`
+    * Returns the server status string when a player joins or when the command
+      `/status` is called. Returns `nil` or an empty string when the message is
+      disabled.
+    * `joined`: Boolean value, indicates whether the function was called when
+      a player joined.
+    * This function may be overwritten by mods to customize the status message.
 * `minetest.get_server_uptime()`: returns the server uptime in seconds
 * `minetest.remove_player(name)`: remove player from database (if they are not
   connected).
index 266c9fd8c312721886ada025067ba64332a4dcd6..493c4a64809758756a7b89b148564f634f049bcc 100644 (file)
 #    type: int
 # item_entity_ttl = 900
 
-#    If enabled, show the server status message on player connection.
-#    type: bool
-# show_statusline_on_connect = true
-
 #    Enable players getting damage and dying.
 #    type: bool
 # enable_damage = false
index 1d1da5128e0d3a7294e1ad21a176b597c5559388..8bcded9cd94d1dea37b20320a5faf1222b353ff8 100644 (file)
@@ -305,7 +305,6 @@ void set_default_settings(Settings *settings)
        settings->setDefault("motd", "");
        settings->setDefault("max_users", "15");
        settings->setDefault("creative_mode", "false");
-       settings->setDefault("show_statusline_on_connect", "true");
        settings->setDefault("enable_damage", "true");
        settings->setDefault("default_password", "");
        settings->setDefault("default_privs", "interact, shout");
index 753c71701139d02a01543a8f990064a39dbfb9f7..38d2c5e94f1b69a2492abbbfaf823f1988a8c55b 100644 (file)
@@ -1059,11 +1059,6 @@ PlayerSAO* Server::StageTwoClientInit(session_t peer_id)
        // Send Breath
        SendPlayerBreath(playersao);
 
-       // Note things in chat if not in simple singleplayer mode
-       if (!m_simple_singleplayer_mode && g_settings->getBool("show_statusline_on_connect")) {
-               // Send information about server to player in chat
-               SendChatMessage(peer_id, ChatMessage(CHATMESSAGE_TYPE_SYSTEM, getStatusString()));
-       }
        Address addr = getPeerAddress(player->getPeerId());
        std::string ip_str = addr.serializeString();
        actionstream<<player->getName() <<" [" << ip_str << "] joins game. " << std::endl;