Skip to content

Migrating to version 3

Natan Vieira edited this page Dec 30, 2022 · 28 revisions

The new version 3.0 is especially needed to restructure the project's packages, previously everything was unified in a single package "me.saiintbrisson.minecraft", and also, everything that was created had to be compatible with previous versions so nothing could be changed if it would not break code compatibility.

To give you an idea, it has working code from 2016 using the first version of Inventory Framework that works perfectly in the latest version 2.5.4-rc.1.

But things get complicated when it comes to adding features, fixing bugs and so on, so now we have version 3.

Relocation

Everything that was in the "me.saiintbrisson.minecraft" package has been moved to "me.devnatan.inventoryframework" and subpackages.

An attempt has been made to preserve as many names as possible such as the root View name and context names to make relocation easier.

Platform Features

As of this new version 3, all of its views are designed with a single platform in mind, and when I say platform I mean: Bukkit, Sponge, Bungeecord, among others. Now you will have access to the APIs you are most familiar with like ItemStack in Bukkit, ProxiedPlayer in BungeeCord and more.

Lombok-compatible API design

Previously it was not possible to use Lombok in views because it was mandatory to define a constructor and use super to choose the properties and initial options of the view.

This has changed, now we have a method specifically for configuring the view and another specifically for defining the items that will be rendered.

So you can use all Lombok annotations naturally like this

@RequiredArgsConstructor
private final class PetShopView extends View {

    private final PetsManager petsManager;

}

Pagination Changes

Perhaps the biggest change of all was on the pagination issue, the PaginatedView class no longer exists. Now everything is handled through states so if you have a PaginatedView, simply change it to a View. Any and all views are now paginated if they have pagination state, and the IF internally takes care of everything else for you.

- public final class PetShopView extends PaginatedView<Pet>
+ public final class PetShopView extends View

The way paging was defined has also changed, before we had specific methods for each type of paging: static, dynamic computed and dynamic asynchronous, we don't have that anymore. Now the type of paging will depend on what kind of data source you provide for the paging state.

New State Management System

The new state handling came to make the data handling experience inside the view more reactive, easy and explicit.

Previously it was necessary to use a combination of context.set, context.get and context.update together to get and update data and this was a bit strange because the Inventory Framework was not specifically written for this so some things they just didn't work which led to several issues.

Learn more about the new State Management System

Rewriting your views

Clone this wiki locally