return { -- id is required, server_version is recommended, all other fields are optional id = "mcchat", name = "MCChat", version = "0.1.0", priority = 80, server_version = "0.2", authors = {"trimill"}, description = "Adds basic chat and join/leave messages", license = "MIT", init = function(self) srv:add_command("tell") srv:add_command("msg") srv:add_command("me") end, on_join = function(self, _, name) srv:info(name .. " joined the game") srv:send_msg({ translate = "multiplayer.player.joined", with = { { text = name } }, color = "yellow", }) end, on_leave = function(self, _, name) srv:info(name .. " left the game") srv:send_msg({ translate = "multiplayer.player.left", with = { { text = name } }, color = "yellow", }) end, on_message = function(self, msg, _, name) srv:info("<" .. name .. "> " .. msg) srv:send_chat({ translate = "chat.type.text", with = { { text = name }, { text = msg }, }, }) return true end, on_command = function(self, cmd, args, _, uuid, name) if cmd == "me" then local msg = table.concat(args, " ") srv:info("* " .. name .. " " .. msg) srv:send_chat({ translate = "chat.type.emote", with = { { text = name }, { text = msg } }, }) elseif cmd == "tell" or cmd == "msg" then local target = args[1] if target == nil then srv:send_msg({ text = cmd .. ": no target specified", color = "red", }, uuid) return end local target_uuid = srv:get_uuid(target) if target_uuid == nil then srv:send_msg({ text = cmd .. ": player not found: " .. target, color = "red", }, uuid) return end local msg = table.concat(args, " ", 2) srv:info(name .. " whispers to " .. target .. ": " .. msg) srv:send_chat({ translate = "commands.message.display.outgoing", with = { { text = target }, { text = msg } }, color = "gray", italic = true, }, uuid) srv:send_chat({ translate = "commands.message.display.incoming", with = { { text = name }, { text = msg } }, color = "gray", italic = true, }, target_uuid); end end }