From c8f3528a438a15dceb0aff4ba0e92ff756138136 Mon Sep 17 00:00:00 2001 From: Coder12a <38924418+Coder12a@users.noreply.github.com> Date: Fri, 24 May 2019 14:40:58 -0500 Subject: [PATCH] Allow: is_protected to work without player param --- chatcommands.lua | 24 ++++++++++++------------ player_events.lua | 12 ++++-------- protection_override.lua | 7 ++++++- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/chatcommands.lua b/chatcommands.lua index 4349132..7cf0660 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -209,7 +209,7 @@ factions.register_command ("name", { return false end end -},false) +}, false) factions.register_command ("claim", { faction_permissions = {"claim"}, @@ -265,7 +265,7 @@ factions.register_command ("claim", { factions.claim_help(player, arg_two) end end -},true) +}, true) factions.register_command("unclaim", { faction_permissions = {"claim"}, @@ -321,7 +321,7 @@ factions.register_command("unclaim", { factions.unclaim_help(player, arg_two) end end -},true) +}, true) --list all known factions factions.register_command("list", { @@ -344,7 +344,7 @@ factions.register_command("list", { minetest.chat_send_player(player, tosend, false) return true end -},false) +}, false) --show factions mod version factions.register_command("version", { @@ -354,7 +354,7 @@ factions.register_command("version", { on_success = function(player, faction, pos, parcelpos, args) minetest.chat_send_player(player, "factions: version 0.8.8", false) end -},false) +}, false) --show description of faction factions.register_command("info", { @@ -369,7 +369,7 @@ factions.register_command("info", { args.factions[1].description, false) return true end -},false) +}, false) factions.register_command("leave", { description = "Leave your faction", @@ -379,7 +379,7 @@ factions.register_command("leave", { factions.remove_player(faction.name, player) return true end -},false) +}, false) factions.register_command("kick", { faction_permissions = {"kick"}, @@ -405,7 +405,7 @@ factions.register_command("kick", { return false end end -},false) +}, false) --create new faction factions.register_command("create", { @@ -433,7 +433,7 @@ factions.register_command("create", { return false end end -},false) +}, false) factions.register_command("join", { format = {"faction"}, @@ -461,7 +461,7 @@ factions.register_command("join", { return true end -},false) +}, false) factions.register_command("disband", { faction_permissions = {"disband"}, @@ -472,7 +472,7 @@ factions.register_command("disband", { factions.disband(faction.name) return true end -},false) +}, false) factions.register_command("flag", { faction_permissions = {"flags"}, @@ -513,7 +513,7 @@ factions.register_command("flag", { end return true end -},true) +}, true) factions.register_command("desc", { format = {"string"}, diff --git a/player_events.lua b/player_events.lua index c572cff..a81c69d 100644 --- a/player_events.lua +++ b/player_events.lua @@ -4,8 +4,7 @@ minetest.register_on_prejoinplayer(function(name, ip) factions.player_ips.set(name, ip) end) -minetest.register_on_joinplayer( -function(player) +minetest.register_on_joinplayer(function(player) local name = player:get_player_name() minetest.after(5, createHudfactionLand, player) local faction, facname = factions.get_player_faction(name) @@ -40,8 +39,7 @@ function(player) end ) -minetest.register_on_leaveplayer( - function(player) +minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() local faction, facname = factions.get_player_faction(name) local id_name1 = name .. "factionLand" @@ -69,8 +67,7 @@ minetest.register_on_leaveplayer( end ) -minetest.register_on_respawnplayer( - function(player) +minetest.register_on_respawnplayer(function(player) local name = player:get_player_name() local faction, facname = factions.get_player_faction(name) @@ -88,8 +85,7 @@ minetest.register_on_respawnplayer( end ) -minetest.register_on_dieplayer( -function(player) +minetest.register_on_dieplayer(function(player) local pname = player:get_player_name() if on_death[pname] then return diff --git a/protection_override.lua b/protection_override.lua index 2c9db80..9ce96e8 100644 --- a/protection_override.lua +++ b/protection_override.lua @@ -9,7 +9,11 @@ minetest.is_protected = function(pos, player) local parcelpos = factions.get_parcel_pos(pos) 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 if not parcel_faction then @@ -33,4 +37,5 @@ minetest.is_protected = function(pos, player) else return true end + return false end