Inventory Library

Source | Discord | FlashLabs

  • Version: v0.1.0
  • Dependencies: None

The inventory library provides a system for creating custom inventories and managing inventory actions to create menus.

QuickStart

  • Note: Complete documentation is being worked on, and it will take us some time to write everything out. If you have any questions, feel free to ask in the #flashlibs channel on Discord

The core of the inventory library is the View class, which represents an inventory that can displayed to players, and the Element class, which represents the item and click action of a slot in the inventory.

A simple Element can be created a follows:

Element element = Element.of(ItemTypes.BLAZE_POWDER, action -> {
    action.getPlayer().sendMessage(Text.of("Elements are awesome!"));
});

To create a View, we can use the View.builder method.

View view = View.builder(InventoryArchetypes.CHEST)
        .title(Text.of("Views are awesome!")
        .build(container);

From here, to position Elements in the view we can use the view’s define method with the help of a Layout:

Layout layout = Layout.builder(3, 9)
        .border(Element.of(ItemStack.of(ItemTypes.STONE, 1)))
        .fill(Element.of(ItemStack.of(ItemTypes.DIRT, 2)))
        .set(Element.of(ItemStack.of(ItemTypes.GRASS, 3)), 1)
        .build();

View Example

Pages

The Page class is used for paginating contents in an inventory which supports navigation.

The remaining documentation hasn’t been written yet, but it should be feasible to piece together things using the javadocs. If you have any questions feel free to ask on Discord. If you’d like to help write documentation we would greatly appreciate it!

Category: Developer Tools

Published on Apr 6, 2020

views

stars

watchers

total downloads

Licensed under MIT

Promoted Versions

Members