From 335d9a3eddcb590c3ca5de9cba9b152e5e560af1 Mon Sep 17 00:00:00 2001
From: Vanessa Ezekowitz <vanessaezekowitz@gmail.com>
Date: Tue, 13 Feb 2018 14:05:34 -0500
Subject: removed boost_cart and carbone_mobs -- too many crashes updated blox,
 homedecor, plantlifed, cottages, farming_redo, framedglass, gloopblocks,
 mesecons, moreblocks, moretrees, pipeworks, player_textures, replacer,
 signs_lib, stained_glass, technic, travelnet, unified_inventory, unifieddyes,
 and worldedit.

---
 replacer/check_owner.lua | 17 ++++++++++++-----
 replacer/init.lua        | 38 +++++++++++++++++++++++++++++++++++---
 2 files changed, 47 insertions(+), 8 deletions(-)

(limited to 'replacer')

diff --git a/replacer/check_owner.lua b/replacer/check_owner.lua
index f8e843f..6a63f69 100644
--- a/replacer/check_owner.lua
+++ b/replacer/check_owner.lua
@@ -2,15 +2,22 @@
 -- see http://forum.minetest.net/viewtopic.php?pid=26061 or https://github.com/VanessaE/homedecor for details!
 function replacer_homedecor_node_is_owned(pos, placer)
 
-	if type( minetest.is_protected == "function") then
-		return minetest.is_protected( pos, placer:get_player_name() );
+	if( not( placer ) or not(pos )) then
+		return true;
+	end
+	local pname = placer:get_player_name();
+	if (type( minetest.is_protected ) == "function") then
+		local res = minetest.is_protected( pos, pname );
+		if( res ) then
+			minetest.chat_send_player( pname, "Cannot replace node. It is protected." );
+		end
+		return res;
 	end
-
 
         local ownername = false
         if type(IsPlayerNodeOwner) == "function" then                                   -- node_ownership mod
                 if HasOwner(pos, placer) then                                           -- returns true if the node is owned
-                        if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
+                        if not IsPlayerNodeOwner(pos, pname) then
                                 if type(getLastOwner) == "function" then                -- ...is an old version
                                         ownername = getLastOwner(pos)
                                 elseif type(GetNodeOwnerName) == "function" then        -- ...is a recent version
@@ -28,7 +35,7 @@ function replacer_homedecor_node_is_owned(pos, placer)
         end
 
         if ownername ~= false then
-                minetest.chat_send_player( placer:get_player_name(), "Sorry, "..ownername.." owns that spot." )
+                minetest.chat_send_player( pname, "Sorry, "..ownername.." owns that spot." )
                 return true
         else
                 return false
diff --git a/replacer/init.lua b/replacer/init.lua
index e8216c2..ddb7478 100644
--- a/replacer/init.lua
+++ b/replacer/init.lua
@@ -21,6 +21,10 @@
 -- Version 3.0
 
 -- Changelog: 
+-- 09.12.2017 * Got rid of outdated minetest.env
+--            * Fixed error in protection function.
+--            * Fixed minor bugs.
+--            * Added blacklist
 -- 02.10.2014 * Some more improvements for inspect-tool. Added craft-guide.
 -- 01.10.2014 * Added inspect-tool.
 -- 12.01.2013 * If digging the node was unsuccessful, then the replacement will now fail
@@ -38,6 +42,19 @@ dofile(minetest.get_modpath("replacer").."/check_owner.lua");
 
 replacer = {};
 
+replacer.blacklist = {};
+
+-- playing with tnt and creative building are usually contradictory
+-- (except when doing large-scale landscaping in singleplayer)
+replacer.blacklist[ "tnt:boom"] = true;
+replacer.blacklist[ "tnt:gunpowder"] = true;
+replacer.blacklist[ "tnt:gunpowder_burning"] = true;
+replacer.blacklist[ "tnt:tnt"] = true;
+
+-- prevent accidental replacement of your protector
+replacer.blacklist[ "protector:protect"] = true;
+replacer.blacklist[ "protector:protect2"] = true;
+
 -- adds a tool for inspecting nodes and entities
 dofile(minetest.get_modpath("replacer").."/inspect.lua");
 
@@ -158,6 +175,18 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
           return nil;
        end
 
+       if( node.name and node.name ~= "" and replacer.blacklist[ node.name ]) then
+          minetest.chat_send_player( name, "Replacing blocks of the type '"..( node.name or "?" )..
+		"' is not allowed on this server. Replacement failed.");
+          return nil;
+       end
+
+       if( replacer.blacklist[ daten[1] ]) then
+          minetest.chat_send_player( name, "Placing blocks of the type '"..( daten[1] or "?" )..
+		"' with the replacer is not allowed on this server. Replacement failed.");
+          return nil;
+       end
+
        -- do not replace if there is nothing to be done
        if( node.name == daten[1] ) then
 
@@ -170,11 +199,12 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
        end
 
 
-       -- in survival mode, the player has to provide the node he wants to be placed
-       if( not(minetest.setting_getbool("creative_mode") )) then
+       -- in survival mode, the player has to provide the node he wants to place
+       if( not(minetest.setting_getbool("creative_mode") )
+	  and not( minetest.check_player_privs( name, {creative=true}))) then
  
           -- players usually don't carry dirt_with_grass around; it's safe to assume normal dirt here
-          -- fortionately, dirt and dirt_with_grass does not make use of rotation
+          -- fortunately, dirt and dirt_with_grass does not make use of rotation
           if( daten[1] == "default:dirt_with_grass" ) then
              daten[1] = "default:dirt";
              item["metadata"] = "default:dirt 0 0";
@@ -195,6 +225,8 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
             and node.name ~= "ignore"
             and node.name ~= "default:lava_source" 
             and node.name ~= "default:lava_flowing"
+	    and node.name ~= "default:river_water_source"
+	    and node.name ~= "default:river_water_flowing"
             and node.name ~= "default:water_source"
             and node.name ~= "default:water_flowing" ) then
 
-- 
cgit v1.2.3