mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 10:31:06 +01:00
Add maphack privilege for advanced blocks like command blocks
This commit is contained in:
parent
5d2df6db4c
commit
3f0bfa0aa8
6 changed files with 82 additions and 5 deletions
|
@ -60,9 +60,7 @@ The following items are interesting for Creative Mode and for adventure
|
|||
map builders. They can not be obtained in-game or in the creative inventory.
|
||||
|
||||
* Barrier: `mcl_core:barrier`
|
||||
* Command Block: `mesecons_commandblock:commandblock_off`
|
||||
* Monster Spawner: `mcl_mobspawners:spawner`
|
||||
* Minecart with Command Block: `mcl_minecarts:command_block_minecart`
|
||||
* Minecart with Command Block (does not work yet): `mcl_minecarts:command_block_minecart`
|
||||
|
||||
Use the `/giveme` chat command to obtain them. See the in-game help for
|
||||
an explanation.
|
||||
|
|
|
@ -106,6 +106,11 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
|||
if not minetest.settings:get_bool("creative_mode") then
|
||||
return
|
||||
end
|
||||
local privs = minetest.get_player_privs(player:get_player_name())
|
||||
if not privs.maphack then
|
||||
minetest.chat_send_player(player:get_player_name(), "Access denied. You need the “maphack” privilege to edit command blocks.")
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local commands = meta:get_string("commands")
|
||||
|
@ -118,6 +123,28 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
|||
minetest.show_formspec(player:get_player_name(), "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec)
|
||||
end
|
||||
|
||||
local on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
|
||||
local privs = minetest.get_player_privs(placer:get_player_name())
|
||||
if not privs.maphack then
|
||||
minetest.chat_send_player(placer:get_player_name(), "Placement denied. You need the “maphack” privilege to place command blocks.")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_commandblock:commandblock_off", {
|
||||
description = "Command Block",
|
||||
|
||||
|
@ -134,11 +161,12 @@ You can optionally use the following placeholders in your commands:
|
|||
• “@random” is replaced by the name of a random player currently connected]],
|
||||
|
||||
tiles = {{name="jeija_commandblock_off.png", animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=2}}},
|
||||
groups = {creative_breakable=1, mesecon_effector_off=1, not_in_creative_inventory=1},
|
||||
groups = {creative_breakable=1, mesecon_effector_off=1},
|
||||
drop = "",
|
||||
on_blast = function() end,
|
||||
on_construct = construct,
|
||||
is_ground_content = false,
|
||||
on_place = on_place,
|
||||
after_place_node = after_place,
|
||||
on_rightclick = on_rightclick,
|
||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
||||
|
@ -157,6 +185,7 @@ minetest.register_node("mesecons_commandblock:commandblock_on", {
|
|||
on_blast = function() end,
|
||||
on_construct = construct,
|
||||
is_ground_content = false,
|
||||
on_place = on_place,
|
||||
after_place_node = after_place,
|
||||
on_rightclick = on_rightclick,
|
||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
||||
|
@ -173,6 +202,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
if not fields.submit and not fields.doc then
|
||||
return
|
||||
end
|
||||
local privs = minetest.get_player_privs(player:get_player_name())
|
||||
if not privs.maphack then
|
||||
minetest.chat_send_player(player:get_player_name(), "Access denied. You need the “maphack” privilege to edit command blocks.")
|
||||
return
|
||||
end
|
||||
|
||||
if fields.doc and minetest.get_modpath("doc") then
|
||||
doc.show_entry(player:get_player_name(), "nodes", "mesecons_commandblock:commandblock_off", true)
|
||||
return
|
||||
|
|
|
@ -142,6 +142,28 @@ minetest.register_node("mcl_core:barrier", {
|
|||
playername = placer:get_player_name()
|
||||
})
|
||||
end,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
|
||||
local name = placer:get_player_name()
|
||||
local privs = minetest.get_player_privs(name)
|
||||
if not privs.maphack then
|
||||
minetest.chat_send_player(name, "Placement denied. You need the “maphack” privilege to place barriers.")
|
||||
return itemstack
|
||||
end
|
||||
local new_itemstack = minetest.item_place(itemstack, placer, pointed_thing)
|
||||
return new_itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
-- Same as barrier, but non-pointable. This node is only to be used internally to separate realms.
|
||||
|
|
|
@ -216,12 +216,30 @@ minetest.register_node("mcl_mobspawners:spawner", {
|
|||
walkable = true,
|
||||
description = S("Monster Spawner"),
|
||||
_doc_items_longdesc = S("A monster spawner is a block which regularily causes monsters and animals to appear around it."),
|
||||
groups = {pickaxey=1, not_in_creative_inventory = 1, material_stone=1},
|
||||
groups = {pickaxey=1, material_stone=1, deco_block=1},
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
|
||||
-- If placed by player, setup spawner with default settings
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
|
||||
local name = placer:get_player_name()
|
||||
local privs = minetest.get_player_privs(name)
|
||||
if not privs.maphack then
|
||||
minetest.chat_send_player(name, "Placement denied. You need the “maphack” privilege to place monster spawners.")
|
||||
return itemstack
|
||||
end
|
||||
local node_under = minetest.get_node(pointed_thing.under)
|
||||
local new_itemstack, success = minetest.item_place(itemstack, placer, pointed_thing)
|
||||
if success then
|
||||
|
|
1
mods/MISC/mcl_privs/description.txt
Normal file
1
mods/MISC/mcl_privs/description.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Shared privileges in MineClone 2
|
3
mods/MISC/mcl_privs/init.lua
Normal file
3
mods/MISC/mcl_privs/init.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
minetest.register_privilege("maphack", {
|
||||
description = "Can place and use advanced blocks like monster spawners, command blocks and barriers.",
|
||||
})
|
Loading…
Reference in a new issue