Merge pull request 'Add a server setting to disable command blocks usage' (#1381) from command-block-setting into master

Reviewed-on: MineClone2/MineClone2#1381
This commit is contained in:
AFCMS 2021-03-26 10:54:53 +00:00
commit 35b2bd72f8
8 changed files with 28 additions and 7 deletions

View File

@ -1,6 +1,11 @@
local S = minetest.get_translator("mesecons_commandblock")
local F = minetest.formspec_escape
local color_red = mcl_colors.RED
local command_blocks_activated = minetest.settings:get_bool("mcl_enable_commandblocks", true)
local msg_not_activated = S("Command blocks are not enabled on this server")
local function construct(pos)
local meta = minetest.get_meta(pos)
@ -78,7 +83,7 @@ local function check_commands(commands, player_name)
if string.sub(cmd, 1, 1) == "/" then
msg = S("Error: The command “@1” does not exist; your command block has not been changed. Use the “help” chat command for a list of available commands. Hint: Try to remove the leading slash.", cmd)
end
return false, minetest.colorize("#FF0000", msg)
return false, minetest.colorize(color_red, msg)
end
if player_name then
local player_privs = minetest.get_player_privs(player_name)
@ -86,7 +91,7 @@ local function check_commands(commands, player_name)
for cmd_priv, _ in pairs(cmddef.privs) do
if player_privs[cmd_priv] ~= true then
local msg = S("Error: You have insufficient privileges to use the command “@1” (missing privilege: @2)! The command block has not been changed.", cmd, cmd_priv)
return false, minetest.colorize("#FF0000", msg)
return false, minetest.colorize(color_red, msg)
end
end
end
@ -98,10 +103,15 @@ local function commandblock_action_on(pos, node)
if node.name ~= "mesecons_commandblock:commandblock_off" then
return
end
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
local meta = minetest.get_meta(pos)
local commander = meta:get_string("commander")
if not command_blocks_activated then
--minetest.chat_send_player(commander, msg_not_activated)
return
end
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
local commands = resolve_commands(meta:get_string("commands"), pos)
for _, command in pairs(commands:split("\n")) do
@ -117,7 +127,6 @@ local function commandblock_action_on(pos, node)
return
end
-- Execute command in the name of commander
local commander = meta:get_string("commander")
cmddef.func(commander, param)
end
end
@ -129,6 +138,10 @@ local function commandblock_action_off(pos, node)
end
local on_rightclick = function(pos, node, player, itemstack, pointed_thing)
if not command_blocks_activated then
minetest.chat_send_player(player:get_player_name(), msg_not_activated)
return
end
local can_edit = true
-- Only allow write access in Creative Mode
if not minetest.is_creative_enabled(player:get_player_name()) then

View File

@ -27,3 +27,4 @@ Access denied. You need the “maphack” privilege to edit command blocks.=Zugr
Editing the command block has failed! You can only change the command block in Creative Mode!=Bearbeitung des Befehlsblocks fehlgeschlagen! Sie können den Befehlsblock nur im Kreativmodus ändern!
Editing the command block has failed! The command block is gone.=Bearbeiten des Befehlsblocks fehlgeschlagen! Der Befehlsblock ist verschwunden.
Executes server commands when powered by redstone power=Führt Serverbefehle aus, wenn mit Redstoneenergie versorgt
Command blocks are not enabled on this server=

View File

@ -28,3 +28,4 @@ Example 2:@n give @@n mcl_core:apple 5@nGives the nearest player 5 apples=2.
Access denied. You need the “maphack” privilege to edit command blocks.=Acceso denegado. Necesita el privilegio "maphack" para editar bloques de comandos.
Editing the command block has failed! You can only change the command block in Creative Mode!=¡La edición del bloque de comando ha fallado! ¡Solo puede cambiar el bloque de comandos en modo creativo!
Editing the command block has failed! The command block is gone.=¡La edición del bloque de comando ha fallado! El bloque de comando se ha ido.
Command blocks are not enabled on this server=

View File

@ -27,3 +27,4 @@ Access denied. You need the “maphack” privilege to edit command blocks.=Acc
Editing the command block has failed! You can only change the command block in Creative Mode!=La modification du bloc de commandes a échoué! Vous ne pouvez modifier le bloc de commandes qu'en mode créatif!
Editing the command block has failed! The command block is gone.=La modification du bloc de commandes a échoué! Le bloc de commande a disparu.
Executes server commands when powered by redstone power=Exécute les commandes du serveur lorsqu'il est alimenté par l'alimentation Redstone
Command blocks are not enabled on this server=Les blocks de commandes ne sont pas activés sur ce serveur

View File

@ -27,3 +27,4 @@ Access denied. You need the “maphack” privilege to edit command blocks.=До
Editing the command block has failed! You can only change the command block in Creative Mode!=Попытка редактирования командного блока потерпела неудачу. Вы можете изменять командные блоки только в творческом режиме!
Editing the command block has failed! The command block is gone.=Попытка редактирования командного блока потерпела неудачу. Командный блок исчез.
Executes server commands when powered by redstone power=При подаче энергии редстоуна выполняет серверные команды
Command blocks are not enabled on this server=

View File

@ -27,3 +27,4 @@ Access denied. You need the “maphack” privilege to edit command blocks.=
Editing the command block has failed! You can only change the command block in Creative Mode!=
Editing the command block has failed! The command block is gone.=
Executes server commands when powered by redstone power=
Command blocks are not enabled on this server=

View File

@ -1,3 +1,3 @@
name = mesecons_commandblock
depends = mesecons
depends = mesecons, mcl_colors
optional_depends = doc, doc_items

View File

@ -129,6 +129,9 @@ mcl_superflat_classic (Classic superflat map generation) bool false
# If disabled, no ores will be generated.
mcl_generate_ores (Generate Ores) bool true
# If disabled, command blocks will be unusuable (but still present).
mcl_enable_commandblocks (Enable Command Blocks) bool true
# Make some blocks emit decorative particles like flames. This setting
# specifies the detail level of particles, with higher levels being
# more CPU demanding.