summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2020-04-16 13:34:29 -0500
committercheapie <no-email-for-you@example.com>2020-04-16 13:34:29 -0500
commit35fc6cd5e1964487924f5d2fe9007ea26b34edbe (patch)
tree239fcf00ed19700da3e5ac31aee9eb19bd973589
parentc6f3716584877bbdce830144dd9a5280f5eaa67f (diff)
downloadareasprotector-35fc6cd5e1964487924f5d2fe9007ea26b34edbe.tar
areasprotector-35fc6cd5e1964487924f5d2fe9007ea26b34edbe.tar.gz
areasprotector-35fc6cd5e1964487924f5d2fe9007ea26b34edbe.tar.bz2
areasprotector-35fc6cd5e1964487924f5d2fe9007ea26b34edbe.tar.xz
areasprotector-35fc6cd5e1964487924f5d2fe9007ea26b34edbe.zip
Add some basic anti-abuse measures
Protector blocks can no longer be placed within the radius of another protector block (even owned by the same player), and there is now a limit (default 16) on how many protector blocks can be used by one player, independent of any area number limits. Players that are areas administrators (have the "areas" privilege) are exempt from both of these.
-rw-r--r--init.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 041c5e1..82e4a79 100644
--- a/init.lua
+++ b/init.lua
@@ -23,6 +23,8 @@ local radius_small = minetest.settings:get("areasprotector_radius_small")
local height_small = minetest.settings:get("areasprotector_height_small")
or minetest.settings:get("areasprotector_radius_small")
or 7
+
+local max_protectors = minetest.settings:get("areasprotector_max_protectors") or 16
local function remove_display(pos)
local objs = minetest.get_objects_inside_radius(pos, 0.5)
@@ -41,6 +43,26 @@ local function on_place(itemstack, player, pointed, radius, height, sizeword)
minetest.chat_send_player(name,red("You are not allowed to protect that area: ")..err)
return itemstack
end
+ local conflicts = minetest.find_nodes_in_area(pos1,pos2,{"areasprotector:protector_small","areasprotector:protector_large",})
+ if conflicts and #conflicts > 0 and not minetest.check_player_privs(name,"areas") then
+ minetest.chat_send_player(name,red("Another protector block is too close: ").."another protector block was found at "..cyan(minetest.pos_to_string(conflicts[1]))..", and this size of protector block cannot be placed within "..cyan(tostring(radius).."m").." of others.")
+ return itemstack
+ end
+ local userareas = 0
+ for k,v in pairs(areas.areas) do
+ if v.owner == name and string.sub(v.name,1,28) == "Protected by Protector Block" then
+ userareas = userareas + 1
+ end
+ end
+ if userareas >= max_protectors and not minetest.check_player_privs(name,"areas") then
+ minetest.chat_send_player(name,red("You are using too many protector blocks:").." this server allows you to use up to "..cyan(tostring(max_protectors)).." protector blocks, and you already have "..cyan(tostring(userareas))..".")
+ if sizeword == "small" then
+ minetest.chat_send_player(name,"If you need to protect more, please consider using the larger protector blocks, using the chat commands instead, or at the very least taking the time to rename some of your areas to something more descriptive first.")
+ else
+ minetest.chat_send_player(name,"If you need to protect more, please consider using the chat commands instead, or at the very least take the time to rename some of your areas to something more descriptive first.")
+ end
+ return itemstack
+ end
local id = areas:add(name,"Protected by Protector Block at "..minetest.pos_to_string(pos, 0),pos1,pos2)
areas:save()
local msg = string.format("The area from %s to %s has been protected as #%s",cyan(minetest.pos_to_string(pos1)),cyan(minetest.pos_to_string(pos2)),cyan(id))