File tree 4 files changed +22
-8
lines changed
4 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,16 @@ local S = core.get_translator("__builtin")
6
6
-- Misc. API functions
7
7
--
8
8
9
+ -- @spec core.kick_player(String, String) :: Boolean
10
+ function core .kick_player (player_name , reason )
11
+ if type (reason ) == " string" then
12
+ reason = " Kicked: " .. reason
13
+ else
14
+ reason = " Kicked."
15
+ end
16
+ return core .disconnect_player (player_name , reason )
17
+ end
18
+
9
19
function core .check_player_privs (name , ...)
10
20
if core .is_player (name ) then
11
21
name = name :get_player_name ()
Original file line number Diff line number Diff line change @@ -5741,6 +5741,10 @@ Bans
5741
5741
* `minetest.kick_player(name, [reason])`: disconnect a player with an optional
5742
5742
reason.
5743
5743
* Returns boolean indicating success (false if player nonexistant)
5744
+ * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
5745
+ optional reason, this will not prefix with 'Kicked: ' like kick_player.
5746
+ If no reason is given, it will default to 'Disconnected.'
5747
+ * Returns boolean indicating success (false if player nonexistant)
5744
5748
5745
5749
Particles
5746
5750
---------
Original file line number Diff line number Diff line change @@ -310,20 +310,20 @@ int ModApiServer::l_ban_player(lua_State *L)
310
310
return 1 ;
311
311
}
312
312
313
- // kick_player (name, [reason]) -> success
314
- int ModApiServer::l_kick_player (lua_State *L)
313
+ // disconnect_player (name, [reason]) -> success
314
+ int ModApiServer::l_disconnect_player (lua_State *L)
315
315
{
316
316
NO_MAP_LOCK_REQUIRED;
317
317
318
318
if (!getEnv (L))
319
319
throw LuaError (" Can't kick player before server has started up" );
320
320
321
321
const char *name = luaL_checkstring (L, 1 );
322
- std::string message ( " Kicked " ) ;
322
+ std::string message;
323
323
if (lua_isstring (L, 2 ))
324
- message.append (" : " ). append ( readParam<std::string>(L, 2 ));
324
+ message.append (readParam<std::string>(L, 2 ));
325
325
else
326
- message.append (" ." );
326
+ message.append (" Disconnected ." );
327
327
328
328
RemotePlayer *player = dynamic_cast <ServerEnvironment *>(getEnv (L))->getPlayer (name);
329
329
if (player == NULL ) {
@@ -554,7 +554,7 @@ void ModApiServer::Initialize(lua_State *L, int top)
554
554
API_FCT (get_ban_list);
555
555
API_FCT (get_ban_description);
556
556
API_FCT (ban_player);
557
- API_FCT (kick_player );
557
+ API_FCT (disconnect_player );
558
558
API_FCT (remove_player);
559
559
API_FCT (unban_player_or_ip);
560
560
API_FCT (notify_authentication_modified);
Original file line number Diff line number Diff line change @@ -97,8 +97,8 @@ class ModApiServer : public ModApiBase
97
97
// unban_player_or_ip()
98
98
static int l_unban_player_or_ip (lua_State *L);
99
99
100
- // kick_player (name, [message ]) -> success
101
- static int l_kick_player (lua_State *L);
100
+ // disconnect_player (name, [reason ]) -> success
101
+ static int l_disconnect_player (lua_State *L);
102
102
103
103
// remove_player(name)
104
104
static int l_remove_player (lua_State *L);
You can’t perform that action at this time.
0 commit comments