Class AttributeUtil

java.lang.Object
de.eldoria.eldoutilities.utils.AttributeUtil

public final class AttributeUtil extends Object
Class which holds utility methods to handle and manage attributes.
Since:
1.1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    getAttributeValue(org.bukkit.entity.LivingEntity entity, org.bukkit.attribute.Attribute attribute)
     
    static void
    setAttributeValue(@NotNull org.bukkit.entity.LivingEntity entity, @NotNull org.bukkit.attribute.Attribute attribute, @org.jetbrains.annotations.NotNull double target)
    Sets the AttributeInstance.getBaseValue() to the value which is required to get the target value on AttributeInstance.getValue() for the requested Attribute
    static void
    setAttributeValue(org.bukkit.attribute.AttributeInstance attribute, double target)
    Deprecated.
    Use setAttributeValue(LivingEntity, Attribute, double) for better and safer assignment.
    static void
    syncAttributeValue(org.bukkit.entity.LivingEntity source, org.bukkit.entity.LivingEntity target, org.bukkit.attribute.Attribute attribute)
    Syncs to attributes to the same value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • setAttributeValue

      @Deprecated public static void setAttributeValue(org.bukkit.attribute.AttributeInstance attribute, double target) throws NullPointerException
      Deprecated.
      Use setAttributeValue(LivingEntity, Attribute, double) for better and safer assignment.
      Sets the AttributeInstance.getBaseValue() to the value which is required to get the target value on AttributeInstance.getValue()
      Parameters:
      attribute - attribute to set
      target - target value which should be retrieved via AttributeInstance.getValue()
      Throws:
      NullPointerException - when the attribute is null
    • setAttributeValue

      public static void setAttributeValue(@NotNull @NotNull org.bukkit.entity.LivingEntity entity, @NotNull @NotNull org.bukkit.attribute.Attribute attribute, @NotNull @org.jetbrains.annotations.NotNull double target)
      Sets the AttributeInstance.getBaseValue() to the value which is required to get the target value on AttributeInstance.getValue() for the requested Attribute
      Parameters:
      entity - to set the attribute for
      attribute - attribute type to set if present
      target - target value which should be retrieved via AttributeInstance.getValue()
    • syncAttributeValue

      public static void syncAttributeValue(org.bukkit.entity.LivingEntity source, org.bukkit.entity.LivingEntity target, org.bukkit.attribute.Attribute attribute)
      Syncs to attributes to the same value.

      If the Attribute is Attribute.GENERIC_MAX_HEALTH the health of the entity health will be set to the new max health value.

      Parameters:
      source - source of the attribute
      target - target of the source attribute value
      attribute - attribute to change
    • getAttributeValue

      public static double getAttributeValue(org.bukkit.entity.LivingEntity entity, org.bukkit.attribute.Attribute attribute)