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