A welcome with the player's name¶
This plugin welcomes each player by name when they join, like "Welcome, Steve!".
main.lua
plugin.registerEvent("PlayerJoinEvent", function(event)
local player = event:getPlayer()
player:sendMessage("Welcome, " .. player:getName() .. "!")
end)
How it works¶
This is the join event from your first plugin, with one change to the message. player:getName() gives you the player's name, and the two dots .. glue pieces of text together, so "Welcome, " and the name and "!" become one message.
How did we know about getName?
It comes from the Spigot API documentation, and soon you'll learn how to look up methods like this yourself.
Next: a leave message.