forked from mtcontrib/factions
Fixed protection to use newer API
This commit is contained in:
parent
4c72e388e8
commit
565608876b
13
factions.lua
13
factions.lua
@ -498,11 +498,9 @@ end
|
||||
function factions.get_player_faction(playername)
|
||||
local facname = factions.players[playername]
|
||||
if facname then
|
||||
minetest.chat_send_all(facname)
|
||||
local faction = factions.factions[facname]
|
||||
return faction
|
||||
end
|
||||
minetest.chat_send_all(playername)
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -728,12 +726,10 @@ minetest.register_on_joinplayer(
|
||||
)
|
||||
minetest.register_on_respawnplayer(
|
||||
function(player)
|
||||
local playername = player:get_player_name()
|
||||
local faction = factions.players[playername]
|
||||
local faction = factions.get_player_faction(player:get_player_name())
|
||||
if not faction then
|
||||
return false
|
||||
else
|
||||
faction = factions.factions[faction]
|
||||
if not faction.spawn then
|
||||
return false
|
||||
else
|
||||
@ -756,8 +752,8 @@ minetest.is_protected = function(pos, player)
|
||||
end
|
||||
|
||||
local parcelpos = factions.get_parcel_pos(pos)
|
||||
local parcel_faction = factions.parcels[parcelpos]
|
||||
local player_faction = factions.players[player]
|
||||
local parcel_faction = factions.get_parcel_faction(parcelpos)
|
||||
local player_faction = factions.get_player_faction(player)
|
||||
-- check if wielding death banner
|
||||
local player_info = minetest.get_player_by_name(player)
|
||||
if not player_info then
|
||||
@ -769,15 +765,12 @@ minetest.is_protected = function(pos, player)
|
||||
end
|
||||
local player_wield = player_info:get_wielded_item()
|
||||
if player_wield:get_name() == "banners:death_banner" and player_faction then --todo: check for allies, maybe for permissions
|
||||
player_faction = factions.factions[player_faction]
|
||||
parcel_faction = factions.factions[parcel_faction]
|
||||
return not player_faction:has_permission(player, "claim") and player_faction.power > 0. and not parcel_faction.is_admin
|
||||
end
|
||||
-- no faction
|
||||
if not parcel_faction then
|
||||
return default_is_protected(pos, player)
|
||||
else
|
||||
parcel_faction = factions.factions[parcel_faction]
|
||||
if parcel_faction.name == player_faction then
|
||||
return not parcel_faction:has_permission(player, "build")
|
||||
elseif parcel_faction.attacked_parcels[parcelpos] then -- chunk is being attacked
|
||||
|
Loading…
Reference in New Issue
Block a user