How to execute op level commands for non-op players with command signs?

After learning how to make signs that run commands when you click them, I have relied on them a lot with my Minecraft server. Most of the teleporting stuff and /say stuff use them. They were working for me and the other admins but when a non-OP player tries them, she said they weren't doing anything. Is there any way to fix this or will I just have to switch everything to pressure plates? On other servers that I've played on, teleporting signs work for non-OP players but I assume this is just some plugin.

I've looked up how to give non-op players permissions and how to make non-op players able to use teleporting signs. I found nothing useful. For both, I only found stuff about plugins which is something the other admin and I are struggling to get. Do you know how to do this WITHOUT plugins or are plugins required?


Solution 1:

In vanilla minecraft, the use of scoreboard triggers can allow non OP players to trigger the execution of op level commands. Commands are Minecraft Java Edition is 1.12.2

Setup

Create a trigger objective one time manually:
scoreboard objectives add cmdTrigger trigger

Next you have to enable that trigger to allow players to use it. Create a command block and set it's options to RepeatUnconditionalAlways Active with command:

scoreboard players enable @a cmdTrigger


Command Setup

Now create a chain of two command blocks. This chain will need to be repeated for each command that you want non OP players to run but the scores in the commands will be different.

The first command block is where the OP level command is executed on the behalf of the player. This is accomplished by specifying the cmdTrigger score in the target selector. An example target selector is @a[score_cmdTrigger_min=1,score_cmdTrigger=1]. The first command block needs to check continuously so it is RepeatUnconditionalAlways Active

Some example commands are:

  • Teleport the player somewhere:

    • tp @a[score_cmdTrigger_min=1,score_cmdTrigger=1] <x> <y> <z>
  • Make the player say hello:

    • execute @a[score_cmdTrigger_min=1,score_cmdTrigger=1] ~ ~ ~ say Hello

The second command block resets the cmdTrigger score back to 0 so it will only execute the previous command one time. It is ChainConditionalAlways Active with command:

scoreboard players set @a[score_cmdTrigger_min=1,score_cmdTrigger=1] cmdTrigger 0

Use different cmdTrigger scores to trigger different commands. A second set of commands would use target selector:

@a[score_cmdTrigger_min=2,score_cmdTrigger=2]

Continue with as many chains as you want commands.


Command the player needs to execute

The actual command the player has to execute in order to trigger the OP level command:
/trigger cmdTrigger set <score>

Set the <score> based on the command that you want to execute. The player can manually enter this command in chat and it will succeed. This requires they know what command to type and what each score does.

In your case, this is where you use the command signs to run the trigger commands. You can use this Command Sign Generator to create these signs more easily. Here is an example command that will give you a sign that when placed and clicked, will trigger the first command you have setup:

/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"Run the\"}",Text2:"{\"text\":\"first command\"}",Text4:"{\"text\":\"Click the sign\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger cmdTrigger set 1\"}}"},display:{Name:"Example Sign"}}