mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2025-07-04 17:10:36 +02:00
Check privs not just during registration of chatcommands
Creative mode could change while the server is running.
This commit is contained in:
@ -9,20 +9,30 @@ minetest.after(0, function()
|
||||
--worldedit privilege is permission to edit everything
|
||||
end)
|
||||
|
||||
--this is privs={worldedit=this()} within chatcommands that actually change land
|
||||
--(should be the same functions as safe_region)
|
||||
function worldedit.priv()
|
||||
if not PROTECTION_MOD_EXISTS or not minetest.setting_getbool("creative_mode") then
|
||||
--I wanted this function to directly choose the privileges for the chat command, but it only applies once.
|
||||
--privs={worldedit=true [, server=true]}
|
||||
--privs={worldedit=worldedit.priv() [, server=true]}
|
||||
--instead, I had to wrap the rest of func = .
|
||||
function worldedit.privs(func)
|
||||
if not minetest.setting_getbool("creative_mode") or not PROTECTION_MOD_EXISTS then
|
||||
--no protection mod, or not the kind of world where people can just create nodes out of thin air,
|
||||
--worldedit privilege means editing anywhere
|
||||
return true
|
||||
if minetest.check_player_privs(name, {worldedit=true}) then
|
||||
func(name, param)
|
||||
else
|
||||
return
|
||||
end
|
||||
else
|
||||
--protection mod, can edit inside your area without worldedit privilege
|
||||
--(worldedit and areas let you edit in no-man's land and other-owned area)
|
||||
func(name, param)
|
||||
end
|
||||
--protection mod, can edit inside your area without worldedit privilege
|
||||
--(worldedit and areas let you edit in no-man's land and other-owned area)
|
||||
return false
|
||||
end
|
||||
|
||||
function worldedit.can_edit_volume(name)
|
||||
--this is... within chatcommands that actually change land
|
||||
--(should be the same functions as safe_region)
|
||||
--also check for permission when region is set?
|
||||
function worldedit.can_edit_volume(name, pos1, pos2)
|
||||
--old you-can-worldedit-everything behaviour
|
||||
if not PROTECTION_MOD_EXISTS then
|
||||
--then if you were able to run this command, then you have the worldedit privilege.
|
||||
@ -35,18 +45,20 @@ function worldedit.can_edit_volume(name)
|
||||
return true
|
||||
end
|
||||
|
||||
--[[I need to use a special per-command region (think /stack, or even worse, /move), the same one safe_region uses, but corner points instead of count... instead of a for loop interpolating between pos1 and pos2]]--
|
||||
|
||||
--all-or-nothing here
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
--pos1, pos2 = worldedit.sort_pos(pos1, pos2) --does this matter?
|
||||
for i in area:iterp(pos1, pos2) do
|
||||
--[[
|
||||
THIS SECTION IGNORES the distinction of area that is owned by someone else, but still editable
|
||||
this is treated as area owned by the editor, or no-man's land depending on if it's shared with one person or everyone
|
||||
|
||||
--THIS SECTION IGNORES the distinction of area that is owned by someone else, but still editable
|
||||
--this is treated as area owned by the editor, or no-man's land depending on if it's shared with one person or everyone
|
||||
--
|
||||
--If it was treated differently (it's not), then single edits would not be able to cross the border between someone else's editable land, and no-man's land, to prevent accidental writes. It may cross the border between multiple people's editable land (or should it?), such as to create a bridge between two skyscrapers that were previously built separately.
|
||||
--
|
||||
--This needs testing for the other changes first.
|
||||
If it was treated differently (it's not), then single edits would not be able to cross the border between someone else's editable land, and no-man's land, to prevent accidental writes. It may cross the border between multiple people's editable land (or should it?), such as to create a bridge between two skyscrapers that were previously built separately.
|
||||
|
||||
This needs testing for the other changes first.
|
||||
--]]
|
||||
--Is it owned?
|
||||
if minetest.is_protected(i) then
|
||||
--Is it someone else's?
|
||||
|
Reference in New Issue
Block a user