1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
--Banish command
--Copyright 2016,2018 Gabriel PĂ©rez-Cerezo
--AGPLv3
local spawn_spawnpos = minetest.setting_get_pos("static_spawnpoint")
local banish_pos = {x=-300,y=7,z=-48}
banish = {}
banish.spawn = {}
local modpath = minetest.get_modpath("banish")
function banish.xbanish(name, param)
-- banish player in param.
local plname, reason = param:match("(%S+)%s+(.+)")
if not plname or not reason then
minetest.chat_send_player(name, "banish: invalid syntax")
return
end
local player = minetest.get_player_by_name(plname)
if player == nil then
minetest.chat_send_player(name,"Player "..plname.." not found.")
return false
end
local record = {
source = name,
time = os.time(),
expires = nil,
reason = reason,
type = "jail",
}
xban.add_record(plname, record)
xban.add_property(plname, "jailed", true)
if beds.spawn[plname] then
banish.spawn[plname] = beds.spawn[plname]
else
banish.spawn[plname] = spawn_spawnpos
end
banish.save_spawns()
beds.spawn[plname] = banish_pos
beds.save_spawns()
player:setpos(banish_pos)
local privs = minetest.get_player_privs(plname)
privs.teleport = false
privs.home = false
minetest.set_player_privs(plname, {interact=true, shout=true})
minetest.chat_send_player(name, "Player "..plname.." has been jailed")
end
function banish.xunbanish(name, param)
local plname, reason = param:match("(%S+)%s+(.+)")
if not plname or not reason then
minetest.chat_send_player(name, "banish: invalid syntax")
return
end
if not banish.spawn[plname] then
minetest.chat_send_player(name,"Player "..plname.." was never jailed")
return
end
local record = {
source = name,
time = os.time(),
expires = nil,
reason = reason,
type = "unjail",
}
xban.add_record(plname, record)
xban.add_property(plname, "jailed", nil)
beds.spawn[plname] = banish.spawn[plname]
beds.save_spawns()
minetest.set_player_privs(plname, {interact=true, shout=true, home=true})
minetest.chat_send_player(name, "Player "..plname.." has been unjailed")
end
minetest.register_chatcommand("jail", {
description = "Jails Players",
privs = {kick=true},
params = "<player> <reason>",
func = function(name, param)
banish.xbanish(name, param)
end,
})
minetest.register_chatcommand("unjail", {
description = "Unjails players",
privs = {kick=true},
params = "<player> <reason>",
func = function(name, param)
banish.xunbanish(name, param)
end,
})
minetest.register_on_joinplayer(function(player)
banish.read_spawns()
end)
dofile(modpath .. "/spawns.lua")
|