Content

Content

Content is the live slot map for a menu view. If a menu currently shows a button in slot 13, that fact lives in Content.

Lotus splits the API into two halves:

  • ContentView for reading
  • ContentEditor for writing

Content extends both, so in practice you usually just work with Content.

Create Content

Most menus should build their initial layout with Content.builder(...):

Content content = Content.builder(Capacity.ofRows(3))
    .set(1, 4, Button.of(new ItemStack(Material.PAPER)))
    .build();

If you need an empty mutable map first, use Content.empty(...):

Content content = Content.empty(Capacity.ofRows(3));
content.set(Slot.of(13), Button.of(new ItemStack(Material.PAPER)));

Use the builder for initial layout and direct mutation for runtime changes. That keeps menu code readable.

Read From Content

Optional<Button> center = content.get(Slot.of(13));

content.forEach((slot, button) -> {
    System.out.println(slot + " -> " + button.item().getType());
});

You can also stream the raw entries with entries().

Write To Content

content.set(Slot.of(13), Button.of(icon));
content.fill(SlotMask.full(content.capacity()), Button.of(filler));
content.update(Slot.of(13), current -> current.withItem(brighterIcon));
content.remove(Slot.of(13));
content.clear();

These mutations happen in place on the live content object.

How Repainting Works

If a button mutates content during a click, Lotus repaints the menu automatically after dispatch. That is why patterns like this work cleanly:

view.content().update(Slot.of(event.getSlot()), current -> current.withItem(newIcon));

view.refresh() rebuilds menu.content(view) only. It does not recreate the inventory, recalculate the title, or resize the menu. If your title or capacity needs to change, open a new menu view instead.

Merge Two Content Maps

You can overlay one content map on another:

Content base = ...;
Content overlay = ...;
Content merged = base.mergeWith(overlay);

Where both define the same slot, the overlay wins.

trimTo(...) Is A Low-Level Tool

content.trimTo(25);

This method exists, but beginners usually do not need it. If you are deciding which items should appear in a menu, it is usually clearer to limit your source data before rendering.

When You Will Touch Content Directly

  • inside a button click to swap one slot
  • inside a menu refresh path to rebuild a section
  • inside pagination decorations or renderers

If your next problem is "I have several objects and need to place them across slots in order," continue to Slot Iterator. Otherwise, jump ahead to The Menu Template.