Keep track of players who damaged mob

Status
This thread has been locked.

Anndrew

Premium
Feedback score
1
Posts
1
Reactions
23
Resources
0
Hello everyone,

I am looking for someone who can help me setup a way to keep track of all players who have damaged a certain mob. One of the plugins I am working for requires me to spawn a mob and keep track of everyone who has attacked it. I have thought of creating a nested Map similar to
Map<Entity, Map<UUID, Double>> damagers = new HashMap<>(). If anyone is able to help please message me on Discord. Payment is possible as well! Thanks guys. This is for Spigot 1.8 as well.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Blbbang

Feedback score
10
Posts
440
Reactions
82
Resources
0
what is the double here?[DOUBLEPOST=1603222295][/DOUBLEPOST]also, dont make a map insid a map

Map<Entity, (Custom class you made, like DamageInfo or idk)
 
Last edited:

Anndrew

Premium
Feedback score
1
Posts
1
Reactions
23
Resources
0
what is the double here?[DOUBLEPOST=1603222295][/DOUBLEPOST]also, dont make a map insid a map

Map<Entity, (Custom class you made, like DamageInfo or idk)

The double would be the amount of damage that they've done to the mob. So each time they damage it, their double value goes up. The only reason I've used a Map to start is thats all I could find when searching up how to do something similar to what I want to do.
 

GabyTM

@gabytm / gabytm.me/discord
Supreme
Feedback score
44
Posts
425
Reactions
191
Resources
6
Map<UUID, DamageInfo> where UUID is the entity UUID and DamageInfo - as Blbbang suggested - is a pair of UUID and Double (damager UUID and damage)
 
Last edited:

Blbbang

Feedback score
10
Posts
440
Reactions
82
Resources
0
The double would be the amount of damage that they've done to the mob. So each time they damage it, their double value goes up. The only reason I've used a Map to start is thats all I could find when searching up how to do something similar to what I want to do.
i dont think the damage can be double
i think thats only an integer
test it
do player.setHp
 

thmihnea

Software Engineer
Supreme
Feedback score
9
Posts
90
Reactions
91
Resources
0
Hello everyone,

I am looking for someone who can help me setup a way to keep track of all players who have damaged a certain mob. One of the plugins I am working for requires me to spawn a mob and keep track of everyone who has attacked it. I have thought of creating a nested Map similar to
Map<Entity, Map<UUID, Double>> damagers = new HashMap<>(). If anyone is able to help please message me on Discord. Payment is possible as well! Thanks guys. This is for Spigot 1.8 as well.
I'd make a custom class and set it up with setters and getters (let's call it DamageStat), and whenever the player joins (or set it up however you want), create a new object of that class and put the player in a hashmap of <UUID, DamageStat>, therefore you will always know which object is assigned to the player. Then just increment a private field in the class whenever they damage the mob and whenever you want to display it just loop through the keySet of the map using a for loop. It should be pretty easy to do, if you need more help pm me.

(also whenever the mob dies, you can display the data, do your thing with it, and then I suggest setting the damage back to 0 for everybody)
 
Last edited:
Status
This thread has been locked.
Top