Package com.comphenix.protocol.wrappers
Class LegacyDataWatcher
java.lang.Object
com.comphenix.protocol.wrappers.AbstractWrapper
com.comphenix.protocol.wrappers.LegacyDataWatcher
- All Implemented Interfaces:
IDataWatcher,Iterable<WrappedWatchableObject>
Represents a DataWatcher
-
Field Summary
Fields inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
handle, handleType -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.LegacyDataWatcher(Object handle) Constructs a new DataWatcher wrapper around a NMS handle.LegacyDataWatcher(List<WrappedWatchableObject> objects) Deprecated.LegacyDataWatcher(org.bukkit.entity.Entity entity) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionasMap()Deprecated.voidclear()Deprecated.Clone the content of the current DataWatcher.booleanorg.bukkit.entity.EntityRetrieve the entity associated with this data watcher.Deprecated.getObject(int index) Retrieve a watchable object by index.Retrieve a watchable object by watcher object.getWatchableObject(int index) Gets the item at a given index.Gets a list of the contents of this DataWatcher.inthashCode()booleanhasIndex(int index) Whether or not this DataWatcher has an object at a given index.indexSet()Deprecated.iterator()remove(int index) Removes the item at a given index.removeObject(int index) Deprecated.voidsetEntity(org.bukkit.entity.Entity entity) Set the entity associated with this data watcher.voidsetObject(WrappedDataWatcher.WrappedDataWatcherObject object, WrappedWatchableObject value, boolean update) voidsetObject(WrappedDataWatcher.WrappedDataWatcherObject object, Object value, boolean update) Sets the DataWatcher Item associated with a given watcher object to a new value.intsize()Gets the size of this DataWatcher's contents.toString()Methods inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
getHandle, getHandleType, setHandleMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.comphenix.protocol.wrappers.IDataWatcher
getHandleMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LegacyDataWatcher
Constructs a new DataWatcher wrapper around a NMS handle. The resulting DataWatcher will likely have existing values that can be removed withclear().- Parameters:
handle- DataWatcher handle
-
LegacyDataWatcher
Deprecated.Constructs a new DataWatcher using a fake egg entity. The resulting DataWatcher will not have any keys or values and new ones will have to be added using watcher objects. -
LegacyDataWatcher
Deprecated.Constructs a new DataWatcher using a real entity. The resulting DataWatcher will not have any keys or values and new ones will have to be added using watcher objects.- Parameters:
entity- The entity
-
LegacyDataWatcher
Deprecated.Constructs a new DataWatcher using a fake egg entity and a given list of watchable objects.- Parameters:
objects- The list of objects
-
-
Method Details
-
asMap
Deprecated.Gets the contents of this DataWatcher as a map.- Specified by:
asMapin interfaceIDataWatcher- Returns:
- The contents
-
getIndexes
Deprecated.Gets a set containing the registered indexes.- Specified by:
getIndexesin interfaceIDataWatcher- Returns:
- The set
-
getWatchableObjects
Gets a list of the contents of this DataWatcher.- Specified by:
getWatchableObjectsin interfaceIDataWatcher- Returns:
- The contents
-
iterator
- Specified by:
iteratorin interfaceIterable<WrappedWatchableObject>
-
size
public int size()Gets the size of this DataWatcher's contents.- Specified by:
sizein interfaceIDataWatcher- Returns:
- The size
-
getWatchableObject
Gets the item at a given index.- Specified by:
getWatchableObjectin interfaceIDataWatcher- Parameters:
index- Index to get- Returns:
- The watchable object, or null if none exists
-
removeObject
Deprecated.Renamed toremove(int) -
remove
Removes the item at a given index.- Specified by:
removein interfaceIDataWatcher- Parameters:
index- Index to remove- Returns:
- The previous value, or null if none existed
-
hasIndex
public boolean hasIndex(int index) Whether or not this DataWatcher has an object at a given index.- Specified by:
hasIndexin interfaceIDataWatcher- Parameters:
index- Index to check for- Returns:
- True if it does, false if not
-
indexSet
Deprecated.Returns a set containing all the registered indexes- Returns:
- The set
-
clear
Deprecated.Clears the contents of this DataWatcher. The watcher will be empty after this operation is called.- Specified by:
clearin interfaceIDataWatcher
-
getObject
Retrieve a watchable object by index.- Specified by:
getObjectin interfaceIDataWatcher- Parameters:
index- Index of the object to retrieve.- Returns:
- The watched object or null if it doesn't exist.
-
getObject
Retrieve a watchable object by watcher object.- Specified by:
getObjectin interfaceIDataWatcher- Parameters:
object- The watcher object- Returns:
- The watched object or null if it doesn't exist.
-
setObject
public void setObject(WrappedDataWatcher.WrappedDataWatcherObject object, WrappedWatchableObject value, boolean update) - Specified by:
setObjectin interfaceIDataWatcher- Parameters:
object-value-update-
-
setObject
public void setObject(WrappedDataWatcher.WrappedDataWatcherObject object, Object value, boolean update) Sets the DataWatcher Item associated with a given watcher object to a new value. If there is not already an object at this index, the specified watcher object must have a serializer.- Specified by:
setObjectin interfaceIDataWatcher- Parameters:
object- Associated watcher objectvalue- New value- Throws:
IllegalArgumentException- If the watcher object is null or must have a serializer and does not have one.
-
deepClone
Clone the content of the current DataWatcher.- Specified by:
deepClonein interfaceIDataWatcher- Returns:
- A cloned data watcher.
-
getEntity
public org.bukkit.entity.Entity getEntity()Retrieve the entity associated with this data watcher.- Specified by:
getEntityin interfaceIDataWatcher- Returns:
- The entity, or NULL.
-
setEntity
public void setEntity(org.bukkit.entity.Entity entity) Set the entity associated with this data watcher.- Specified by:
setEntityin interfaceIDataWatcher- Parameters:
entity- - the new entity.
-
equals
- Overrides:
equalsin classAbstractWrapper
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractWrapper
-
toString
- Overrides:
toStringin classAbstractWrapper
-
remove(int)