What is wrong with this custom command sign? [duplicate]
1. Nested strings
Your command is deeply nested, containing strings within strings. This is why you have to escape (i.e. add a \
) the quotation marks within the Text1
tag. The problem is, that there's an even deeper level of nested strings within the clickEvent:
...\"value\":\"/give @p iron_sword 1 0 {display:{Name:\"Honjo Masamune\",Lore:[\"The Honjo Masamune is the finest sword ever made.\",\"It was created by Masamune,the best swordsmith to ever live\"]},...
When the game reaches Name:\"
it sees the end of the string, instead of the beginning of the new string. This is why it's confused about the "H": It expects a ,
or a }
, since the "value"
tag of the ClickEvent is finished.
To start a new string, you'll have to doubly escape, i.e. Name:\\\"Honjo Masamune\\\"
. The game will then turn \\
and \"
into \
and "
, respectively, and then both into "
.
Don't go fixing your quotation marks just yet though.
2. Your command is too long and requires OP
ClickEvents are executed as if the player had written the command into chat themselves. This includes the character limitation of 100 characters, as well as the permission level (op or not) of the player.
To work around these limitations, the /trigger
command was implemented. Set up a trigger-type objective
/scoreboard objectives add Masamune trigger
Create a repeating/chain command block line enabling all players to use the trigger command for this objective, to give the sword to the player that triggered it:
/scoreboard players enable @a Masamune
/give @a[score_Masamune_min=1] iron_sword 1 0 {display:{Name:"Honjo Masamune",Lore:["The Honjo Masamune is the finest sword ever made.","It was created by Masamune,the best swordsmith to ever live"]},AttributeModifiers:[{AttributeName:"generic.movementSpeed",Name:"generic.movementSpeed",Amount:40,Operation:1,UUIDMost:70725,UUIDLeast:981697},{AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:140,Operation:1,UUIDMost:84742,UUIDLeast:31325}],ench:[{id:0,lvl:120},{id:1,lvl:120},{id:2,lvl:120},{id:3,lvl:120},{id:4,lvl:120},{id:5,lvl:120},{id:6,lvl:120},{id:7,lvl:120},{id:8,lvl:120},{id:16,lvl:120},{id:17,lvl:120},{id:18,lvl:120},{id:19,lvl:120},{id:20,lvl:120},{id:21,lvl:120},{id:32,lvl:120},{id:34,lvl:120},{id:35,lvl:120},{id:48,lvl:120},{id:49,lvl:120},{id:50,lvl:120},{id:51,lvl:120}],HideFlags:7,Unbreakable:1}
/scoreboard players reset @a[score_Masamune_min=1] Masamune
Finally, change the value of your ClickEvent
to
/trigger Masamune set 1