Class DamageHistory

java.lang.Object
com.ninjaguild.dragoneggdrop.dragon.DamageHistory

public class DamageHistory
extends Object
Represents a recordable history of damage for an entity.
Author:
Parker Hawke - Choco
  • Method Details

    • getEntityUUID

      public UUID getEntityUUID()
      Get the UUID of the entity to which this damage history belongs.
      Returns:
      the belonging entity's UUID
      See Also:
      getEntity()
    • getEntity

      public org.bukkit.entity.Entity getEntity()
      Get the Entity instance to which this damage history belongs. Note that internally this makes a call to Bukkit.getEntity(UUID) on getEntityUUID(). Therefore this may return null! One should take caution in using the result of this method without first checking for nullability.
      Returns:
      the belonging entity
      See Also:
      getEntityUUID()
    • getTotalDamageFrom

      public double getTotalDamageFrom​(org.bukkit.entity.Entity entity)
      Get the total amount of damage caused by the specified entity.
      Parameters:
      entity - the entity whose damage to retrieve
      Returns:
      the amount of damage caused by the entity
    • getTotalDamageFrom

      public double getTotalDamageFrom​(UUID uuid)
      Get the total amount of damage caused by the specified entity's UUID.
      Parameters:
      uuid - the UUID of the entity whose damage to retrieve
      Returns:
      the amount of damage caused by the entity
    • getTopDamager

      public DamageHistory.DamageEntry getTopDamager()
      Get the entity that caused the most amount of damage to this entity. This comes paired with the amount of total damage done.
      Returns:
      the top damager
    • getTopDamager

      public DamageHistory.DamageEntry getTopDamager​(int offset)
      Get the top damager at the given offset (from most amount of damage + offset). For example, if fetching at the offset of 1, the second top damager will be retrieved. If offset of 2, third most. So on and so forth. Offset 0 would be equivalent to getTopDamager().
      Parameters:
      offset - the damage entry offset. Must be < uniqueDamagers()
      Returns:
      the top damager at the given offset
    • getTopDamagers

      public DamageHistory.DamageEntry[] getTopDamagers​(int amount)
      Get an array of entities that caused the most amount of damage to this entity in order of most amount of damage (first index) to least amount of damage (last index). This comes paired with the amount of total damage done by each entity.

      If more damagers are queried than is available, the resulting array will fill as much as it can after which point null will be used to represent unrecorded or unavailable data.

      Parameters:
      amount - the amount of damagers to retrieve. Must be greater than 0
      Returns:
      the top x damagers
    • recordDamage

      public void recordDamage​(org.bukkit.entity.Entity source, double damage)
      Record damage to this history.
      Parameters:
      source - the damage's source entity
      damage - the damage to record
    • getMostRecentDamage

      public DamageHistory.DamageEntry getMostRecentDamage()
      Get the most recent damage entry to this history.
      Returns:
      the most recent damage. null if no damage has been recorded
    • getMostRecentDamage

      public DamageHistory.DamageEntry getMostRecentDamage​(int offset)
      Get the damage entry at the given offset (from most recent + offset). For example, if fetching at the offset of 1, the second most recent damage will be retrieved. If offset of 2, third most. So on and so forth. Offset 0 would be equivalent to getMostRecentDamage().
      Parameters:
      offset - the damage entry offset. Must be < size()
      Returns:
      the damage entry at the given offset
    • size

      public int size()
      Get the amount of history recorded by this record.
      Returns:
      the history size
    • uniqueDamagers

      public int uniqueDamagers()
      Get the amount of unique damagers recorded by this history.
      Returns:
      the amount of unique damagers
    • clearTotalDamage

      public void clearTotalDamage()
      Reset all total damage from all entities in this history to zero.
    • clearDamageHistory

      public void clearDamageHistory()
      Clear all damage history from this history.
    • clear

      public void clear()
      Clear all total damage and damage history from this history. This is equivalent to calling both clearTotalDamage() and clearDamageHistory().
    • forEntity

      public static DamageHistory forEntity​(UUID uuid)
      Get the DamageHistory associated with the given entity UUID. This method will never return null.
      Parameters:
      uuid - the entity whose history to get
      Returns:
      the entity's damage history
    • forEntity

      public static DamageHistory forEntity​(org.bukkit.entity.Entity entity)
      Get the DamageHistory associated with the given entity. This method will never return null.
      Parameters:
      entity - the entity whose history to get
      Returns:
      the entity's damage history
    • clearGlobalDamageHistory

      public static void clearGlobalDamageHistory()
      Clear all damage history from all entities.