FlashyReese / CommandAliases

Alternate short commands for complex commands
MIT License
26 stars 6 forks source link

@jsonString includes the quotation marks used to mark the string/message #17

Closed taliform closed 2 years ago

taliform commented 3 years ago

See title.

I'm writing a COMMAND_ALIAS for my tellraws. The goal is to have it formatted like so: Name of Sender: Message

It works, but the "Name of Sender" includes the quotation marks when I use @jsonString, so it outputs like this: "Name of Sender": Message

My command is as follows:

    {
        "commandMode": "COMMAND_ALIAS",
        "command": "tr {arg::minecraft:game_profile#Target} {arg::brigadier:string#FromName} {arg::minecraft:color#NameColor} {arg::minecraft:greedy_string#Message}",
        "execution": [
            {
                "command": "tellraw {Target} [\"\",{\"text\":\"{FromName@jsonString}\",\"color\":\"{NameColor}\"},\": {Message@jsonString}\"]",
                "type": "CLIENT"
            }
        ]
    },

So I do it like: /tr @a "Satan" red Welcome to hell!

and it outputs: "Satan": Welcome to hell!

But I want it as: Satan: Welcome to hell!

FlashyReese commented 3 years ago

Brigadier's string - Each string argument type can accept either a single word (no spaces), a quotable phrase (either single word or quoted string), or a greedy phrase (taking the rest of the command as the string argument).

So you can do /tr @a Satan red Welcome to hell! image

You only quote /tr @a "If Satan's name has a space or more" red Welcome to hell! which will results in image

Which is intended behavior from Brigadier. Perhaps I could add a functionality to remove quotes like @removeQuotes. I don't plan on updating COMMAND_ALIAS in the future, if you can you should move over to COMMAND_CUSTOM

taliform commented 3 years ago

Sorry, the quotations were happening yes when the name is in quotations to include spaces. I'm using it to make my NPCs talk, so the names are like "Guard A", "Guard B".

FlashyReese commented 3 years ago

I have added a temporary branch with the @removeDoubleQuotes, you can fetch them from here. This will make it into the next official release but there is a format change.

taliform commented 3 years ago

Thanks! Will try it out. Can you combine 2 or more formatters? Like {message@jsonString@removeDoubleQuotes}?

FlashyReese commented 3 years ago

No(exact reason I'm abandoning COMMAND_ALIAS for COMMAND_CUSTOM), I assume you just want to remove it from the name not the message.

{
   "commandMode":"COMMAND_ALIAS",
   "command":"tr {arg::minecraft:game_profile#Target} {arg::brigadier:string#FromName} {arg::minecraft:color#NameColor} {arg::minecraft:greedy_string#Message}",
   "execution":[
      {
         "command":"tellraw {Target} [\"\",{\"text\":\"{FromName@removeDoubleQuotes}\",\"color\":\"{NameColor}\"},\": {Message@jsonString}\"]",
         "type":"CLIENT"
      }
   ]
}
taliform commented 3 years ago

Just tested it out, @removeDoubleQuotes is working wonders. Finally was able to reduce the length of my tellraws. :) Thanks! Will wait for the next official release.