/command arguments syntax highlight

Started by Ondre on

Topic category: Help with MCreator software

Last seen on 15:21, 1. Nov 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
/command arguments syntax highlight

Commands created using Text command preset have no arguments syntax highlighting and says [<arguments>]  what ever you type in it.
Like on screenshot below:

no syntax highlighting

And here is the normal way of argument syntax highlighting:

arguments highlighting is working

So there is any way to make it possible to add arguments highlighting?

Current commands don't have…
Thu, 10/07/2021 - 20:35

Current commands don't have a real argument support. It is only a single argument where you cant get a word. This is why you see <argument>(it's the name Klemen gave it). It will be fixed with https://github.com/MCreator/MCreator/pull/929

Last seen on 15:21, 1. Nov 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you for reply! I we…
Fri, 10/08/2021 - 00:35

Thank you for reply!
I we looked into command class, and already saw

StringTypeArgument.greedyString()

That getting parsed to get arguments indexes // pretty crutchy implementation))))

So i decided to rewrite that code in to this:

public static void registerCommands(RegisterCommandsEvent event) {
		event.getDispatcher()
				.register(LiteralArgumentBuilder.<CommandSource>literal("testcommand")
						.then(Commands.argument("target", EntityArgument.players())
						.executes(TestcommandCommand::execute))
						.executes(TestcommandCommand::execute));
	}

Well i get a good result

working syntax highlighting

I don't quite sure why there is 2 same .executes() in generated code, but in source references only one.
Then i decided to change function to highlight number after player name:

public static void registerCommands(RegisterCommandsEvent event) {
		event.getDispatcher()
				.register(LiteralArgumentBuilder.<CommandSource>literal("testcommand")
						.then(Commands.argument("target", EntityArgument.players())
						.then(Commands.argument( "value", DoubleArgumentType.doubleArg()))
						.executes(TestcommandCommand::execute))
						.executes(TestcommandCommand::execute));
	}

(int also not working)

command brakes

Do you have any ideas what is wrong?

Last seen on 15:21, 1. Nov 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
public static void…
Fri, 10/08/2021 - 00:40
public static void registerCommands(RegisterCommandsEvent event) {
		event.getDispatcher()
		.register(LiteralArgumentBuilder.<CommandSource>literal("testcommand")
		.then(Commands.argument("target", EntityArgument.players())
		.executes(TestcommandCommand::execute))
		.executes(TestcommandCommand::execute));
	}

 

public static void registerCommands(RegisterCommandsEvent event) {
		event.getDispatcher()
		.register(LiteralArgumentBuilder.<CommandSource>literal("testcommand")
		.then(Commands.argument("target", EntityArgument.players())
		.then(Commands.argument( "value", DoubleArgumentType.doubleArg()))
		.executes(TestcommandCommand::execute))
		.executes(TestcommandCommand::execute));
	}