mirror of
git://repo.or.cz/minetest_schemedit.git
synced 2025-01-09 17:40:32 +01:00
Do more strict privilege checks
This commit is contained in:
parent
a639c2b9c0
commit
4199f645f3
34
init.lua
34
init.lua
@ -28,13 +28,15 @@ end
|
|||||||
|
|
||||||
minetest.register_privilege("schemedit")
|
minetest.register_privilege("schemedit")
|
||||||
local NEEDED_PRIV = "schemedit"
|
local NEEDED_PRIV = "schemedit"
|
||||||
local function check_priv(player_name)
|
local function check_priv(player_name, quit)
|
||||||
local privs = minetest.get_player_privs(player_name)
|
local privs = minetest.get_player_privs(player_name)
|
||||||
if privs[NEEDED_PRIV] then
|
if privs[NEEDED_PRIV] then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(player_name, minetest.colorize("red",
|
if not quit then
|
||||||
S("Insufficient privileges! You need the “@1” privilege to use this.", NEEDED_PRIV)))
|
minetest.chat_send_player(player_name, minetest.colorize("red",
|
||||||
|
S("Insufficient privileges! You need the “@1” privilege to use this.", NEEDED_PRIV)))
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -318,7 +320,12 @@ schemedit.add_form("main", {
|
|||||||
return form
|
return form
|
||||||
end,
|
end,
|
||||||
handle = function(self, pos, name, fields)
|
handle = function(self, pos, name, fields)
|
||||||
if not check_priv(name) then
|
if fields.doc then
|
||||||
|
doc.show_entry(name, "nodes", "schemedit:creator", true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not check_priv(name, fields.quit) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -351,11 +358,6 @@ schemedit.add_form("main", {
|
|||||||
meta.schem_name = fields.name
|
meta.schem_name = fields.name
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.doc then
|
|
||||||
doc.show_entry(name, "nodes", "schemedit:creator", true)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Toggle border
|
-- Toggle border
|
||||||
if fields.border then
|
if fields.border then
|
||||||
if meta.schem_border == "true" and schemedit.markers[hashpos] then
|
if meta.schem_border == "true" and schemedit.markers[hashpos] then
|
||||||
@ -575,7 +577,7 @@ schemedit.add_form("slice", {
|
|||||||
return form
|
return form
|
||||||
end,
|
end,
|
||||||
handle = function(self, pos, name, fields)
|
handle = function(self, pos, name, fields)
|
||||||
if not check_priv(name) then
|
if not check_priv(name, fields.quit) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -674,7 +676,7 @@ schemedit.add_form("probtool", {
|
|||||||
return form
|
return form
|
||||||
end,
|
end,
|
||||||
handle = function(self, pos, name, fields)
|
handle = function(self, pos, name, fields)
|
||||||
if not check_priv(name) then
|
if not check_priv(name, fields.quit) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1116,10 +1118,20 @@ S("The node HUD is not updated automatically and may be outdated. The node HUD o
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||||
|
local uname = user:get_player_name()
|
||||||
|
if uname and not check_priv(uname) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
schemedit.clear_displayed_node_probs(user)
|
schemedit.clear_displayed_node_probs(user)
|
||||||
end,
|
end,
|
||||||
-- Set note probability and force_place and enable node probability display
|
-- Set note probability and force_place and enable node probability display
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
local pname = placer:get_player_name()
|
||||||
|
if pname and not check_priv(pname) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Use pointed node's on_rightclick function first, if present
|
-- Use pointed node's on_rightclick function first, if present
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
if placer and not placer:get_player_control().sneak then
|
if placer and not placer:get_player_control().sneak then
|
||||||
|
@ -70,7 +70,7 @@ Main=Grundeinstellungen
|
|||||||
X size:=X-Größe:
|
X size:=X-Größe:
|
||||||
Y size:=Y-Größe:
|
Y size:=Y-Größe:
|
||||||
Z size:=Z-Größe:
|
Z size:=Z-Größe:
|
||||||
Insufficient privileges! You need the “@1” privilege to use this.=Unzureichende Privilegien! Sie benötigen das „@1“-Privileg, um dies tun zu können.
|
Insufficient privileges! You need the “@1” privilege to use this.=Unzureichende Privilegien! Sie benötigen das „@1“-Privileg, um dies benutzen zu können.
|
||||||
Convert .mts schematic file to .lua file (loaded from @1)=„.mts“-Schematicdatei zu „.lua“-Datei konvertieren (geladen von @1)
|
Convert .mts schematic file to .lua file (loaded from @1)=„.mts“-Schematicdatei zu „.lua“-Datei konvertieren (geladen von @1)
|
||||||
<schematic name>[.mts] [comments]=<Schematic-Name>[.mts] [comments]
|
<schematic name>[.mts] [comments]=<Schematic-Name>[.mts] [comments]
|
||||||
Failed.=Fehlgeschlagen.
|
Failed.=Fehlgeschlagen.
|
||||||
|
Loading…
Reference in New Issue
Block a user