Message when trying to spawn forbidden hostile mob
This commit is contained in:
parent
f2b7392a30
commit
7a870d0ead
6 changed files with 30 additions and 4 deletions
|
@ -126,6 +126,21 @@ local function register_chatcommand_alias(alias, cmd)
|
|||
minetest.register_chatcommand(alias, def)
|
||||
end
|
||||
|
||||
-- Replace spawnentity cmd to disallow spawning of hostile mobs if disabled
|
||||
local orig_func = minetest.registered_chatcommands["spawnentity"].func
|
||||
local cmd = table.copy(minetest.registered_chatcommands["spawnentity"])
|
||||
cmd.func = function(name, param)
|
||||
local ent = minetest.registered_entities[param]
|
||||
if minetest.settings:get_bool("only_peaceful_mobs", false) and ent and ent._cmi_is_mob and ent.type == "monster" then
|
||||
return false, S("Only peaceful mobs allowed!")
|
||||
else
|
||||
local bool, msg = orig_func(name, param)
|
||||
return bool, msg
|
||||
end
|
||||
end
|
||||
minetest.unregister_chatcommand("spawnentity")
|
||||
minetest.register_chatcommand("spawnentity", cmd)
|
||||
|
||||
if minecraftaliases then
|
||||
register_chatcommand_alias("?", "help")
|
||||
register_chatcommand_alias("who", "list")
|
||||
|
@ -145,3 +160,4 @@ if minecraftaliases then
|
|||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue