-- mod governor by mckaygerhard -- Copyright 2020 ---------------------------------------------------------------------------- -- this program can be used free but cannot be used commertially or -- modified for, licenced CC-BY-SA-NC 4.0 -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ---------------------------------------------------------------------------- if not governing.modkillme then minetest.register_chatcommand("killme", { description = "Kill player or yourselft to respawn", func = function(name) local player = minetest.get_player_by_name(name) if player then if minetest.settings:get_bool("enable_damage") and player:is_player() then player:set_hp(0) return true else for _, callback in pairs(minetest.registered_on_respawnplayers) do if callback(player) then return true end end -- There doesn't seem to be a way to get a default spawn pos from the lua API return false, "No static_spawnpoint defined" end else -- Show error message if used when not logged in, eg: from IRC mod return false, "You need to be online to be killed!" end end }) end -- manual query if not governing.modgeoip then minetest.register_chatcommand("geoip", { params = "", privs = {geoip=true}, description = "Does a geoip lookup on the given player for governing", func = function(name, param) if not param then return true, "usage: /geoip " end minetest.log("warning", "[governing/geoip] Player " .. name .. " queries : " .. param) if not minetest.get_player_ip then return true, "minetest.get_player_ip no available! engine its too older or client does not provide such info." end local ip = minetest.get_player_ip(param) if not ip then return true, "no ip available! seems ".. name .." does not provide such info!" end governing.lookup(ip, function(result) local txt = format_result(result) if not txt then return true, "Geoip error: "..name..":"..ip": " .. (result.description or "unknown error") end minetest.log("action", "[geoip] result for player " .. param .. ": " .. txt) minetest.chat_send_player(name, txt) end) end }) end