mirror of
https://git.phreedom.club/localhost_frssoft/fediauth.git
synced 2024-11-18 22:19:15 +00:00
Refactor
* Position lock by default without entities * Make immortal player
This commit is contained in:
parent
c433898c26
commit
7f89f9f2e8
83
join.lua
83
join.lua
|
@ -16,16 +16,8 @@ local formspecfediadd = "size[9,10]" ..
|
||||||
|
|
||||||
local feditempstore = {}
|
local feditempstore = {}
|
||||||
local failed_counter = {}
|
local failed_counter = {}
|
||||||
|
local armor_stor = {}
|
||||||
local cubic_jail_entities = {}
|
local playerpos_stor = {}
|
||||||
function fediauth.remove_lock_cube(playername)
|
|
||||||
if cubic_jail_entities[playername] == nil then return end
|
|
||||||
for _, obj in ipairs(cubic_jail_entities[playername]) do
|
|
||||||
obj:remove()
|
|
||||||
end
|
|
||||||
cubic_jail_entities[playername] = nil
|
|
||||||
minetest.log("action", "[fediauth] cubic jail removed for: '" .. playername .. "'")
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_entity("fediauth:checkmark", {
|
minetest.register_entity("fediauth:checkmark", {
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
|
@ -41,22 +33,6 @@ minetest.register_entity("fediauth:checkmark", {
|
||||||
on_detach = function(self, parent) self.object:remove() end
|
on_detach = function(self, parent) self.object:remove() end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_entity("fediauth:stopper", {
|
|
||||||
initial_properties = {
|
|
||||||
pointable = false,
|
|
||||||
physical = true,
|
|
||||||
collide_with_objects = true,
|
|
||||||
armor_group = { immortal = 1 },
|
|
||||||
collisionbox = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
|
|
||||||
visual = "sprite",
|
|
||||||
visual_size = {x = 1, y = 1 },
|
|
||||||
textures = { "ignore" },
|
|
||||||
use_texture_alpha = true,
|
|
||||||
static_save = true,
|
|
||||||
glow = 10,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function fediauth.verified_checkmark(player, verified)
|
function fediauth.verified_checkmark(player, verified)
|
||||||
local tag = player:get_player_name()
|
local tag = player:get_player_name()
|
||||||
local props = player:get_properties()
|
local props = player:get_properties()
|
||||||
|
@ -70,34 +46,15 @@ end
|
||||||
-- Code formspec on join for fediauth enabled players
|
-- Code formspec on join for fediauth enabled players
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local player_pos = player:getpos()
|
playerpos_stor[playername] = player:getpos()
|
||||||
|
armor_stor[playername] = player:get_armor_groups()
|
||||||
|
if minetest.settings.get_bool("fediauth.make_immortal_player", true) then
|
||||||
|
player:set_armor_groups({immortal = 1})
|
||||||
|
end
|
||||||
|
|
||||||
if fediauth.is_player_bypassed(playername) then return end
|
if fediauth.is_player_bypassed(playername) then return end
|
||||||
if fediauth.is_player_enabled(playername) or minetest.settings:get_bool("fediauth.fedi_required", false) then
|
if fediauth.is_player_enabled(playername) or minetest.settings:get_bool("fediauth.fedi_required", false) then
|
||||||
minetest.log("action", "[fediauth] session start for player: '" .. playername .. "'")
|
minetest.log("action", "[fediauth] session start for player: '" .. playername .. "'")
|
||||||
if minetest.settings:get_bool("fediauth.create_lock_jail_cube") then
|
|
||||||
local cube = {}
|
|
||||||
for x=-2,2 do
|
|
||||||
for y=-2,2 do
|
|
||||||
for z=-2,2 do
|
|
||||||
if x ~= 0 then
|
|
||||||
table.insert(cube, {player_pos.x + x, player_pos.y + y, player_pos.z + z})
|
|
||||||
elseif y ~= 0 and y ~= 1 then
|
|
||||||
table.insert(cube, {player_pos.x + x, player_pos.y + y, player_pos.z + z})
|
|
||||||
elseif z ~= 0 then
|
|
||||||
table.insert(cube, {player_pos.x + x, player_pos.y + y, player_pos.z + z})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local cube_entities = {}
|
|
||||||
for _, i in ipairs(cube) do
|
|
||||||
table.insert(cube_entities, minetest.add_entity({x=i[1], y=i[2], z=i[3]}, "fediauth:stopper", nil))
|
|
||||||
end
|
|
||||||
cubic_jail_entities[playername] = cube_entities
|
|
||||||
cube = nil
|
|
||||||
minetest.log("action", "[fediauth] cubic jail created for: '" .. playername .. "'")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- start fediauth session time
|
-- start fediauth session time
|
||||||
fediauth_sessions[player:get_player_name()] = os.time()
|
fediauth_sessions[player:get_player_name()] = os.time()
|
||||||
|
@ -158,7 +115,6 @@ minetest.register_on_leaveplayer(function(player, timed_out)
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
fediauth_sessions[playername] = nil
|
fediauth_sessions[playername] = nil
|
||||||
fediauth.discard_passw(playername)
|
fediauth.discard_passw(playername)
|
||||||
fediauth.remove_lock_cube(playername)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- check sessions periodically and kick if timed out
|
-- check sessions periodically and kick if timed out
|
||||||
|
@ -237,16 +193,29 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
fediauth.regrant_privs(playername)
|
fediauth.regrant_privs(playername)
|
||||||
fediauth.discard_passw(playername)
|
fediauth.discard_passw(playername)
|
||||||
fediauth.verified_checkmark(player, true)
|
fediauth.verified_checkmark(player, true)
|
||||||
if minetest.settings:get_bool("fediauth.create_lock_jail_cube") then
|
player:set_armor_groups(armor_stor[playername])
|
||||||
fediauth.remove_lock_cube(playername)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
fediauth.discard_passw(playername)
|
fediauth.discard_passw(playername)
|
||||||
minetest.kick_player(playername, "fediauth code validation failed")
|
minetest.kick_player(playername, "fediauth code validation failed")
|
||||||
fediauth.regrant_privs(playername)
|
fediauth.regrant_privs(playername)
|
||||||
if minetest.settings:get_bool("fediauth.create_lock_jail_cube") then
|
|
||||||
fediauth.remove_lock_cube(playername)
|
|
||||||
end
|
|
||||||
failed_counter[playername] = (failed_counter[playername] or 0) + 1
|
failed_counter[playername] = (failed_counter[playername] or 0) + 1
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if minetest.settings:get_bool("fediauth.position_lock", true) then
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
|
local playername = player:get_player_name()
|
||||||
|
local playerpos = player:get_pos()
|
||||||
|
if fediauth_sessions[playername] ~= nil then
|
||||||
|
if playerpos ~= playerpos_stor[playername] then -- position lock, stupid, but works as possible
|
||||||
|
-- maybe compatible with others mods who override physics
|
||||||
|
player:add_velocity({x = (playerpos_stor[playername].x - playerpos.x) * 2,
|
||||||
|
y = (playerpos_stor[playername].y - playerpos.y) * 2,
|
||||||
|
z = (playerpos_stor[playername].z - playerpos.z) * 2})
|
||||||
|
player:set_pos(playerpos_stor[playername])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
|
@ -16,5 +16,7 @@ fediauth.restricted_instances (Restrict instance domains) string example.com,ano
|
||||||
# Supported on: Pleroma/Akkoma and their forks
|
# Supported on: Pleroma/Akkoma and their forks
|
||||||
fediauth.automatic_delete (Mark messages for delete*) bool false
|
fediauth.automatic_delete (Mark messages for delete*) bool false
|
||||||
|
|
||||||
# Unstable and can cause out of memory. Create jail/lock cube entities around player
|
fediauth.position_lock (Lock position player) bool true
|
||||||
fediauth.create_lock_jail_cube (Create jail/lock cube) bool false
|
|
||||||
|
# Makes player immortal during fediauth proccess
|
||||||
|
fediauth.make_immortal_player (Make immortal player) bool true
|
||||||
|
|
Loading…
Reference in a new issue