[Feature] Add API to query type of PersistentDataContainer value - #14143
[Feature] Add API to query type of PersistentDataContainer value#14143Keksnet wants to merge 6 commits into
Conversation
This is the initial implementation of PersistentDataContainerView.getType. The method makes it possible for callees to retrieve the data type of a specific persistent data container key.
|
Detection of nested lists is now fixed. |
|
I am not much of a fan of such an method, definitely not under the proposed method name at least. Type information is not encoded. A plugin inserting a value using PersistentDataType A is not guaranteed to receive said data type when querying the PDC#getType(). Maybe PDCV#estimatePrimitiveDataType(Key) could work? With a large amount of notice in the javadocs. |
|
@lynxplay I totally missed the possibility of plugin-specific data types. I renamed the method and edited the javadocs. This should hopefully reflect that this method is essentially only estimating the data type based on the underlying nbt tag. |
|
I personally don't really like the name |
|
@Leguan16 I personally think the storage type thing is too abstract. I would maybe suggest |
The issue with this name is that there is no concept of NBT in the API I think. So it could be a confusing name. |
|
|
|
@Leguan16 the point of "primitive" here was that the persistent data type interface already has the concept of a complex and a primitive type. We can fight over the verb estimate but "storage" vs "primitive" seems like an easy choice in my head. |
|
what about Since I assume you want the |
|
I think |
|
I have renamed the method to |
Hi,
this PR adds a method that makes it possible to query the data type of a specific value inside a persistent data container.
With this method it will be possible to read a value without knowing the exact type of the value you are trying to read.
This is useful for migrating the data type of a value to another one or for a library that sits on top of Paper and does not know the type by design.
It enables further tools like editors for the persistent data container to be developed without the need to check every available data type or using a nbt API.
I have tested the method using the test-plugin and can provide my testing code if necessary.
This API in its current form is not able to correctly determine the data type of nested lists but I'm already trying to fix this issue.Already fixed.Any question or feedback is welcome. 🙂