This commit is contained in:
AFCMS 2021-03-08 23:27:39 +01:00
parent 43c641f84f
commit 19e83fc2fb
3 changed files with 26 additions and 38 deletions

View File

@ -61,7 +61,7 @@ end
local dprint = function() end
function mcl_commands.build(def)
function mcl_commands.build(name, chat_def)
local cmd = {
_subs = {}
}
@ -174,8 +174,8 @@ function mcl_commands.build(def)
table.insert(self._subs, sub)
end
if def.func then
def.func(cmd)
if chat_def.func then
chat_def.func(cmd)
end
cmd.func = function(name, param)
@ -224,18 +224,19 @@ function mcl_commands.build(def)
missing_privs_str = missing_privs_str..missing_privs[i]
end
end
return false, "You don't have permission to run this command (missing privilege: "..missing_privs_str..")" --TODO:replace message
return false, "You don't have permission to run this command (missing privilege: "..missing_privs_str..")"
end
end
end
return false, "Invalid parameters: "
return false, "Invalid parameters!"
end
if not def.params then
def.params = ""
if chat_def.params then
cmd.params = chat_def.params
else
cmd.params = ""
end
cmd.params = def.params
cmd.privs = def.privs
cmd.description = def.description
cmd.privs = chat_def.privs
cmd.description = chat_def.description
return cmd
end

View File

@ -41,19 +41,21 @@ local function handle_kill_command(suspect, victim)
return true
end
mcl_commands.overide_command("kill", function(cmd)
cmd:sub("", {
func = function(name)
return handle_kill_command(name, name)
end,
})
cmd:sub(":target:username", {
func = function(name, target)
return handle_kill_command(name, target)
end,
privs = {settime = true}
})
end, {
mcl_commands.overide_command("kill", {
func = function(cmd)
cmd:sub("", {
func = function(name)
return handle_kill_command(name, name)
end,
})
cmd:sub(":target:username", {
func = function(name, target)
return handle_kill_command(name, target)
end,
privs = {settime = true}
})
end,
description = "Kill player or yourself.",
params = S("[<target>]"),
privs = {server = true},
})

View File

@ -5,21 +5,6 @@ minetest.register_privilege("announce", {
give_to_singleplayer = false,
})
mcl_commands.register_command("say", function(cmd)
cmd:sub(":message:text", {
func = function(name, message)
minetest.chat_send_all(("["..name.."] "..message))
return true
end})
end,
{
description = S("Send a message to every player"),
params = S("<message>"),
privs = {
announce = true,
}
})
mcl_commands.register_command("say", {
func = function(cmd)
cmd:sub(":message:text", {