Hey there guys Just need some help figuring out how to integrate an assist system. So I'm thinking we will need to have a sort of hashmap that stores who hits who then compares who gets the kill and then sends the other players some xp. Any ideas would be greatly appreciated!
Maybe you should mind your own business and not post unless you have something valuable to say. I don't think a hash map would be the best idea. Are you thinking of having these assists stored long term? Or at least until disconnect or after a certain time has passed. I'm not great with Bukkit itself so this may not be possible, but I'll give it a shot. Is it possible to actually modify the Player class at all (I know you could extend it, but that would be kind of messy for this application) ? If so, a Hashmap in there would be good. <String, Integer>. Attacker name corresponding to damage dealt. I don't know, consider it.
I was just joking, I know absolutely nothing about programming, and I was just talking to him on Skype too..
Bauer Yeah just short term even for like 30 seconds. Like if a player where to assist with the kill within 30 seconds of the kill then they can be rewarded. I am not concerned about the amount of damage dealt although that would be cool
Suggestion: Map<String, Map<String, DamageEntry>> The outer map stores the damaged player's name as its key and a collection of players that recently damaged the key. The inner map is that collection, with its key being the attacker player names and its value a custom class containing: 1. when the last damage happened 2. (if needed) the damage that the player dealt, this should most likely add up with multiple hits 3. any other funky stuff you want to know (wielded weapon, maybe?) Of course, if you only need the first information, you can go with a Map<String, Long> for the inner map as well. That's basically the structure I would use for that.
Ah, I see. So then you can handle a PlayerDeathEvent to get the internal map for the dead player's name as a key. Then iterate through the keys and use a (fair) formula to hand out exp where due based on the damageEntry associated with each key. Good idea
Didn't know a map as a type parameter was possible. I don't know why I thought that was impossible, because that does seem perfectly acceptable.