Add Attribute and AttributeModifier API.

Thanks to __0x277F and Meeh on #spigot-dev for implementation advice.

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2016-03-01 08:30:03 +11:00
parent 128ff503e9
commit 95de3820b4
5 changed files with 229 additions and 1 deletions

View File

@@ -0,0 +1,60 @@
package org.bukkit.attribute;
import java.util.Collection;
/**
* Represents a mutable instance of an attribute and its associated modifiers
* and values.
*/
public interface AttributeInstance {
/**
* The attribute pertaining to this instance.
*
* @return the attribute
*/
Attribute getAttribute();
/**
* Base value of this instance before modifiers are applied.
*
* @return base value
*/
double getBaseValue();
/**
* Set the base value of this instance.
*
* @param value new base value
*/
void setBaseValue(double value);
/**
* Get all modifiers present on this instance.
*
* @return
*/
Collection<AttributeModifier> getModifiers();
/**
* Add a modifier to this instance.
*
* @param modifier to add
*/
void addModifier(AttributeModifier modifier);
/**
* Remove a modifier from this instance.
*
* @param modifier to remove
*/
void removeModifier(AttributeModifier modifier);
/**
* Get the value of this instance after all associated modifiers have been
* applied.
*
* @return the total attribute value
*/
double getValue();
}