I am getting jumbled up with this and I might know the answer. How do I make my String[] array increment every time this function is called?
Here is the function code:
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
//The /ticket command
if(cmd.getName().equalsIgnoreCase("ticket")){
//Gets amount of arguments
int size_of_args = args.length;
String ticket = null;
String[] ticket_array;
//Puts ticket into one string to be stored.
for (int i=0; i<=size_of_args; i++){
ticket = ticket + args[i];
}
return true;
} else {return false;}
}
I think I have to do a for loop, but I am very tired and this has been stumping me for quite a while. The function is not complete, so do not mention that I haven't used String commandLabel or CommandSender sender (sorry if that sounds rude). Thanks in advance!
P.S. I do not want to set a value for String[] ticket_array because the amount of tickets made should be as many as there are sent in.
ticketis stored. So the first time the function/method is calledticket_array[0] = ticket;and second timeticket_array[1] = ticket;and etc.