From 443614f7045f5cdc8d6fa645c1935705146b1a7e Mon Sep 17 00:00:00 2001 From: Isidor Zeuner Date: Sat, 1 Jul 2017 10:31:46 +0200 Subject: [PATCH] move logic to method --- worldedit_commands/init.lua | 12 ++++++------ worldedit_commands/safe.lua | 13 +++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index a2bb8fb..d00c47c 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -656,7 +656,7 @@ minetest.register_chatcommand("/cylinder", { }) local check_pyramid = function(name, param) - if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then + if area_protection:interaction_restrictions(name) then worldedit.player_notify( name, "check_pyramid not yet supported with area protection" @@ -723,7 +723,7 @@ minetest.register_chatcommand("/spiral", { worldedit.player_notify(name, count .. " nodes added") end, function(name, param) - if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then + if area_protection:interaction_restrictions(name) then worldedit.player_notify( name, "/spiral not yet supported with area protection" @@ -853,7 +853,7 @@ minetest.register_chatcommand("/stack2", { worldedit.stack2(pos1, pos2, {x=x, y=y, z=z}, repetitions, function() worldedit.player_notify(name, count .. " nodes stacked") end) end, function() - if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then + if area_protection:interaction_restrictions(name) then worldedit.player_notify( name, "/stack2 not yet supported with area protection" @@ -885,7 +885,7 @@ minetest.register_chatcommand("/stretch", { worldedit.player_notify(name, count .. " nodes stretched") end, function(name, param) - if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then + if area_protection:interaction_restrictions(name) then worldedit.player_notify( name, "/stretch not yet supported with area protection" @@ -1172,7 +1172,7 @@ minetest.register_chatcommand("/load", { description = "Load nodes from \"(world folder)/schems/[.we[m]]\" with position 1 of the current WorldEdit region as the origin", privs = {worldedit=true}, func = function(name, param) - if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then + if area_protection:interaction_restrictions(name) then worldedit.player_notify( name, "/load not yet supported with area protection" @@ -1295,7 +1295,7 @@ minetest.register_chatcommand("/mtschemplace", { description = "Load nodes from \"(world folder)/schems/.mts\" with position 1 of the current WorldEdit region as the origin", privs = {worldedit=true}, func = function(name, param) - if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then + if area_protection:interaction_restrictions(name) then worldedit.player_notify( name, "/mtschemplace not yet supported with area protection" diff --git a/worldedit_commands/safe.lua b/worldedit_commands/safe.lua index d4ac454..96fa00a 100644 --- a/worldedit_commands/safe.lua +++ b/worldedit_commands/safe.lua @@ -4,6 +4,19 @@ if minetest.get_modpath("areas") then area_protection.areas = areas end +local area_protection.interaction_restrictions = function( + area_protection, + player_name +) + if area_protection.areas then + if minetest.check_player_privs(name, {areas = true}) then + return false + end + return true + end + return false +end + local area_protection.interaction_allowed = function( area_protection, description,