From a08ba2bb93d7683b619a0e6b0bf00e3afd614ae4 Mon Sep 17 00:00:00 2001
From: cx384 <cx384@proton.me>
Date: Mon, 22 Jan 2024 18:27:54 +0100
Subject: [PATCH] Get rid of deprecated metadata (#628)

---
 technic/machines/HV/forcefield.lua |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/technic/machines/HV/forcefield.lua b/technic/machines/HV/forcefield.lua
index 7395284..5b8ff4f 100644
--- a/technic/machines/HV/forcefield.lua
+++ b/technic/machines/HV/forcefield.lua
@@ -112,15 +112,24 @@
 	else
 		formspec = formspec.."button[0,1;5,1;mesecon_mode_0;"..S("Controlled by Mesecon Signal").."]"
 	end
+	-- TODO: String replacement with %s will stop working with client-side translations
 	if meta:get_int("enabled") == 0 then
-		formspec = formspec.."button[0,1.75;5,1;enable;"..S("%s Disabled"):format(S("%s Forcefield Emitter"):format("HV")).."]"
+		formspec = formspec.."button[0,1.75;5,1;enable;"..
+			S("%s Disabled"):format(S("%s Forcefield Emitter"):format("HV")).."]"
 	else
-		formspec = formspec.."button[0,1.75;5,1;disable;"..S("%s Enabled"):format(S("%s Forcefield Emitter"):format("HV")).."]"
+		formspec = formspec.."button[0,1.75;5,1;disable;"..
+			S("%s Enabled"):format(S("%s Forcefield Emitter"):format("HV")).."]"
 	end
 	meta:set_string("formspec", formspec)
 end
 
 local forcefield_receive_fields = function(pos, formname, fields, sender)
+	local player_name = sender:get_player_name()
+	if minetest.is_protected(pos, player_name) then
+		minetest.chat_send_player(player_name, "You are not allowed to edit this!")
+		minetest.record_protection_violation(pos, player_name)
+		return
+	end
 	local meta = minetest.get_meta(pos)
 	local range = nil
 	if fields.range then

--
Gitblit v1.8.0