public class WrappedDataWatcher
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected net.minecraft.server.DataWatcher |
handle |
Constructor and Description |
---|
WrappedDataWatcher()
Initialize a new data watcher.
|
WrappedDataWatcher(net.minecraft.server.DataWatcher handle)
Create a wrapper for a given data watcher.
|
WrappedDataWatcher(java.util.List<WrappedWatchableObject> watchableObjects)
Create a new data watcher from a list of watchable objects.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Byte |
getByte(int index)
Get a watched byte.
|
WrappedChunkCoordinate |
getChunkCoordinate(int index)
Get a watched string.
|
static WrappedDataWatcher |
getEntityWatcher(org.bukkit.entity.Entity entity)
Retrieve the data watcher associated with an entity.
|
java.lang.Float |
getFloat(int index)
Get a watched float.
|
net.minecraft.server.DataWatcher |
getHandle()
Retrieves the underlying data watcher.
|
java.lang.Integer |
getInteger(int index)
Get a watched integer.
|
org.bukkit.inventory.ItemStack |
getItemStack(int index)
Get a watched string.
|
java.lang.Object |
getObject(int index)
Retrieve a watchable object by index.
|
protected java.util.concurrent.locks.ReadWriteLock |
getReadWriteLock()
Retrieve the current read write lock.
|
java.lang.Short |
getShort(int index)
Get a watched short.
|
java.lang.String |
getString(int index)
Get a watched string.
|
static java.lang.Class<?> |
getTypeClass(int id)
Retrieve the type of a given ID, if it's allowed to be watched.
|
static java.lang.Integer |
getTypeID(java.lang.Class<?> clazz)
Retrieve the ID of a given type, if it's allowed to be watched.
|
protected java.util.Map<java.lang.Integer,java.lang.Object> |
getWatchableObjectMap()
Retrieve the underlying map of key values that stores watchable objects.
|
java.util.List<WrappedWatchableObject> |
getWatchableObjects()
Retrieve every watchable object in this watcher.
|
java.util.Set<java.lang.Integer> |
indexSet()
Retrieve a copy of every index associated with a watched object.
|
void |
setObject(int index,
java.lang.Object newValue)
Set a watched byte.
|
void |
setObject(int index,
java.lang.Object newValue,
boolean update)
Set a watched byte.
|
int |
size()
Retrieve the number of watched objects.
|
public WrappedDataWatcher()
FieldAccessException
- If we're unable to wrap a DataWatcher.public WrappedDataWatcher(net.minecraft.server.DataWatcher handle)
handle
- - the data watcher to wrap.FieldAccessException
- If we're unable to wrap a DataWatcher.public WrappedDataWatcher(java.util.List<WrappedWatchableObject> watchableObjects) throws FieldAccessException
watchableObjects
- - list of watchable objects that will be copied.FieldAccessException
- Unable to read watchable objects.public net.minecraft.server.DataWatcher getHandle()
public static java.lang.Integer getTypeID(java.lang.Class<?> clazz) throws FieldAccessException
FieldAccessException
- If we cannot initialize the reflection machinery.public static java.lang.Class<?> getTypeClass(int id) throws FieldAccessException
FieldAccessException
- If we cannot initialize the reflection machinery.public java.lang.Byte getByte(int index) throws FieldAccessException
index
- - index of the watched byte.FieldAccessException
- Cannot read underlying field.public java.lang.Short getShort(int index) throws FieldAccessException
index
- - index of the watched short.FieldAccessException
- Cannot read underlying field.public java.lang.Integer getInteger(int index) throws FieldAccessException
index
- - index of the watched integer.FieldAccessException
- Cannot read underlying field.public java.lang.Float getFloat(int index) throws FieldAccessException
index
- - index of the watched float.FieldAccessException
- Cannot read underlying field.public java.lang.String getString(int index) throws FieldAccessException
index
- - index of the watched string.FieldAccessException
- Cannot read underlying field.public org.bukkit.inventory.ItemStack getItemStack(int index) throws FieldAccessException
index
- - index of the watched string.FieldAccessException
- Cannot read underlying field.public WrappedChunkCoordinate getChunkCoordinate(int index) throws FieldAccessException
index
- - index of the watched string.FieldAccessException
- Cannot read underlying field.public java.lang.Object getObject(int index) throws FieldAccessException
index
- - index of the object to retrieve.FieldAccessException
- Cannot read underlying field.public java.util.List<WrappedWatchableObject> getWatchableObjects() throws FieldAccessException
FieldAccessException
- If reflection failed.public java.util.Set<java.lang.Integer> indexSet() throws FieldAccessException
FieldAccessException
- If we're unable to read the underlying object.public int size() throws FieldAccessException
FieldAccessException
- If we're unable to read the underlying object.public void setObject(int index, java.lang.Object newValue) throws FieldAccessException
index
- - index of the watched byte.newValue
- - the new watched value.FieldAccessException
- Cannot read underlying field.public void setObject(int index, java.lang.Object newValue, boolean update) throws FieldAccessException
index
- - index of the watched byte.newValue
- - the new watched value.update
- - whether or not to refresh every listening clients.FieldAccessException
- Cannot read underlying field.protected java.util.concurrent.locks.ReadWriteLock getReadWriteLock() throws FieldAccessException
FieldAccessException
- If we're unable to read the underlying field.protected java.util.Map<java.lang.Integer,java.lang.Object> getWatchableObjectMap() throws FieldAccessException
FieldAccessException
- If we don't have permission to perform reflection.public static WrappedDataWatcher getEntityWatcher(org.bukkit.entity.Entity entity) throws FieldAccessException
entity
- - the entity to read from.FieldAccessException
- Reflection failed.