Features:
- Adding the ability to retrieve the value associated with a paginated InventoryItem. An InventoryItem now has a local DataStore that can be retrieved by using the getLocalStore() method. The paginated data is associated with the constant key CommonDataStoreKey.PAGINATED_DATA, and can be retrieved using the <T> Optional<T> getData(String key, Class<T> type) method. Related issue. Issue #57
- Adding the ability to transfer data between inventories by passing a Context when opening it. Two methods has been added to the InventoryViewManager interface: void openView(CraftVentory inventory, Context context) and void openView(CraftVentory inventory, boolean newHistory, Context context). When opening the inventory, this context will be available in the CraftVentoryBeforeOpenEvent thrown. This event can be handled by declaring hooks. Then, the Context interface contains methods that can be used to retrieve the data. Issue #56
- Improving the Context interface by replacing the method boolean hasData(String key) by boolean hasData(String key, Class<?> type) to also check the type of the data. Adding a method <T> Optional<T> findData(String key, Class<T> type) to retrieve the data in an Optional<T>. Issue #60
- Adding a static method createContext() in CraftVentoryLibrary to create a Context without manipulating the implementation. This is useful when you want to create a Context to pass data when opening an inventory.
- Replacing the CommonContextKey enum by a class with static constants, which is lighter to use. Renaming the PAGINATION_ITEM constant to PAGINATED_DATA which is more explicit.
Rework:
- In the
DataStore interface, changing parameters
Class<T> type and
T value order of the
setData() method to be consistent with the same method in the
Context interface. Concretely, changing
<T> void setData(String key, Class<T> type, T value) to
<T> void setData(String key, T value, Class<T> type).
Documentation:
- Improving javadoc consistency between
Context and
DataStore which are similar interfaces.
- Adding javadoc for newly added methods.