1.16.4 modded args code example

Example: How to make arguments minecraft java

if (alias.equalsIgnoreCase("hello") {
	if (args.length == 0) { //Sender only typed '/hello' and nothing else
		sender.sendMessage("You only typed hello!");
 
	} else { //Sender typed more then 1 argument, so args[0] can't be null.
		if (args[0].equalsIgnoreCase("sir") { //Sender typed '/hello sir'
			sender.sendMessage("You typed hello sir!");
		} else { //Sender had attest 1 argument, but didn't type sir as a second one!
		//args[0] also returns string, so lets send the message right back to them!
			sender.sendMessage("Your first argument was: " + args[0]);
 
	}
}

Tags:

Java Example