mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-15 13:55:11 -05:00
Add minetest.kick_player(name, reason)
This commit is contained in:
parent
ea0def381d
commit
857a49e081
@ -670,6 +670,24 @@ minetest.register_chatcommand("unban", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("kick", {
|
||||||
|
params = "<name> [reason]",
|
||||||
|
description = "kick a player",
|
||||||
|
privs = {kick=true},
|
||||||
|
func = function(name, param)
|
||||||
|
local tokick, reason = string.match(param, "([^ ]+) (.+)")
|
||||||
|
if not tokick then
|
||||||
|
tokick = param
|
||||||
|
end
|
||||||
|
if not minetest.kick_player(tokick, reason) then
|
||||||
|
minetest.chat_send_player(name, "Failed to kick player " .. tokick)
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(name, "kicked " .. tokick)
|
||||||
|
minetest.log("action", name .. " kicked " .. tokick)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("clearobjects", {
|
minetest.register_chatcommand("clearobjects", {
|
||||||
params = "",
|
params = "",
|
||||||
description = "clear all objects in world",
|
description = "clear all objects in world",
|
||||||
|
@ -34,6 +34,7 @@ minetest.register_privilege("basic_privs", "Can modify 'shout' and 'interact' pr
|
|||||||
minetest.register_privilege("server", "Can do server maintenance stuff")
|
minetest.register_privilege("server", "Can do server maintenance stuff")
|
||||||
minetest.register_privilege("shout", "Can speak in chat")
|
minetest.register_privilege("shout", "Can speak in chat")
|
||||||
minetest.register_privilege("ban", "Can ban and unban players")
|
minetest.register_privilege("ban", "Can ban and unban players")
|
||||||
|
minetest.register_privilege("kick", "Can kick players")
|
||||||
minetest.register_privilege("give", "Can use /give and /giveme")
|
minetest.register_privilege("give", "Can use /give and /giveme")
|
||||||
minetest.register_privilege("password", "Can use /setpassword and /clearpassword")
|
minetest.register_privilege("password", "Can use /setpassword and /clearpassword")
|
||||||
minetest.register_privilege("fly", {
|
minetest.register_privilege("fly", {
|
||||||
|
@ -1532,6 +1532,7 @@ minetest.get_ban_list() -> ban list (same as minetest.get_ban_description(""))
|
|||||||
minetest.get_ban_description(ip_or_name) -> ban description (string)
|
minetest.get_ban_description(ip_or_name) -> ban description (string)
|
||||||
minetest.ban_player(name) -> ban a player
|
minetest.ban_player(name) -> ban a player
|
||||||
minetest.unban_player_or_ip(name) -> unban player or IP address
|
minetest.unban_player_or_ip(name) -> unban player or IP address
|
||||||
|
minetest.kick_player(name, [reason]) -> disconnect a player with a optional reason
|
||||||
|
|
||||||
Particles:
|
Particles:
|
||||||
minetest.add_particle(particle definition)
|
minetest.add_particle(particle definition)
|
||||||
|
@ -160,6 +160,31 @@ int ModApiServer::l_ban_player(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// kick_player(name, [reason]) -> success
|
||||||
|
int ModApiServer::l_kick_player(lua_State *L)
|
||||||
|
{
|
||||||
|
NO_MAP_LOCK_REQUIRED;
|
||||||
|
const char *name = luaL_checkstring(L, 1);
|
||||||
|
std::string message;
|
||||||
|
if (lua_isstring(L, 2))
|
||||||
|
{
|
||||||
|
message = std::string("Kicked: ") + lua_tostring(L, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "Kicked.";
|
||||||
|
}
|
||||||
|
Player *player = getEnv(L)->getPlayer(name);
|
||||||
|
if (player == NULL)
|
||||||
|
{
|
||||||
|
lua_pushboolean(L, false); // No such player
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
getServer(L)->DenyAccess(player->peer_id, narrow_to_wide(message));
|
||||||
|
lua_pushboolean(L, true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// unban_player_or_ip()
|
// unban_player_or_ip()
|
||||||
int ModApiServer::l_unban_player_or_ip(lua_State *L)
|
int ModApiServer::l_unban_player_or_ip(lua_State *L)
|
||||||
{
|
{
|
||||||
@ -327,6 +352,7 @@ void ModApiServer::Initialize(lua_State *L, int top)
|
|||||||
API_FCT(get_ban_list);
|
API_FCT(get_ban_list);
|
||||||
API_FCT(get_ban_description);
|
API_FCT(get_ban_description);
|
||||||
API_FCT(ban_player);
|
API_FCT(ban_player);
|
||||||
|
API_FCT(kick_player);
|
||||||
API_FCT(unban_player_or_ip);
|
API_FCT(unban_player_or_ip);
|
||||||
API_FCT(notify_authentication_modified);
|
API_FCT(notify_authentication_modified);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,9 @@ private:
|
|||||||
// unban_player_or_ip()
|
// unban_player_or_ip()
|
||||||
static int l_unban_player_or_ip(lua_State *L);
|
static int l_unban_player_or_ip(lua_State *L);
|
||||||
|
|
||||||
|
// kick_player(name, [message]) -> success
|
||||||
|
static int l_kick_player(lua_State *L);
|
||||||
|
|
||||||
// notify_authentication_modified(name)
|
// notify_authentication_modified(name)
|
||||||
static int l_notify_authentication_modified(lua_State *L);
|
static int l_notify_authentication_modified(lua_State *L);
|
||||||
|
|
||||||
|
@ -330,6 +330,8 @@ public:
|
|||||||
void peerAdded(con::Peer *peer);
|
void peerAdded(con::Peer *peer);
|
||||||
void deletingPeer(con::Peer *peer, bool timeout);
|
void deletingPeer(con::Peer *peer, bool timeout);
|
||||||
|
|
||||||
|
void DenyAccess(u16 peer_id, const std::wstring &reason);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class EmergeThread;
|
friend class EmergeThread;
|
||||||
@ -415,7 +417,6 @@ private:
|
|||||||
|
|
||||||
void DiePlayer(u16 peer_id);
|
void DiePlayer(u16 peer_id);
|
||||||
void RespawnPlayer(u16 peer_id);
|
void RespawnPlayer(u16 peer_id);
|
||||||
void DenyAccess(u16 peer_id, const std::wstring &reason);
|
|
||||||
void DeleteClient(u16 peer_id, ClientDeletionReason reason);
|
void DeleteClient(u16 peer_id, ClientDeletionReason reason);
|
||||||
void UpdateCrafting(u16 peer_id);
|
void UpdateCrafting(u16 peer_id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user