MobDamage

Discussion in 'Spigot Plugin Development' started by harveycat1, May 25, 2017.

  1. Anyone know a good way for collecting who did the most damage to a unlimited health giant zombie
     
    • Like Like x 1
  2. Maybe you can do a map like this
    Code (Text):
    Map<LivingEntity,Map<UUID,Double>> damage;
    In which you save for the giant is being killed the UUID of all players with the damage they are dealing (summing every time a damage is done). Finally, when the giant dies, order the second map based on who dealt the biggest damage and you are done

    EDIT: Remember to remove the value for the dead giant at the end if you don't want memory leaks
     
    • Agree Agree x 1
  3. that might work i basically got to make a giant that is say alive for 2minutes and check for does most damage to it
     
    • Like Like x 1
  4. Well, then spawn the mob using the World#spawnEntity method. Start a BukkitRunnable with 2-minute delay. Add the entity you spawn inside the map and then track all the damage your players are doing in the map
     
    • Agree Agree x 1
  5. Spawn that giant then run a runnable to remove it after 2 minutes .
    Create a HashMap<UUID , Double>
    Check damage event , if the entity (victim ) is the Giant , put the player in the map then keep sum it ,
    after that you can loop thought the map and get values
     
    • Like Like x 1
  6. Make onentiydemagenyentity Event Check if its your gigant use getDemage to know the demage and Use getDemager Check if its a Player and add him or Update his demage Value.