Allow: is_protected to work without player param

This commit is contained in:
Coder12a 2019-05-24 14:40:58 -05:00
parent 7fa6abd4aa
commit c8f3528a43
3 changed files with 22 additions and 21 deletions

View File

@ -209,7 +209,7 @@ factions.register_command ("name", {
return false return false
end end
end end
},false) }, false)
factions.register_command ("claim", { factions.register_command ("claim", {
faction_permissions = {"claim"}, faction_permissions = {"claim"},
@ -265,7 +265,7 @@ factions.register_command ("claim", {
factions.claim_help(player, arg_two) factions.claim_help(player, arg_two)
end end
end end
},true) }, true)
factions.register_command("unclaim", { factions.register_command("unclaim", {
faction_permissions = {"claim"}, faction_permissions = {"claim"},
@ -321,7 +321,7 @@ factions.register_command("unclaim", {
factions.unclaim_help(player, arg_two) factions.unclaim_help(player, arg_two)
end end
end end
},true) }, true)
--list all known factions --list all known factions
factions.register_command("list", { factions.register_command("list", {
@ -344,7 +344,7 @@ factions.register_command("list", {
minetest.chat_send_player(player, tosend, false) minetest.chat_send_player(player, tosend, false)
return true return true
end end
},false) }, false)
--show factions mod version --show factions mod version
factions.register_command("version", { factions.register_command("version", {
@ -354,7 +354,7 @@ factions.register_command("version", {
on_success = function(player, faction, pos, parcelpos, args) on_success = function(player, faction, pos, parcelpos, args)
minetest.chat_send_player(player, "factions: version 0.8.8", false) minetest.chat_send_player(player, "factions: version 0.8.8", false)
end end
},false) }, false)
--show description of faction --show description of faction
factions.register_command("info", { factions.register_command("info", {
@ -369,7 +369,7 @@ factions.register_command("info", {
args.factions[1].description, false) args.factions[1].description, false)
return true return true
end end
},false) }, false)
factions.register_command("leave", { factions.register_command("leave", {
description = "Leave your faction", description = "Leave your faction",
@ -379,7 +379,7 @@ factions.register_command("leave", {
factions.remove_player(faction.name, player) factions.remove_player(faction.name, player)
return true return true
end end
},false) }, false)
factions.register_command("kick", { factions.register_command("kick", {
faction_permissions = {"kick"}, faction_permissions = {"kick"},
@ -405,7 +405,7 @@ factions.register_command("kick", {
return false return false
end end
end end
},false) }, false)
--create new faction --create new faction
factions.register_command("create", { factions.register_command("create", {
@ -433,7 +433,7 @@ factions.register_command("create", {
return false return false
end end
end end
},false) }, false)
factions.register_command("join", { factions.register_command("join", {
format = {"faction"}, format = {"faction"},
@ -461,7 +461,7 @@ factions.register_command("join", {
return true return true
end end
},false) }, false)
factions.register_command("disband", { factions.register_command("disband", {
faction_permissions = {"disband"}, faction_permissions = {"disband"},
@ -472,7 +472,7 @@ factions.register_command("disband", {
factions.disband(faction.name) factions.disband(faction.name)
return true return true
end end
},false) }, false)
factions.register_command("flag", { factions.register_command("flag", {
faction_permissions = {"flags"}, faction_permissions = {"flags"},
@ -513,7 +513,7 @@ factions.register_command("flag", {
end end
return true return true
end end
},true) }, true)
factions.register_command("desc", { factions.register_command("desc", {
format = {"string"}, format = {"string"},

View File

@ -4,8 +4,7 @@ minetest.register_on_prejoinplayer(function(name, ip)
factions.player_ips.set(name, ip) factions.player_ips.set(name, ip)
end) end)
minetest.register_on_joinplayer( minetest.register_on_joinplayer(function(player)
function(player)
local name = player:get_player_name() local name = player:get_player_name()
minetest.after(5, createHudfactionLand, player) minetest.after(5, createHudfactionLand, player)
local faction, facname = factions.get_player_faction(name) local faction, facname = factions.get_player_faction(name)
@ -40,8 +39,7 @@ function(player)
end end
) )
minetest.register_on_leaveplayer( minetest.register_on_leaveplayer(function(player)
function(player)
local name = player:get_player_name() local name = player:get_player_name()
local faction, facname = factions.get_player_faction(name) local faction, facname = factions.get_player_faction(name)
local id_name1 = name .. "factionLand" local id_name1 = name .. "factionLand"
@ -69,8 +67,7 @@ minetest.register_on_leaveplayer(
end end
) )
minetest.register_on_respawnplayer( minetest.register_on_respawnplayer(function(player)
function(player)
local name = player:get_player_name() local name = player:get_player_name()
local faction, facname = factions.get_player_faction(name) local faction, facname = factions.get_player_faction(name)
@ -88,8 +85,7 @@ minetest.register_on_respawnplayer(
end end
) )
minetest.register_on_dieplayer( minetest.register_on_dieplayer(function(player)
function(player)
local pname = player:get_player_name() local pname = player:get_player_name()
if on_death[pname] then if on_death[pname] then
return return

View File

@ -9,7 +9,11 @@ minetest.is_protected = function(pos, player)
local parcelpos = factions.get_parcel_pos(pos) local parcelpos = factions.get_parcel_pos(pos)
local parcel_faction, parcel_fac_name = factions.get_parcel_faction(parcelpos) local parcel_faction, parcel_fac_name = factions.get_parcel_faction(parcelpos)
local player_faction, player_fac_name = factions.get_player_faction(player) local player_faction
local player_fac_name
if player then
player_faction, player_fac_name = factions.get_player_faction(player)
end
-- no faction -- no faction
if not parcel_faction then if not parcel_faction then
@ -33,4 +37,5 @@ minetest.is_protected = function(pos, player)
else else
return true return true
end end
return false
end end