brigadier-ts icon indicating copy to clipboard operation
brigadier-ts copied to clipboard

Execution fails for a command tree with adjacent branches

Open haykam821 opened this issue 1 year ago • 0 comments

With the following command tree, only the first branch with a and b arguments works correctly:

dispatcher.register(literal('foo')
	.then(argument('a', new FloatArgumentType())
		.then(argument('b', new FloatArgumentType())
			.executes(ctx => ctx.get('a') + ctx.get('b'))))
	.then(argument("c", new FloatArgumentType())
		.executes(ctx => ctx.get('c')))
);

In other words:

  • foo 1 2 succeeds
  • foo 1 fails with message Unknown Command at position 5: foo 1<--[HERE]

The argument type seems to not affect the issue. Switching the branches around such that the first branch only has the c argument causes the second branch with a and b arguments to fail.

haykam821 avatar Sep 21 '23 03:09 haykam821