Package org.bukkit.metadata
Class MetadataValueAdapter
java.lang.Object
org.bukkit.metadata.MetadataValueAdapter
- All Implemented Interfaces:
MetadataValue
- Direct Known Subclasses:
LazyMetadataValue
public abstract class MetadataValueAdapter extends java.lang.Object implements MetadataValue
Optional base class for facilitating MetadataValue implementations.
This provides all the conversion functions for MetadataValue so that writing an implementation of MetadataValue is as simple as implementing value() and invalidate().
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.ref.WeakReference<Plugin>owningPlugin -
Constructor Summary
Constructors Modifier Constructor Description protectedMetadataValueAdapter(Plugin owningPlugin) -
Method Summary
Modifier and Type Method Description booleanasBoolean()Attempts to convert the value of this metadata item into a boolean.byteasByte()Attempts to convert the value of this metadata item into a byte.doubleasDouble()Attempts to convert the value of this metadata item into a double.floatasFloat()Attempts to convert the value of this metadata item into a float.intasInt()Attempts to convert the value of this metadata item into an int.longasLong()Attempts to convert the value of this metadata item into a long.shortasShort()Attempts to convert the value of this metadata item into a short.java.lang.StringasString()Attempts to convert the value of this metadata item into a string.PlugingetOwningPlugin()Returns thePluginthat created this metadata item.
-
Field Details
-
Constructor Details
-
Method Details
-
getOwningPlugin
Description copied from interface:MetadataValueReturns thePluginthat created this metadata item.- Specified by:
getOwningPluginin interfaceMetadataValue- Returns:
- the plugin that owns this metadata value. This should never be null.
-
asInt
public int asInt()Description copied from interface:MetadataValueAttempts to convert the value of this metadata item into an int.- Specified by:
asIntin interfaceMetadataValue- Returns:
- the value as an int.
-
asFloat
public float asFloat()Description copied from interface:MetadataValueAttempts to convert the value of this metadata item into a float.- Specified by:
asFloatin interfaceMetadataValue- Returns:
- the value as a float.
-
asDouble
public double asDouble()Description copied from interface:MetadataValueAttempts to convert the value of this metadata item into a double.- Specified by:
asDoublein interfaceMetadataValue- Returns:
- the value as a double.
-
asLong
public long asLong()Description copied from interface:MetadataValueAttempts to convert the value of this metadata item into a long.- Specified by:
asLongin interfaceMetadataValue- Returns:
- the value as a long.
-
asShort
public short asShort()Description copied from interface:MetadataValueAttempts to convert the value of this metadata item into a short.- Specified by:
asShortin interfaceMetadataValue- Returns:
- the value as a short.
-
asByte
public byte asByte()Description copied from interface:MetadataValueAttempts to convert the value of this metadata item into a byte.- Specified by:
asBytein interfaceMetadataValue- Returns:
- the value as a byte.
-
asBoolean
public boolean asBoolean()Description copied from interface:MetadataValueAttempts to convert the value of this metadata item into a boolean.- Specified by:
asBooleanin interfaceMetadataValue- Returns:
- the value as a boolean.
-
asString
public java.lang.String asString()Description copied from interface:MetadataValueAttempts to convert the value of this metadata item into a string.- Specified by:
asStringin interfaceMetadataValue- Returns:
- the value as a string.
-