Essential Commands

Essential Commands

108k Downloads

Partial mod imcompatibility with Command Aliases

pahanakun opened this issue · 4 comments

commented

most of my aliases and redirects and what not with Essential-Commands work fine, but I'm having an issue with setting warps in a particular way.

I'd like to make setting a single warp as a perk for the highest player rank in the server. I thought I'd go about this by giving them permission only to run the command /warp set {playername} so that they'd only be able to set one warp, with the same name as their player name. Something like this

	{
		"commandMode": "COMMAND_ALIAS",
		"command": "warpset",
		"execution": [
			{
				"command": "execute as {this::SELF} run warp set {this::SELF}",
				"type": "SERVER"
			}
		]
	}

This command works fine from another player with op, or the server console (replacing {this::SELF} with a players name of course). It doesn't do anything, even return an error, when executing it using the alias /warpset. The rest of the entry works fine, I can replace "warp set {this::SELF}" with "say test {this::SELF}" and it executes perfectly fine.

I can even set it to just
"command": "warp set test",
and it refuses to create a warp named test.

commented

I don't fully understand the magic that CommandAliases does behind the scenes, but I managed to get this working like so:

      {
        "commandMode": "COMMAND_CUSTOM",
        "customCommand": {
          "parent": "warpset",
          "type": "literal",
          "permission": 1,
          "message": "Warp '$executor_name()' set.'",
          "actions": [
            {
              "command": "execute as $executor_name() run warp set $executor_name()",
              "commandType": "SERVER"
            }
          ]
        }
      }

While I'm here, I also managed to get setting arbitrary warps to work, in case this is useful:

      {
        "commandMode": "COMMAND_CUSTOM",
        "customCommand": {
          "parent": "warpset",
          "type": "literal",
          "permission": 1,
          "message": "/warpset <warp_name>",
          "children": [
            {
              "child": "warp_name",
              "type": "argument",
              "argumentType": "minecraft:greedy_string",
              "actions": [
                {
                  "command": "execute as $executor_name() run warp set {{warp_name}}",
                  "commandType": "SERVER"
                }
              ]
            }
          ]
        }
      }
commented

Worth noting, for your specific use-case, I'm not 100% sure the permissions validation you're looking for exists currently... Let me know if you can get the result you want with this method. There is a possibility I might have to add some additional logic to the mod itself, though.

commented

this works perfectly, thank you so much!

commented

Happy to hear it! Thanks for the update