Reading more then one argument

Any help topics that don't fit in the current categories can go here.
Post Reply
odogollie
Posts: 4
Joined: Wed Jul 04, 2012 7:33 pm

Reading more then one argument

Post 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!
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Reading more then one argument

Post by jacek »

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]
Image
odogollie
Posts: 4
Joined: Wed Jul 04, 2012 7:33 pm

Re: Reading more then one argument

Post by odogollie »

Oh great! thank you very much! i will probably be back for more help later!
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Reading more then one argument

Post by jacek »

odogollie wrote:Oh great! thank you very much! i will probably be back for more help later!

No problem :)
Image
Post Reply