FlashyReese / CommandAliases

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

Please help #30

Closed kdbhu closed 2 years ago

kdbhu commented 2 years ago

Can somebody help me why this isn't working??

{
    "commandMode": "COMMAND_CUSTOM",
    "customCommand": {
      "parent": "test",
      "type": "literal",
      "permission": 0,
      "children": [
        {
          "child": "name",
          "type": "argument",
          "argumentType": "minecraft:word",
          "suggestionProvider": {
            "suggestionMode": "DATABASE_STARTS_WITH",
            "suggestion": "farms.suggestions"
          },
          "permisssion": 0,
          "actions": [
            {
              "message": "execute in $get_database_value(farm.{{name}}.dimension) run player {{name}} spawn at $get_database_value(farm.{{name}}.position)",
              "requireSuccess": true
            }
          ]
        }
      ]
    }
  },
  {
    "commandMode": "COMMAND_ALIAS",
    "aliasCommand": {
      "command": "asd {arg::minecraft:word#name} {arg::minecraft:dimension#dimension} {arg::minecraft:vec3#position} {arg::minecraft:message#message}",
      "execution": [
        {
          "command": "commandaliases database put farm.suggestions.{{name}} {{name}}",
          "commandType": "SERVER",
          "requireSuccess": true
        },
        {
          "command": "commandaliases database put farm.{{name}}.dimension  {{dimension}}",
          "commandType": "SERVER",
          "requireSuccess": true
        },
        {
          "command": "commandaliases database put farm.{{name}}.position  {{position}}",
          "commandType": "SERVER",
          "requireSuccess": true
        },
        {
          "command": "commandaliases database put farm.{{name}}.message  {{message}}",
          "commandType": "SERVER",
          "requireSuccess": true
        }
      ]
    }
  }
FlashyReese commented 2 years ago

The text you uploaded is missing the array

[
  {
    "commandMode": "COMMAND_CUSTOM",
    "customCommand": {
      "parent": "test",
      "type": "literal",
      "permission": 0,
      "children": [
        {
          "child": "name",
          "type": "argument",
          "argumentType": "minecraft:word",
          "suggestionProvider": {
            "suggestionMode": "DATABASE_STARTS_WITH",
            "suggestion": "farms.suggestions"
          },
          "permission": 0,
          "actions": [
            {
              "command": "execute in $get_database_value(farm.{{name}}.dimension) run player {{name}} spawn at $get_database_value(farm.{{name}}.position)",
              "commandType": "SERVER",
              "requireSuccess": true
            }
          ]
        }
      ]
    }
  },
  {
    "commandMode": "COMMAND_ALIAS",
    "aliasCommand": {
      "command": "asd {arg::minecraft:word#name} {arg::minecraft:dimension#dimension} {arg::minecraft:vec3#position} {arg::minecraft:message#message}",
      "execution": [
        {
          "command": "commandaliases database put farm.suggestions.{{name}} {{name}}",
          "type": "SERVER"
        },
        {
          "command": "commandaliases database put farm.{{name}}.dimension {{dimension}}",
          "type": "SERVER"
        },
        {
          "command": "commandaliases database put farm.{{name}}.position {{position}}",
          "type": "SERVER"
        },
        {
          "command": "commandaliases database put farm.{{name}}.message {{message}}",
          "type": "SERVER"
        }
      ]
    }
  }
]

This command won't execute cause it's only a message "message": "execute in $get_database_value(farm.{{name}}.dimension) run player {{name}} spawn at $get_database_value(farm.{{name}}.position)"

The suggestion provider suggestion should match the keys

"suggestion": "farms.suggestions"

should be instead "suggestion": "farm.suggestions"

There is an extra s in "permisssion": 0,

These commands all have extra space between the key and value.

"command": "commandaliases database put farm.{{name}}.dimension  {{dimension}}",
"command": "commandaliases database put farm.{{name}}.position  {{position}}",
"command": "commandaliases database put farm.{{name}}.message  {{message}}",

The command type is different on COMMAND_ALIAS. You currently have it set to "commandType": "SERVER", but it should be "type": "SERVER", instead. Additionally requireSuccess does not exist in COMMAND_ALIAS.

I highly recommend switching over to COMMAND_CUSTOM, although the format is a bit more verbose, it has more features and solves all the problems with COMMAND_ALIAS. I can assist on Discord more easily if you run into further issues.

Using COMMAND_CUSTOM will look something like this

[
  {
    "commandMode": "COMMAND_CUSTOM",
    "customCommand": {
      "parent": "test",
      "permission": 0,
      "children": [
        {
          "child": "name",
          "type": "argument",
          "argumentType": "minecraft:word",
          "permission": 0,
          "suggestionProvider": {
            "suggestionMode": "DATABASE_STARTS_WITH",
            "suggestion": "farm.suggestions"
          },
          "actions": [
            {
              "command": "execute in $get_database_value(farm.{{name}}.dimension) run player {{name}} spawn at $get_database_value(farm.{{name}}.position)",
              "commandType": "SERVER",
              "requireSuccess": true
            },
            {
              "message": "$get_database_value(farm.{{name}}.message)"
            }
          ]
        }
      ]
    }
  },
  {
    "commandMode": "COMMAND_CUSTOM",
    "customCommand": {
      "parent": "asd",
      "children": [
        {
          "child": "name",
          "type": "argument",
          "argumentType": "minecraft:word",
          "children": [
            {
              "child": "dimension",
              "type": "argument",
              "argumentType": "minecraft:dimension",
              "children": [
                {
                  "child": "position",
                  "type": "argument",
                  "argumentType": "minecraft:vec3",
                  "children": [
                    {
                      "child": "message",
                      "type": "argument",
                      "argumentType": "minecraft:message",
                      "actions": [
                        {
                          "command": "commandaliases database put farm.suggestions.{{name}} {{name}}",
                          "commandType": "SERVER",
                          "requireSuccess": true
                        },
                        {
                          "command": "commandaliases database put farm.{{name}}.dimension {{dimension}}",
                          "commandType": "SERVER",
                          "requireSuccess": true
                        },
                        {
                          "command": "commandaliases database put farm.{{name}}.position {{position}}",
                          "commandType": "SERVER",
                          "requireSuccess": true
                        },
                        {
                          "command": "commandaliases database put farm.{{name}}.message {{message}}",
                          "commandType": "SERVER",
                          "requireSuccess": true
                        },
                        {
                          "message": "Success with {{name}} {{dimension}} {{position}} {{message}}"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  }
]
kdbhu commented 2 years ago

Thanks for your help!