Hello! I am working on a reporting plugin that saves the name of the reported player and the reason why. so in the text file it would look like this...
<player_name>: <reason>
<player_name2>: <reason2>
and so on...
I was watching the tutorial Data Storage - Banning Plugin, and I just need help on how to add the reason to the file and make it work as an argument.
Please help!
Reading more then one argument
Re: Reading more then one argument
Well you reason would be every argument after the first one, so if the command is
[syntax=text]/ban wide_load not being very nice[/syntax]
to get the string "not being very nice" you would need to join together all of the argument except the first one which is the name
something like this could work.
[syntax=java]StringBuilder builder = new StringBuilder();
builder.append(args[1]);
for (int i = 2; i < args.length; ++i){
builder.append(' ');
builder.append(args[i]);
}
String reason = builder.toString();[/syntax]
[syntax=text]/ban wide_load not being very nice[/syntax]
to get the string "not being very nice" you would need to join together all of the argument except the first one which is the name
something like this could work.
[syntax=java]StringBuilder builder = new StringBuilder();
builder.append(args[1]);
for (int i = 2; i < args.length; ++i){
builder.append(' ');
builder.append(args[i]);
}
String reason = builder.toString();[/syntax]
Re: Reading more then one argument
Oh great! thank you very much! i will probably be back for more help later!
Re: Reading more then one argument
odogollie wrote:Oh great! thank you very much! i will probably be back for more help later!
No problem