modify for Survival X server

master
Juraj Vajda 2018-01-06 20:41:57 -05:00
parent a69dc4b0ec
commit efc2addb38
1 changed files with 59 additions and 27 deletions

View File

@ -1,5 +1,6 @@
-- ANTI GRIEF by rnd
-- Copyright 2016 rnd
-- modified by SaKeL for Survival X Server
----------------------------------------------------------------------------
-- This program is free software: you can redistribute it and/or modify
@ -8,7 +9,7 @@
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- but WITHOUT ANY WARRANTY without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
@ -25,59 +26,90 @@
function prevent_place_above(name)
local old_on_place=minetest.registered_craftitems[name];--.on_place;
local old_after_place_node = minetest.registered_nodes[name];--.after_place_node;
local old_on_place = minetest.registered_craftitems[name] -- on_place
local old_after_place_node = minetest.registered_nodes[name] --after_place_node
--after_place_node = func(pos, placer, itemstack, pointed_thing)
if old_on_place and old_on_place.on_place then
old_on_place=old_on_place.on_place;
minetest.registered_craftitems[name].on_place=function(itemstack, placer, pointed_thing)
old_on_place = old_on_place.on_place
minetest.registered_craftitems[name].on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
if pos.y>0 then
minetest.log("action","ANTI GRIEF " .. placer:get_player_name() .. " tried to place " .. name .. " at " .. minetest.pos_to_string(pos));
local placer_name = placer:get_player_name()
local item_name = string.split(itemstack:get_name(), ":")[2]
local max_y = 50 -- water
if string.find(itemstack:get_name(), "lava") then
max_y = 0 -- lava
end
if pos.y > max_y and placer_name ~= "ADMIN" and placer_name ~= "SaKeL" then
minetest.log("action","ANTI GRIEF " .. placer_name .. " tried to place " .. name .. " at " .. minetest.pos_to_string(pos))
minetest.chat_send_player(placer_name, "You can place "..item_name.." only below "..max_y.." blocks")
return itemstack
else
return old_on_place(itemstack, placer, pointed_thing)
end
end
return;
return
end
if old_after_place_node then
old_after_place_node=old_after_place_node.after_place_node
old_after_place_node = old_after_place_node.after_place_node
local table = minetest.registered_nodes[name];
local table = minetest.registered_nodes[name]
local table2 = {}
for i,v in pairs(table) do
table2[i] = v
end
table2.after_place_node=function(pos, placer, itemstack, pointed_thing)
table2.after_place_node = function(pos, placer, itemstack, pointed_thing)
--after_place_node = func(pos, placer, itemstack, pointed_thing)
local pos = pointed_thing.above
if pos.y>0 then
minetest.log("action","ANTI GRIEF " .. placer:get_player_name() .. " tried to place " .. name .. " at " .. minetest.pos_to_string(pos));
minetest.set_node(pos, {name = "air"});
local placer_name = placer:get_player_name()
local item_name = string.split(itemstack:get_name(), ":")[2]
local max_y = 50 -- water
if string.find(itemstack:get_name(), "lava") then
max_y = 0 -- lava
end
if string.find(itemstack:get_name(), "tnt") then
max_y = -150 -- tnt
end
if pos.y > max_y and placer_name ~= "ADMIN" and placer_name ~= "SaKeL" then
minetest.log("action","ANTI GRIEF " .. placer_name .. " tried to place " .. name .. " at " .. minetest.pos_to_string(pos))
minetest.chat_send_player(placer_name, "You can place "..item_name.." only below "..max_y.." blocks")
minetest.set_node(pos, {name = "air"})
return itemstack
end
end
minetest.register_node(":"..name, table2)
return;
return
end
return;
return
end
minetest.after(0,
function ()
prevent_place_above("bucket:bucket_water");
prevent_place_above("default:water_source");
prevent_place_above("bucket:bucket_lava");
prevent_place_above("default:lava_source");
end
)
minetest.after(0, function ()
prevent_place_above("bucket:bucket_water")
prevent_place_above("bucket:bucket_river_water")
-- prevent_place_above("default:water_source")
-- prevent_place_above("default:river_water_source")
prevent_place_above("bucket:bucket_lava")
prevent_place_above("default:lava_source")
prevent_place_above("tnt:tnt")
prevent_place_above("tnt:gunpowder")
end)