local S = minetest.get_translator(minetest.get_current_modname())

local msg = {
	S("Game over. Time to start all over again."),
	S("Oh wow, you died. Tough luck."),
	S("Seems like that creeper catched up to you, huh."),
	S("You're 100% dead, no jokes. And no game."),
	S("Be more careful next time."),
	S("Wasted. Try again."),
}

minetest.register_on_dieplayer(function(player, reason)
	local name = player:get_player_name()
	local meta = player:get_meta()
	local message = msg[math.random(1, #msg)]
	meta:set_int("dead", 1)
	if xban then
		xban.ban_player(name, nil, nil, message)
	else
		minetest.kick_player(name, message)
	end
	minetest.log("action", "[vl_yolo] "..name.." died and has been banned!")
end)

minetest.register_on_joinplayer(function(player)
	if xban and xban.find_entry(player)[2] then return
	else
		local meta = player:get_meta()
		local message = msg[math.random(1, #msg)]
		if meta:get_int("dead") == 1 then
			local name = player:get_player_name()
			minetest.kick_player(name, message)
		end
	end
end)
