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 local dprint = function() end
function mcl_commands.build(def) function mcl_commands.build(name, chat_def)
local cmd = { local cmd = {
_subs = {} _subs = {}
} }
@ -174,8 +174,8 @@ function mcl_commands.build(def)
table.insert(self._subs, sub) table.insert(self._subs, sub)
end end
if def.func then if chat_def.func then
def.func(cmd) chat_def.func(cmd)
end end
cmd.func = function(name, param) cmd.func = function(name, param)
@ -224,18 +224,19 @@ function mcl_commands.build(def)
missing_privs_str = missing_privs_str..missing_privs[i] missing_privs_str = missing_privs_str..missing_privs[i]
end end
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 end
end end
return false, "Invalid parameters: " return false, "Invalid parameters!"
end end
if not def.params then if chat_def.params then
def.params = "" cmd.params = chat_def.params
else
cmd.params = ""
end end
cmd.params = def.params cmd.privs = chat_def.privs
cmd.privs = def.privs cmd.description = chat_def.description
cmd.description = def.description
return cmd return cmd
end end

View File

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

View File

@ -5,21 +5,6 @@ minetest.register_privilege("announce", {
give_to_singleplayer = false, 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", { mcl_commands.register_command("say", {
func = function(cmd) func = function(cmd)
cmd:sub(":message:text", { cmd:sub(":message:text", {