From 86a18802dc790a9c2cead1466665082223eda41d Mon Sep 17 00:00:00 2001 From: AFCMS <61794590+AFCMS@users.noreply.github.com> Date: Thu, 25 Mar 2021 21:57:07 +0100 Subject: [PATCH 1/7] use proper colors --- mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index c5c3b3dc8a..bbecd07dcb 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -1,6 +1,8 @@ local S = minetest.get_translator("mesecons_commandblock") local F = minetest.formspec_escape +local color_red = mcl_colors.RED + local function construct(pos) local meta = minetest.get_meta(pos) @@ -78,7 +80,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 +88,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 From b9301f12ce1b65fac9d2319bcddab715d449a4be Mon Sep 17 00:00:00 2001 From: AFCMS <61794590+AFCMS@users.noreply.github.com> Date: Thu, 25 Mar 2021 21:59:21 +0100 Subject: [PATCH 2/7] Update mod.conf --- mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf b/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf index 4a743406c7..a35c425f59 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf @@ -1,3 +1,3 @@ name = mesecons_commandblock -depends = mesecons +depends = mesecons, mcl_colors optional_depends = doc, doc_items From e4a6244fddb16be0868f52d366f81b543ae4e160 Mon Sep 17 00:00:00 2001 From: AFCMS <61794590+AFCMS@users.noreply.github.com> Date: Thu, 25 Mar 2021 22:07:38 +0100 Subject: [PATCH 3/7] add basic setting --- mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua | 2 ++ settingtypes.txt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index bbecd07dcb..247a0718b9 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -3,6 +3,8 @@ local F = minetest.formspec_escape local color_red = mcl_colors.RED +local command_blocks_activated = minetest.settings:get_bool("mcl_enable_commandblocks", true) + local function construct(pos) local meta = minetest.get_meta(pos) diff --git a/settingtypes.txt b/settingtypes.txt index af0e18d852..67e686d1eb 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -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. From 8258dae1b80afe2d58a3efd459b9cb0892247404 Mon Sep 17 00:00:00 2001 From: AFCMS <61794590+AFCMS@users.noreply.github.com> Date: Thu, 25 Mar 2021 22:13:37 +0100 Subject: [PATCH 4/7] setting working --- .../REDSTONE/mesecons_commandblock/init.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 247a0718b9..481ed5d6ee 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -4,6 +4,7 @@ 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 activated on the server") --TODO: real mc message and translation local function construct(pos) local meta = minetest.get_meta(pos) @@ -102,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 @@ -121,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 @@ -133,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 From 0e5bbd6d3df2d5332073ff684eb6746bb36eddbc Mon Sep 17 00:00:00 2001 From: AFCMS <61794590+AFCMS@users.noreply.github.com> Date: Fri, 26 Mar 2021 09:57:28 +0100 Subject: [PATCH 5/7] fix msg to be mc like https://www.digminecraft.com/game_commands/enable_command_blocks.php --- mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 481ed5d6ee..58355dafc2 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -4,7 +4,7 @@ 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 activated on the server") --TODO: real mc message and translation +local msg_not_activated = S("Command blocks are not enabled on this server") --TODO: translation local function construct(pos) local meta = minetest.get_meta(pos) From 78bad87a72b0c322ef5b034c393e08c2501cdf98 Mon Sep 17 00:00:00 2001 From: AFCMS <61794590+AFCMS@users.noreply.github.com> Date: Fri, 26 Mar 2021 09:59:58 +0100 Subject: [PATCH 6/7] fix transation --- mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua | 2 +- .../mesecons_commandblock/locale/mesecons_commandblock.de.tr | 1 + .../mesecons_commandblock/locale/mesecons_commandblock.es.tr | 1 + .../mesecons_commandblock/locale/mesecons_commandblock.fr.tr | 1 + .../mesecons_commandblock/locale/mesecons_commandblock.ru.tr | 1 + mods/ITEMS/REDSTONE/mesecons_commandblock/locale/template.txt | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 58355dafc2..4b389090d2 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -4,7 +4,7 @@ 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") --TODO: translation +local msg_not_activated = S("Command blocks are not enabled on this server") local function construct(pos) local meta = minetest.get_meta(pos) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.de.tr b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.de.tr index 9c9b1df1de..a149feef94 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.de.tr +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.de.tr @@ -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= diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.es.tr b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.es.tr index 8826ab9a68..938c710b94 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.es.tr +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.es.tr @@ -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= diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.fr.tr b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.fr.tr index 061ac08a04..b397c979ca 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.fr.tr +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.fr.tr @@ -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 diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.ru.tr b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.ru.tr index 8671099c73..85bed4b95c 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.ru.tr +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/mesecons_commandblock.ru.tr @@ -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= diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/template.txt b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/template.txt index 0e0c3caa52..49e98ef2b0 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/template.txt +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/locale/template.txt @@ -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= From 53d7134437ef11f05506ea1eb7d45dd28dee1bc9 Mon Sep 17 00:00:00 2001 From: AFCMS <61794590+AFCMS@users.noreply.github.com> Date: Fri, 26 Mar 2021 10:00:48 +0100 Subject: [PATCH 7/7] remove unuseful spamming messages --- mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 4b389090d2..1928f809cf 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -108,7 +108,7 @@ local function commandblock_action_on(pos, node) local commander = meta:get_string("commander") if not command_blocks_activated then - minetest.chat_send_player(commander, msg_not_activated) + --minetest.chat_send_player(commander, msg_not_activated) return end minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})