Is it possible to make custom commands in minecraft 1.12? [duplicate]

Solution 1:

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

Setup

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

Create a command block that is RepeatUnconditionalAlways Active with command:

scoreboard players enable @a tpTrigger


Setup Warps

Now create a chain of two command blocks. This chain will need to be repeated for each warp that you want to create but the scores and coordinates in the commands will be changed.

First command block is RepeatUnconditionalAlways Active with command:

tp @a[score_tpTrigger_min=1,score_tpTrigger=1] <x> <y> <z>

Second command block is ChainConditionalAlways Active with command:

scoreboard players set @a[score_tpTrigger_min=1,score_tpTrigger=1] tpTrigger 0

Change <x> <y> <z> in the first command block to the coordinates of your warp. A second set of commands for a different warp would be commands:

tp @a[score_tpTrigger_min=2,score_tpTrigger=2] <x2> <y2> <z2>
scoreboard players set @a[score_tpTrigger_min=2,score_tpTrigger=2] tpTrigger 0

Continue with as many chains as you want warps.


Player Warp Commands

To use the first warp the player would have to use command:
/trigger tpTrigger set 1

To use the second warp the player would have to use command:

/trigger tpTrigger set 2

And so on for all your warps.

You can also use the tellraw command in chat with a clickEvent which causes the player to run those commands. You can use this Tellraw Generator to create them. Here is an example:

/tellraw @a [{"text":"To teleport to spawn:  "},{"text":"[Click Here]","color":"aqua","clickEvent":{"action":"run_command","value":"/trigger tpTrigger set 1"}}]

You can also use command signs which use a clickEvent as well. You could have a hub of signs that sends you to many places. Each place could have a sign that goes back to the hub. You can use this Command Sign Generator to create these signs. Here is an example command that will give you a sign that when placed and clicked, will run the trigger command for the first warp:

/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"Teleport to\"}",Text2:"{\"text\":\"spawn\"}",Text4:"{\"text\":\"Click the sign\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger tpTrigger set 1\"}}"},display:{Name:"Custom Sign"}}