WolfyScript / viewportl

A Minecraft Inventory GUI framework, designed to easily create reactive GUIs. Based on the well known Signal Reactivity System.
GNU General Public License v3.0
68 stars 12 forks source link

ItemsAdder CustomStack wrapper #82

Closed WolfyScript closed 2 years ago

WolfyScript commented 2 years ago

This wrapper makes it possible to make use of the ItemsAdder CustomStack without adding the API to your build dependencies.

The wrapper can be access via the ItemsAdderIntegration. getByItemStack and getInstance return a new CustomStack wrapper.

Get the integration:

ItemsAdderIntegration integration = wuCore.getCompatibilityManager().getPlugins().getIntegration("ItemsAdder", ItemsAdderIntegration.class);
if (integration != null) {
    //ItemsAdder is available
}

or

wuCore.getCompatibilityManager().getPlugins().runIfAvailable("ItemsAdder", ItemsAdderIntegration.class, integration -> {
    //ItemsAdder is available
    //use the integration e.g. integration.getByItemStack(itemstack); 
    //of course you need to use Atomics to edit variables outside of this lambda.
});