quectocraft/plugins/mcchat/main.lua

46 lines
1 KiB
Lua
Raw Normal View History

2022-12-04 06:06:21 +00:00
local plugin = {
2022-12-05 16:31:45 +00:00
id = "mcchat",
name = "MCChat",
2022-12-04 06:06:21 +00:00
description = "Provides Minecraft-style chat. Messages sent by one client will be broadcasted to every client.",
authors = { "trimill" },
version = "0.1.0",
}
local logger = nil
function plugin.init()
logger = server.initLogger(plugin)
2022-12-05 16:31:45 +00:00
logger.info("MCChat version " .. plugin.version)
2022-12-04 06:06:21 +00:00
end
function plugin.playerJoin(name)
logger.info(name .. " joined the game")
server.broadcast({
translate = "multiplayer.player.joined",
with = { {text = name} },
color = "yellow"
})
end
function plugin.playerLeave(name)
logger.info(name .. " left the game")
server.broadcast({
translate = "multiplayer.player.left",
with = { {text = name} },
color = "yellow"
})
end
function plugin.chatMessage(message, author)
logger.info("<" .. author .. "> " .. message)
server.broadcast({
translate = "chat.type.text",
with = {
{text = author},
{text = message}
}
})
end
return plugin