1
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
Thanks,
Ibix13
P.S I'm trying to post on bukkit but it's being a derp when I send the confirmation email
3
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.
I would say use a map instead for the values.
And then save the values if you want to on server shutdown, and regular intervals.
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.
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:
to integrate with a storage file, or what you want to have.
Sorry if I misunderstood the question.
death ++;to integrate with a storage file, or what you want to have.
Sorry if I misunderstood the question.
