Don't allow bad names
This mod stops people from using bad usernames and allows people with ban priv add and remove names from ingame
This commit is contained in:
parent
33f507c28e
commit
e91b7c0521
2 changed files with 69 additions and 0 deletions
60
mods/other/disallowed_names/init.lua
Normal file
60
mods/other/disallowed_names/init.lua
Normal file
|
@ -0,0 +1,60 @@
|
|||
local storage = minetest.get_mod_storage()
|
||||
minetest.deserialize(storage:get_string("disallowed_names"))
|
||||
disallowed_names=minetest.deserialize(storage:get_string("disallowed_names")) or {"sex","fuck","damn","drug","suicid"}
|
||||
|
||||
minetest.register_on_prejoinplayer(function(name)
|
||||
for k,v in pairs(disallowed_names) do
|
||||
if string.find(string.lower(name),string.lower(v)) then
|
||||
return "Your cannot use that username in this server, please change it and come back."
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--adds a name to disallowed names
|
||||
minetest.register_chatcommand("bdname_add", {
|
||||
params = "<string>",
|
||||
privs = {ban= true},
|
||||
description = "adds a name to disallowed names",
|
||||
func = function(name,param)
|
||||
if param ~= "" then
|
||||
table.insert(disallowed_names,tostring(param))
|
||||
minetest.chat_send_player(name, "added "..param.." to the list of banned words")
|
||||
local serial_table = minetest.serialize(disallowed_names)
|
||||
storage:set_string("disallowed_names", serial_table)
|
||||
|
||||
else
|
||||
minetest.chat_send_player(name, "You need to add a name\n/bdname_add <name>")
|
||||
end
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
--removes a name from disallowed names
|
||||
minetest.register_chatcommand("bdname_remove",{
|
||||
description = "removes a name from disallowed names",
|
||||
params = "<name>",
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
if param ~="" then
|
||||
for k in pairs(disallowed_names) do
|
||||
if param == disallowed_names[k] then
|
||||
table.remove(disallowed_names,k)
|
||||
end
|
||||
end
|
||||
storage:set_string("disallowed_names", minetest.serialize(disallowed_names))
|
||||
end
|
||||
end
|
||||
|
||||
})
|
||||
|
||||
--list disallowed names
|
||||
minetest.register_chatcommand("bdname_list", {
|
||||
description = "lists all the disallowed",
|
||||
privs = {ban= true},
|
||||
func= function(name)
|
||||
for k,v in pairs(disallowed_names) do
|
||||
minetest.chat_send_player(name, disallowed_names[k])
|
||||
end
|
||||
end
|
||||
})
|
9
mods/other/disallowed_names/license.txt
Normal file
9
mods/other/disallowed_names/license.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
Copyright 2021 olliy
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
Loading…
Reference in a new issue