1

Need to know how to make stats for a PvP plugin

Ibix13 4/13/13 10:21 pm
44
4/17/2013 12:44 pm
Ok so I've been making a plugin for my PvP server and I need a way to know the kills and deaths of people and their KDR by doing /kdr /kills /death. I have all the kits but I can't do anything else until I can figure out how to make some kind of counter to count kills deaths etc. Please help ASAP!!!
Thanks,
Ibix13
P.S I'm trying to post on bukkit but it's being a derp when I send the confirmation email
Posted by
Ibix13
Level 1 : New Miner
0

  Have something to say?

JoinSign in

3

oggehej
04/17/2013 12:44 pm
Level 18 : Journeyman Toast
int i = killcount.get(p);
killcount.put(p, i++);

Was something like that I meant, but everyone prefer different things, perhaps even MySQL support... But anyway, that's the basics, and you can't escape from that small line.
And also, from past experience, you won't learn anything by just copy/paste something that anyone else did. Of course you could need a little help on the way, like now, but if you're going to make a plugin that, for example, does the same as "World Edit", you won't learn anything by just copy/paste the source into an IDE.
I'm not a pro, but I think everyone could agree with the last I said.
1
Rogue
04/17/2013 11:42 am
Level 12 : Journeyman Crafter
I would say use a map instead for the values.

Map<Player, String> killcount = new HashMap<>();

//PlayerDeathEvent
Player p = e.getPlayer(); // get the proper one for the event
if (killcount.keySet().contains(p)) {
int i = killcount.get(p);
killcount.put(p, i++);
}
else {
killcount.put(p, 1);
}


And then save the values if you want to on server shutdown, and regular intervals.
1
oggehej
04/17/2013 11:01 am
Level 18 : Journeyman Toast
Just listen for the PlayerDeathEvent, and see who died, and if it was by a player, what player it was. Then just make something like this:
death ++;
to integrate with a storage file, or what you want to have.

Sorry if I misunderstood the question.
1

Welcome