mckaygerhard
31542d73da
* this cos we will also implement a new cdn api tool to detect vpn access and real ip clients
66 lines
2.2 KiB
Lua
66 lines
2.2 KiB
Lua
-- 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 = "<playername>",
|
|
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 <playername>" end
|
|
if not minetest.get_player_ip then return true, "[geoip]: engine its too older, canot get ip of player." end
|
|
|
|
local ip = minetest.get_player_ip(param)
|
|
if not ip then return true, "[geoip] no ip available! seems "..param.." does not provide such info!" end
|
|
|
|
governing.lookup(ip, function(result)
|
|
local txt = format_result_geoip(result)
|
|
if not txt then return true, "[geoip]: "..param..":"..ip" error: "..(result.description or "unknown error") end
|
|
minetest.log("action", "[geoip] "..param..": "..txt)
|
|
minetest.chat_send_player(name, param..": "..txt)
|
|
end)
|
|
|
|
end
|
|
})
|
|
end
|
|
|