You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more of a rolling issue that I'm going to be maintaining and some brain dumping on how certain aspects of Data API (and maybe other aspects of Sponge's systems, like the registry system) should be used.
Table for explaining what methods in DataView to use for what and when
Method
Usage
getContainer()
Used to get the top level container of the current view
get(DataQuery)
Gets a raw Object, whether it's serialized or a DataView or a primitive type is unknown
getView()
Gets a DataView child within this DataView, good for getting nested views for larger complex objects.
getBoolean()
Gets a boolean out of the current DataView
getShort()
Gets a short out of the current DataView
getByte()
Gets a byte out of the current DataView`
getInt()
Gets an int out of the current DataView
getLong()
Gets a long out of the current DataView
getFloat()
Gets a float out of the current DataView
getDouble()
Gets a double out of the current DataView
getString()
Gets a String out of the current DataView
getList()
Gets a List of something out of the current DataView, this would be useful if you're attempting to get complex objects out of this list, such as a list of Maps. Not to be confused with a list of things that are DataSerializable or that are added as DataTranslatable (like UUIDs).
getViewList()
Gets a List of DataViews. Useful for the list of DataViews that are separated from the current parent only by the given List. The path does not function past this point as the DataViews internally are parented only by themselves.
getSerializable()
Gets a DataSerializable out of this DataView. Since DataSerializables are automatically serialized to DataViews upon insertion, the DataSerializable is deserialized from the internal DataView represented by the path as indicated by the DataQuery. Note that certain objects may not be deserializable, such as Entity objects.
getSerializableList()
Gets a list of DataSerializables, follows the limitations of getList() or getViewList().
getObject()
Gets an Object of type T that must have been registered as a DataTranslatable. These types of objects are declared in other libraries, not controlled by Sponge, and as such, cannot be marked as DataSerializable, but have been registered to be serializable by a DataTranslator. Objects such as these are Date, Instance, UUID, etc.
getObjectList()
Similar to getObject and getViewList.
getCatalogType()
Gets a CatalogType that is registered with Sponge. As CatalogTypes are uniquely identifiable by their String id, one can assume that if you have the id, and know the CatalogType base class, you can get the desired CatalogType instance of the id. Examples include BlockStates, ItemTypes, DyeColors, etc.
getCatalogTypeList()
Similar to getCatalogType() but still represented as a list of Strings to be resolved by the GameRegistry.
More things as they come.
The text was updated successfully, but these errors were encountered:
This is more of a rolling issue that I'm going to be maintaining and some brain dumping on how certain aspects of Data API (and maybe other aspects of Sponge's systems, like the registry system) should be used.
DataView
to use for what and whengetContainer()
get(DataQuery)
Object
, whether it's serialized or aDataView
or a primitive type is unknowngetView()
DataView
child within thisDataView
, good for getting nested views for larger complex objects.getBoolean()
boolean
out of the currentDataView
getShort()
short
out of the currentDataView
getByte()
byte out of the current
DataView`getInt
()int
out of the currentDataView
getLong()
long
out of the currentDataView
getFloat()
float
out of the currentDataView
getDouble()
double
out of the currentDataView
getString()
String
out of the currentDataView
getList()
List
of something out of the currentDataView
, this would be useful if you're attempting to get complex objects out of this list, such as a list ofMap
s. Not to be confused with a list of things that areDataSerializable
or that are added asDataTranslatable
(likeUUID
s).getViewList()
List
ofDataView
s. Useful for the list ofDataView
s that are separated from the current parent only by the givenList
. The path does not function past this point as theDataView
s internally are parented only by themselves.getSerializable()
DataSerializable
out of thisDataView
. SinceDataSerializable
s are automatically serialized toDataView
s upon insertion, theDataSerializable
is deserialized from the internalDataView
represented by the path as indicated by theDataQuery
. Note that certain objects may not be deserializable, such asEntity
objects.getSerializableList()
DataSerializable
s, follows the limitations ofgetList()
orgetViewList()
.getObject()
Object
of typeT
that must have been registered as aDataTranslatable
. These types of objects are declared in other libraries, not controlled by Sponge, and as such, cannot be marked asDataSerializable
, but have been registered to be serializable by aDataTranslator
. Objects such as these areDate
,Instance
,UUID
, etc.getObjectList()
getObject
andgetViewList
.getCatalogType()
CatalogType
that is registered with Sponge. AsCatalogType
s are uniquely identifiable by theirString
id, one can assume that if you have the id, and know theCatalogType
base class, you can get the desiredCatalogType
instance of the id. Examples includeBlockState
s,ItemType
s,DyeColor
s, etc.getCatalogTypeList()
getCatalogType()
but still represented as a list ofString
s to be resolved by theGameRegistry
.The text was updated successfully, but these errors were encountered: