Hello guys, it's not really a problem i have creating a plugin but i was wondering how to get args[0] until i reach args[5] .. like e.x /me hello world blah blah blah..|| I want to get "hello world blah blah blah" anyone that can help with this?
I'm a little unsure by what you mean, but are you asking about how to loop through the arguments? You could do the following ... Code:java for(int i = 0; i <= 5; i++){args[ i ] // This would be the argument as a String.// Continue your code.} By the looks of it, do you want to check if an argument is equal to a specific String? You would do it like so: Code:java if(args[0].equals("world")) // and you may continue your code from there.
Code:java String msg = ""; //string msgfor (String part : args) { //loops through the arguments of command if (msg != "") msg += " "; //msg will add spaces message += part; //puts the arguments in the message string} I think this is what you need?
number1_Master & MrTang Thanks for your help but now i need to get args[1] and all others args[0] = players name that's why.
Do not use msg != "", use !(msg.equals("")) Also, use a StringBuilder if you're going to continuously add spaces.