Package de.eldoria.eldoutilities.utils
Class AttributeUtil
java.lang.Object
de.eldoria.eldoutilities.utils.AttributeUtil
Class which holds utility methods to handle and manage attributes.
- Since:
- 1.1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublegetAttributeValue(org.bukkit.entity.LivingEntity entity, org.bukkit.attribute.Attribute attribute) static voidsetAttributeValue(@NotNull org.bukkit.entity.LivingEntity entity, @NotNull org.bukkit.attribute.Attribute attribute, @org.jetbrains.annotations.NotNull double target) Sets theAttributeInstance.getBaseValue()to the value which is required to get the target value onAttributeInstance.getValue()for the requestedAttributestatic voidsetAttributeValue(org.bukkit.attribute.AttributeInstance attribute, double target) Deprecated.static voidsyncAttributeValue(org.bukkit.entity.LivingEntity source, org.bukkit.entity.LivingEntity target, org.bukkit.attribute.Attribute attribute) Syncs to attributes to the same value.
-
Method Details
-
setAttributeValue
@Deprecated public static void setAttributeValue(org.bukkit.attribute.AttributeInstance attribute, double target) throws NullPointerException Deprecated.UsesetAttributeValue(LivingEntity, Attribute, double)for better and safer assignment.Sets theAttributeInstance.getBaseValue()to the value which is required to get the target value onAttributeInstance.getValue()- Parameters:
attribute- attribute to settarget- target value which should be retrieved viaAttributeInstance.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 theAttributeInstance.getBaseValue()to the value which is required to get the target value onAttributeInstance.getValue()for the requestedAttribute- Parameters:
entity- to set the attribute forattribute- attribute type to set if presenttarget- target value which should be retrieved viaAttributeInstance.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
AttributeisAttribute.GENERIC_MAX_HEALTHthe health of the entity health will be set to the new max health value.- Parameters:
source- source of the attributetarget- target of the source attribute valueattribute- attribute to change
-
getAttributeValue
public static double getAttributeValue(org.bukkit.entity.LivingEntity entity, org.bukkit.attribute.Attribute attribute)
-
setAttributeValue(LivingEntity, Attribute, double)for better and safer assignment.