From 39cd62a2217f620b9e8fc83b891183cd0c2160c3 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Wed, 8 Apr 2020 12:40:52 +0100 Subject: [PATCH 1/7] add protector_hurt delay to fix drop issue --- init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index e67f35a..f8b8e21 100644 --- a/init.lua +++ b/init.lua @@ -293,7 +293,11 @@ function minetest.is_protected(pos, digger) -- hurt player if protection violated if protector_hurt > 0 and player:get_hp() > 0 then - player:set_hp(player:get_hp() - protector_hurt) + + -- This delay fixes item duplication bug (thanks luk3yx) + minetest.after(0.1, function() + player:set_hp(player:get_hp() - protector_hurt) + end) end -- flip player when protection violated From db932e676c687b32386077c20f273171ad2a8d10 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sat, 25 Apr 2020 09:02:46 +0100 Subject: [PATCH 2/7] added playerfactions support, protecor_hud_interval and settings update --- README.md | 1 + depends.txt | 1 + hud.lua | 6 +++++- init.lua | 29 +++++++++++++++++++++++++++++ settingtypes.txt | 26 ++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 settingtypes.txt diff --git a/README.md b/README.md index 9c79d39..009779e 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Change log: - 2.7 - Remove protection field entity when protector has been dug - 2.8 - Added 'protector_show_interval' setting to minetest.conf [default is 5], make protection field glow in dark. - 2.9 - Added MineClone2 recipes for protection block but no official support as yet +- 3.0 - Added PlayerFactions support, 'protector_hud_interval' setting and listing in advanced settings for mod values. Lucky Blocks: 10 diff --git a/depends.txt b/depends.txt index f1e9655..5b09c28 100644 --- a/depends.txt +++ b/depends.txt @@ -2,3 +2,4 @@ default? intllib? lucky_block? mesecons_mvps? +playerfactions? diff --git a/hud.lua b/hud.lua index 7a334f3..6b70e71 100644 --- a/hud.lua +++ b/hud.lua @@ -3,12 +3,14 @@ local S = protector.intllib local radius = (tonumber(minetest.setting_get("protector_radius")) or 5) local hud = {} local hud_timer = 0 +local hud_interval = (tonumber(minetest.setting_get("protector_hud_interval")) or 5) +if hud_interval > 0 then minetest.register_globalstep(function(dtime) -- every 5 seconds hud_timer = hud_timer + dtime - if hud_timer < 5 then + if hud_timer < hud_interval then return end hud_timer = 0 @@ -57,3 +59,5 @@ end) minetest.register_on_leaveplayer(function(player) hud[player:get_player_name()] = nil end) + +end diff --git a/init.lua b/init.lua index f8b8e21..22bff1f 100644 --- a/init.lua +++ b/init.lua @@ -13,6 +13,8 @@ local MP = minetest.get_modpath(minetest.get_current_modname()) local S = dofile(MP .. "/intllib.lua") local F = minetest.formspec_escape +-- Load support for factions +local factions_available = minetest.global_exists("factions") protector = { mod = "redo", @@ -58,6 +60,15 @@ end -- check for member name local is_member = function (meta, name) + if factions_available + and meta:get_int("faction_members") == 1 + and factions.get_player_faction(name) ~= nil + and factions.get_player_faction(meta:get_string("owner")) == + factions.get_player_faction(name) then + + return true + end + for _, n in pairs(get_member_list(meta)) do if n == name then @@ -129,6 +140,19 @@ local protector_formspec = function(meta) local npp = protector_max_share_count -- max users added to protector list local i = 0 + if factions_available + and factions.get_player_faction(meta:get_string("owner")) then + + formspec = formspec .. "checkbox[0,5;faction_members;" + .. F(S("Allow faction access")) + .. ";" .. (meta:get_int("faction_members") == 1 and + "true" or "false") .. "]" + + if npp > 8 then + npp = 8 + end + end + for n = 1, #members do if i < npp then @@ -613,6 +637,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return end + -- add faction members + if factions_available then + meta:set_int("faction_members", fields.faction_members == "true" and 1 or 0) + end + -- add member [+] if add_member_input then diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..cbdc11b --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,26 @@ +# Size of protected area around protection node limiting player interaction +protector_radius (Protector Radius) int 5 + +# Flips player around when accessing protected area to stop lag griefing +protector_flip (Protector Flip) bool false + +# Hurts player by amount entered when accessing protected area, 0 to disable +protector_hurt (Protector Hurt) int 0 + +# Sets a protected area around spawn by node radius given +protector_spawn (Protector Spawn) int 0 + +# Enables PVP inside of protected areas +protector_pvp (Protector PVP) bool false + +# When true will allow PVP inside protected spawn area +protector_pvp_spawn (Protector PVP Spawn) int 0 + +# When true will allow PVP inside all protected areas at night time only +protector_night_pvp (Protector Night PVP) bool false + +# Interval in seconds that protection field is shown +protector_show_interval (Protector Show Interval) int 5 + +# Interval in seconds that HUD ownership text is updated, 0 to disable +protector_hud_interval (Protector HUD Interval) int 5 From c147242c7de7a95e55b36526fc18d5c10431914d Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 12 Jun 2020 11:41:33 +0100 Subject: [PATCH 3/7] added /protector_show /protector_hide feature --- README.md | 6 ++++ admin.lua | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- hud.lua | 2 +- init.lua | 2 +- tool.lua | 4 +-- 5 files changed, 106 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 009779e..d40465a 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Change log: - 2.8 - Added 'protector_show_interval' setting to minetest.conf [default is 5], make protection field glow in dark. - 2.9 - Added MineClone2 recipes for protection block but no official support as yet - 3.0 - Added PlayerFactions support, 'protector_hud_interval' setting and listing in advanced settings for mod values. +- 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show Lucky Blocks: 10 @@ -94,6 +95,11 @@ reset name list show protected areas of your nearby protectors (max of 5) + /protector_show_area + + +A players own protection blocks can be hidden and shown using the following: + /protector_hide /protector_show diff --git a/admin.lua b/admin.lua index a6a4964..52d287d 100644 --- a/admin.lua +++ b/admin.lua @@ -68,7 +68,7 @@ minetest.register_chatcommand("protector_replace", { minetest.register_abm({ - nodenames = {"protector:protect", "protector:protect2"}, + nodenames = {"protector:protect", "protector:protect2", "protector:protect_hidden"}, interval = 8, chance = 1, catch_up = false, @@ -112,7 +112,7 @@ minetest.register_abm({ local r = tonumber(minetest.settings:get("protector_radius")) or 5 -- show protection areas of nearby protectors owned by you (thanks agaran) -minetest.register_chatcommand("protector_show", { +minetest.register_chatcommand("protector_show_area", { params = "", description = S("Show protected areas of your nearby protectors"), privs = {}, @@ -125,7 +125,7 @@ minetest.register_chatcommand("protector_show", { local pos = minetest.find_nodes_in_area( {x = pos.x - r, y = pos.y - r, z = pos.z - r}, {x = pos.x + r, y = pos.y + r, z = pos.z + r}, - {"protector:protect", "protector:protect2"}) + {"protector:protect", "protector:protect2", "protector:protect_hidden"}) local meta, owner @@ -141,3 +141,96 @@ minetest.register_chatcommand("protector_show", { end end }) + + +-- ability to hide protection blocks (borrowed from doors mod :) +minetest.register_node("protector:protect_hidden", { + description = "Hidden Protector", + drawtype = "airlike", + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + -- has to be walkable for falling nodes to stop falling + walkable = true, + pointable = false, + diggable = false, + buildable_to = false, + floodable = false, + drop = "", + groups = {not_in_creative_inventory = 1, unbreakable = 1}, + on_blast = function() end, + -- 1px block inside door hinge near node top + collision_box = { + type = "fixed", + fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32}, + }, +}) + + +minetest.register_chatcommand("protector_show", { + params = "", + description = "Hide protection blocks", + privs = {interact = true}, + + func = function(name, param) + + local player = minetest.get_player_by_name(name) + + if not player then + return false, "Player not found" + end + + local pos = player:get_pos() + + local a = minetest.find_nodes_in_area( + {x = pos.x - r, y = pos.y - r, z = pos.z - r}, + {x = pos.x + r, y = pos.y + r, z = pos.z + r}, + {"protector:protect_hidden"}) + + local meta, owner + + for _, row in pairs(a) do + + meta = minetest.get_meta(row) + owner = meta:get_string("owner") or "" + + if owner == name then + minetest.swap_node(row, {name = "protector:protect"}) + end + end + end +}) + +minetest.register_chatcommand("protector_hide", { + params = "", + description = "Hide protection blocks", + privs = {interact = true}, + + func = function(name, param) + + local player = minetest.get_player_by_name(name) + + if not player then + return false, "Player not found" + end + + local pos = player:get_pos() + + local a = minetest.find_nodes_in_area( + {x = pos.x - r, y = pos.y - r, z = pos.z - r}, + {x = pos.x + r, y = pos.y + r, z = pos.z + r}, + {"protector:protect", "protector:protect2"}) + + local meta, owner + + for _, row in pairs(a) do + + meta = minetest.get_meta(row) + owner = meta:get_string("owner") or "" + + if owner == name then + minetest.swap_node(row, {name = "protector:protect_hidden"}) + end + end + end +}) diff --git a/hud.lua b/hud.lua index 6b70e71..9b78afa 100644 --- a/hud.lua +++ b/hud.lua @@ -24,7 +24,7 @@ minetest.register_globalstep(function(dtime) local protectors = minetest.find_nodes_in_area( {x = pos.x - radius , y = pos.y - radius , z = pos.z - radius}, {x = pos.x + radius , y = pos.y + radius , z = pos.z + radius}, - {"protector:protect","protector:protect2"}) + {"protector:protect","protector:protect2", "protector:protect_hidden"}) if #protectors > 0 then local npos = protectors[1] diff --git a/init.lua b/init.lua index 22bff1f..93ec483 100644 --- a/init.lua +++ b/init.lua @@ -244,7 +244,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel) local pos = minetest.find_nodes_in_area( {x = pos.x - r, y = pos.y - r, z = pos.z - r}, {x = pos.x + r, y = pos.y + r, z = pos.z + r}, - {"protector:protect", "protector:protect2"}) + {"protector:protect", "protector:protect2", "protector:protect_hidden"}) local meta, owner, members diff --git a/tool.lua b/tool.lua index 575d1d0..41b385d 100644 --- a/tool.lua +++ b/tool.lua @@ -19,7 +19,7 @@ minetest.register_craftitem("protector:tool", { local pos = user:get_pos() local pp = minetest.find_nodes_in_area( vector.subtract(pos, 2), vector.add(pos, 2), - {"protector:protect", "protector:protect2"}) + {"protector:protect", "protector:protect2", "protector:protect_hidden"}) if #pp == 0 then return end -- none found @@ -67,7 +67,7 @@ minetest.register_craftitem("protector:tool", { -- does a protector already exist ? if #minetest.find_nodes_in_area( vector.subtract(pos, 1), vector.add(pos, 1), - {"protector:protect", "protector:protect2"}) > 0 then + {"protector:protect", "protector:protect2", "protector:protect_hidden"}) > 0 then minetest.chat_send_player(name, S("Protector already in place!")) From f4beba6cf6496c4b844ed7eb8db1e997433ac117 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 12 Jun 2020 12:27:33 +0100 Subject: [PATCH 4/7] add protection bypass check to new commands --- admin.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/admin.lua b/admin.lua index 52d287d..77059e5 100644 --- a/admin.lua +++ b/admin.lua @@ -135,7 +135,8 @@ minetest.register_chatcommand("protector_show_area", { meta = minetest.get_meta(pos[n]) owner = meta:get_string("owner") or "" - if owner == name then + if owner == name + or minetest.check_player_privs(name, {protection_bypass = true}) then minetest.add_entity(pos[n], "protector:display") end end @@ -194,7 +195,8 @@ minetest.register_chatcommand("protector_show", { meta = minetest.get_meta(row) owner = meta:get_string("owner") or "" - if owner == name then + if owner == name + or minetest.check_player_privs(name, {protection_bypass = true}) then minetest.swap_node(row, {name = "protector:protect"}) end end @@ -228,7 +230,8 @@ minetest.register_chatcommand("protector_hide", { meta = minetest.get_meta(row) owner = meta:get_string("owner") or "" - if owner == name then + if owner == name + or minetest.check_player_privs(name, {protection_bypass = true}) then minetest.swap_node(row, {name = "protector:protect_hidden"}) end end From 76c926dadc4fa41d0a7c5a3d77920560a26cec41 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 12 Jun 2020 14:12:06 +0100 Subject: [PATCH 5/7] intllib support for new command descriptions --- admin.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin.lua b/admin.lua index 77059e5..ad1afce 100644 --- a/admin.lua +++ b/admin.lua @@ -170,7 +170,7 @@ minetest.register_node("protector:protect_hidden", { minetest.register_chatcommand("protector_show", { params = "", - description = "Hide protection blocks", + description = S("Show your nearby protection blocks"), privs = {interact = true}, func = function(name, param) @@ -205,7 +205,7 @@ minetest.register_chatcommand("protector_show", { minetest.register_chatcommand("protector_hide", { params = "", - description = "Hide protection blocks", + description = S("Hide your nearby protection blocks"), privs = {interact = true}, func = function(name, param) From 8ec273febd75165932c3a1fa02eaef3a5fb0535e Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 12 Jun 2020 21:11:54 +0100 Subject: [PATCH 6/7] added italian locale (thanks Hamlet) --- README.md | 2 +- locale/it.po | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 locale/it.po diff --git a/README.md b/README.md index d40465a..f3a3cc2 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Change log: - 2.8 - Added 'protector_show_interval' setting to minetest.conf [default is 5], make protection field glow in dark. - 2.9 - Added MineClone2 recipes for protection block but no official support as yet - 3.0 - Added PlayerFactions support, 'protector_hud_interval' setting and listing in advanced settings for mod values. -- 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show +- 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show , italian local added (thanks Hamlet) Lucky Blocks: 10 diff --git a/locale/it.po b/locale/it.po new file mode 100644 index 0000000..97145f4 --- /dev/null +++ b/locale/it.po @@ -0,0 +1,180 @@ +# Italian translation for PROTECTOR MOD. +# Copyright (C) 2020 Hamlet +# This file is distributed under the same license as the PROTECTOR MOD package. +# Xanthin , 2016. +# CodeXP , 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PROTECTOR MOD\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-10 17:33+0200\n" +"PO-Revision-Date: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.2.1\n" +"Last-Translator: Hamlet \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: it\n" + +#: admin.lua +msgid "Remove Protectors around players (separate names with spaces)" +msgstr "Elimina i protettori attorno ai giocatori (separa i nomi con gli spazi)" + +#: admin.lua +msgid "" +msgstr "" + +#: admin.lua +msgid "Replace Protector Owner with name provided" +msgstr "Sostituisci il proprietario del protettore col nome fornito" + +#: admin.lua +msgid " " +msgstr " " + +#: admin.lua +msgid "Replacing Protector name '@1' with '@2'" +msgstr "Sostituzione del nome del protettore '@1' con '@2'" + +#: admin.lua +msgid "Show protected areas of your nearby protectors" +msgstr "Mostra le aree protette dei protettori vicino a te" + +#: admin.lua +msgid "Protector Names to remove: @1" +msgstr "Nomi dei protettori da eliminare: @1" + +#: admin.lua +msgid "Name List Reset" +msgstr "Azzera l'elenco dei nomi" + +#: doors_chest.lua +msgid "Protected Wooden Door" +msgstr "Porta di legno protetta" + +#: doors_chest.lua +msgid "Protected Steel Door" +msgstr "Porta d'acciaio protetta" + +#: doors_chest.lua +msgid "Protected Trapdoor" +msgstr "Botola protetta" + +#: doors_chest.lua +msgid "Protected Steel Trapdoor" +msgstr "Botola d'acciaio protetta" + +#: doors_chest.lua +msgid "Protected Chest" +msgstr "Baule protetto" + +#: doors_chest.lua +msgid "To Chest" +msgstr "Al baule" + +#: doors_chest.lua +msgid "To Inventory" +msgstr "All'inventario" + +#: doors_chest.lua +msgid "Protected Chest (@1)" +msgstr "Baule protetto (@1)" + +#: init.lua +msgid "-- Protector interface --" +msgstr "-- Interfaccia protettore --" + +#: init.lua +msgid "PUNCH node to show protected area" +msgstr "COLPISCI il nodo per mostrare l'area protetta" + +#: init.lua +msgid "USE for area check" +msgstr "USA per controllare l'area" + +#: init.lua +msgid "Members:" +msgstr "Membri:" + +#: init.lua +msgid "Close" +msgstr "Chiudi" + +#: init.lua +msgid "Protection located at: @1" +msgstr "Protezione collocata a: @1" + +#: init.lua +msgid "Members: @1." +msgstr "Membri: @1." + +#: init.lua +msgid "This area is not protected." +msgstr "Quest'area non è protetta." + +#: init.lua +msgid "You can build here." +msgstr "Qui puoi costruire." + +#: init.lua tool.lua +msgid "Overlaps into above players protected area" +msgstr "Si sovrappone ad un'area sovrastante protetta dai giocatori" + +#: init.lua +msgid "Protection Block" +msgstr "Blocco di protezione" + +#: admin.lua init.lua tool.lua +msgid "Protection (owned by @1)" +msgstr "Protezione (di proprietà di @1)" + +#: init.lua +msgid "Protection Logo" +msgstr "Logo di protezione" + +#: init.lua +msgid "[MOD] Protector Redo loaded" +msgstr "[MOD] Protector Redo caricato" + +#: init.lua +msgid "Spawn @1 has been protected up to a @2 block radius." +msgstr "Lo spawn @1 è stato protetto fino a un raggio di @2 blocchi." + +#: init.lua +msgid "This area is owned by @1" +msgstr "Quest'area è di proprietà di @1" + +#: pvp.lua +msgid "[Protector] on_punchplayer called with nil objects" +msgstr "[Protector] on_punchplayer chiamato con oggetti nil" + +#: pvp.lua +msgid "[Protector] pvp_protect not active, update your version of Minetest" +msgstr "[Protector] pvp_protect non attiva, aggiorna la tua versione di Minetest" + +#: pvp.lua +msgid "[Protector] pvp_protect is disabled" +msgstr "[Protector] pvp_protect è disattivato" + +#: hud.lua +msgid "Owner: @1" +msgstr "Proprietario: @1" + +#: tool.lua +msgid "Protector Placer Tool (stand near protector, face direction and use)" +msgstr "Strumento di posizionamento protettore (stai vicino al protettore, guarda la direzione e usa)" + +#: tool.lua +msgid "Protector already in place!" +msgstr "Protettore già presente!" + +#: tool.lua +msgid "No protectors available to place!" +msgstr "Nessun protettore disponibile da posizionare!" + +#: tool.lua +msgid "Protector placed at @1" +msgstr "Protettore posizionato a @1" \ No newline at end of file From 969a6dd37c559aeda598024afba8237ab910ec74 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Fri, 26 Jun 2020 08:28:33 +0200 Subject: [PATCH 7/7] add factions to luacheckrc --- .luacheckrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index a5b19ab..22f87d3 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -21,5 +21,6 @@ read_globals = { "intllib", "mesecon", "screwdriver", - "lucky_block" + "lucky_block", + "factions" }