Chatcommand aliases (by luk3yx)

This commit is contained in:
MoNTE48 2019-11-01 22:14:56 +01:00
parent 6abf056272
commit fcdc8266a7

View File

@ -66,6 +66,15 @@ local function parse_range_str(player_name, str)
return p1, p2
end
-- Chatcommand aliases (by @luk3yx)
local function register_chatcommand_alias(new, old)
local def = assert(core.registered_chatcommands[old])
assert(not core.registered_chatcommands[new])
core.registered_chatcommands[new] = def
end
core.register_chatcommand_alias = register_chatcommand_alias
--
-- Chat commands
--
@ -100,7 +109,7 @@ core.register_chatcommand("privs", {
return true, "Privileges of " .. name .. ": "
.. core.privs_to_string(
core.get_player_privs(name), ' ')
end,
end
})
local function handle_grant_command(caller, grantname, grantprivstr)
@ -270,7 +279,6 @@ core.register_chatcommand("clearpassword", {
})
core.register_chatcommand("auth_reload", {
params = "",
description = "Reload authentication data",
privs = {server = true},
func = function(name, param)
@ -305,7 +313,6 @@ core.register_chatcommand("remove_player", {
})
core.register_chatcommand("auth_save", {
params = "",
description = "Write authentication data to disk",
privs = {server = true},
func = function(name, param)
@ -421,6 +428,7 @@ core.register_chatcommand("teleport", {
.. '") or player not found (see /help teleport)'
end
})
register_chatcommand_alias("tp", "teleport")
core.register_chatcommand("set", {
params = "([-n] <name> <value>) | <name>",
@ -544,9 +552,8 @@ core.register_chatcommand("fixlight", {
})
core.register_chatcommand("mods", {
params = "",
description = "List mods installed on the server",
privs = {},
privs = {server = true},
func = function(name, param)
return true, table.concat(core.get_modnames(), ", ")
end
@ -659,7 +666,6 @@ core.register_chatcommand("spawnentity", {
})
core.register_chatcommand("pulverize", {
params = "",
description = "Destroy item in hand",
func = function(name, param)
local player = core.get_player_by_name(name)
@ -785,7 +791,7 @@ core.register_chatcommand("status", {
end
})
core.register_chatcommand("time", {
core.register_chatcommand("settime", {
params = "<0..23>:<0..59> | <0..24000>",
description = "Set time of day",
privs = {},
@ -824,6 +830,7 @@ core.register_chatcommand("time", {
return true, "Time of day changed."
end
})
register_chatcommand_alias("time", "settime")
core.register_chatcommand("days", {
description = "Display day count",
@ -948,6 +955,7 @@ core.register_chatcommand("msg", {
return true, "Message sent."
end
})
register_chatcommand_alias("m", "msg")
core.register_chatcommand("last-login", {
params = "[<name>]",
@ -1026,7 +1034,6 @@ core.register_chatcommand("kill", {
})
core.register_chatcommand("spawn", {
params = "",
description = "Teleport to the spawn point",
func = function(name, param)
local player = core.get_player_by_name(name)
@ -1044,7 +1051,6 @@ core.register_chatcommand("spawn", {
})
core.register_chatcommand("setspawn", {
params = "",
description = "Sets the spawn point to your current position",
privs = {server = true},
func = function(name, param)