Files
Bukkit/src/main/java/org/bukkit/metadata/MetadataValue.java
mbax a2566bfc3e Updated null checks in MetadataStoreBase. Fixes BUKKIT-1412
Previously, the method could be called with a null MetadataStore and stored.
In later execution null pointer exceptions would be generated when checking
for the plugin that the set Metadata belongs to.

Additionally, places where a plugin is referenced will now throw an
IllegalArgumentException if specified plugin is null. Using null would be an
obvious logical flaw, and in some cases produce additional exceptions later
in execution.
2012-08-26 22:09:21 -05:00

74 lines
1.8 KiB
Java

package org.bukkit.metadata;
import org.bukkit.plugin.Plugin;
public interface MetadataValue {
/**
* Fetches the value of this metadata item.
*
* @return the metadata value.
*/
public Object value();
/**
* Attempts to convert the value of this metadata item into an int.
* @return the value as an int.
*/
public int asInt();
/**
* Attempts to convert the value of this metadata item into a float.
* @return the value as a float.
*/
public float asFloat();
/**
* Attempts to convert the value of this metadata item into a double.
* @return the value as a double.
*/
public double asDouble();
/**
* Attempts to convert the value of this metadata item into a long.
* @return the value as a long.
*/
public long asLong();
/**
* Attempts to convert the value of this metadata item into a short.
* @return the value as a short.
*/
public short asShort();
/**
* Attempts to convert the value of this metadata item into a byte.
* @return the value as a byte.
*/
public byte asByte();
/**
* Attempts to convert the value of this metadata item into a boolean.
* @return the value as a boolean.
*/
public boolean asBoolean();
/**
* Attempts to convert the value of this metadata item into a string.
* @return the value as a string.
*/
public String asString();
/**
* Returns the {@link Plugin} that created this metadata item.
*
* @return the plugin that owns this metadata value. This should never be null.
*/
public Plugin getOwningPlugin();
/**
* Invalidates this metadata item, forcing it to recompute when next accessed.
*/
public void invalidate();
}