I'm making a TeamSpeak3 ServerQuery bot, command line style. I already have the commands down, but what I can't seem to wrap my head around is the arguments to a command. I use a reset() method to create a List of arguments so combining the string(s) would be easier.
For example, say I change a setting in memory for my bot name
set query name "Kyles Bot"
But the program takes "Kyles and Bot" as two different arguments. I want them as one. How would I go about doing this?
Fields needed for reset():
// Keep String[] and 3 strings null for now, they'll be changed.
private String command, to1, to2;
private String[] to3;
private List<String> args = new ArrayList<>();
The reset() method:
private void reset() {
args.clear();
to1 = line.getText();
command = to1.split(" ")[0];
if (to1.split(" ").length > 1) {
to2 = to1.substring(command.length() + 1, to1.length());
to3 = to2.split(" ");
for (int i = 0; i < to3.length; i++) {
if (to3[i].isEmpty() || to3[i].startsWith(" ")) {
System.out.println("Argument null, command cancelled. [" + to3[i] + "]");
break;
} else {
args.add(to3[i]);
}
}
//EDIT2: Removed useless for loop,
//it was my previous attempt to solve the problem.
} else {
//EDIT: This loop here is used to prevent AIOUB
command = to1;
for (int i = 0; i < 5; i++) {
args.add("NullElement");
}
}
}