Page 1 of 1

Reading more then one argument

Posted: Thu Jul 05, 2012 11:33 pm
by odogollie
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!

Re: Reading more then one argument

Posted: Fri Jul 06, 2012 4:31 pm
by jacek
Well you reason would be every argument after the first one, so if the command is
/ban wide_load not being very nice
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.
StringBuilder builder = new StringBuilder();
builder.append(args[1]);

for (int i = 2; i < args.length; ++i){
    builder.append(' ');
    builder.append(args);
}

String reason = builder.toString();

Re: Reading more then one argument

Posted: Sat Jul 07, 2012 3:56 am
by odogollie
Oh great! thank you very much! i will probably be back for more help later!

Re: Reading more then one argument

Posted: Sat Jul 07, 2012 5:23 pm
by jacek
odogollie wrote:Oh great! thank you very much! i will probably be back for more help later!
No problem :)