Fixed protection to use newer API

This commit is contained in:
shamoanjac 2016-08-18 15:21:59 +02:00
parent 4c72e388e8
commit 565608876b

View File

@ -498,11 +498,9 @@ end
function factions.get_player_faction(playername) function factions.get_player_faction(playername)
local facname = factions.players[playername] local facname = factions.players[playername]
if facname then if facname then
minetest.chat_send_all(facname)
local faction = factions.factions[facname] local faction = factions.factions[facname]
return faction return faction
end end
minetest.chat_send_all(playername)
return nil return nil
end end
@ -728,12 +726,10 @@ minetest.register_on_joinplayer(
) )
minetest.register_on_respawnplayer( minetest.register_on_respawnplayer(
function(player) function(player)
local playername = player:get_player_name() local faction = factions.get_player_faction(player:get_player_name())
local faction = factions.players[playername]
if not faction then if not faction then
return false return false
else else
faction = factions.factions[faction]
if not faction.spawn then if not faction.spawn then
return false return false
else else
@ -756,8 +752,8 @@ minetest.is_protected = function(pos, player)
end end
local parcelpos = factions.get_parcel_pos(pos) local parcelpos = factions.get_parcel_pos(pos)
local parcel_faction = factions.parcels[parcelpos] local parcel_faction = factions.get_parcel_faction(parcelpos)
local player_faction = factions.players[player] local player_faction = factions.get_player_faction(player)
-- check if wielding death banner -- check if wielding death banner
local player_info = minetest.get_player_by_name(player) local player_info = minetest.get_player_by_name(player)
if not player_info then if not player_info then
@ -769,15 +765,12 @@ minetest.is_protected = function(pos, player)
end end
local player_wield = player_info:get_wielded_item() 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 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 return not player_faction:has_permission(player, "claim") and player_faction.power > 0. and not parcel_faction.is_admin
end end
-- no faction -- no faction
if not parcel_faction then if not parcel_faction then
return default_is_protected(pos, player) return default_is_protected(pos, player)
else else
parcel_faction = factions.factions[parcel_faction]
if parcel_faction.name == player_faction then if parcel_faction.name == player_faction then
return not parcel_faction:has_permission(player, "build") return not parcel_faction:has_permission(player, "build")
elseif parcel_faction.attacked_parcels[parcelpos] then -- chunk is being attacked elseif parcel_faction.attacked_parcels[parcelpos] then -- chunk is being attacked