require("mineunit") mineunit("core") mineunit("common/chatcommands") mineunit("server") mineunit("player") mineunit("settings") mineunit("auth") sourcefile("init") mineunit:mods_loaded() minetest.check_password_entry = function() return false end minetest.kick_player = function () return end local exists = minetest.player_exists local settings = core.settings describe("Afk works", function() local admin = Player("admin", {kick = true, ban = true}) local newplayer = Player("bannedplayer") setup(function() mineunit:execute_on_joinplayer(admin) mineunit:execute_on_joinplayer(newplayer, {address = "9.9.9.9"}) mineunit:execute_on_leaveplayer(newplayer) end) it("Bans players", function() admin:send_chat_message("/xban bannedplayer ban message") mineunit:execute_on_joinplayer(newplayer) assert.is_not_true(newplayer._online) end) it("Bans players from the same IP", function() local secondplayer = Player("totallynotbannedplayer") mineunit:execute_on_joinplayer(secondplayer, {address = "9.9.9.9"}) assert.is_not_true(newplayer._online) end) it("Unbans players", function() admin:send_chat_message("/xunban bannedplayer unban message") mineunit:execute_on_joinplayer(newplayer) assert.is_true(newplayer._online) end) it("Allows players from the same IP again after unban", function() local secondplayer = Player("totallynotbannedplayer") mineunit:execute_on_joinplayer(secondplayer, {address = "9.9.9.9"}) assert.is_true(newplayer._online) end) end)