Class DefaultContent

java.lang.Object
studio.mevera.lotus.internal.content.DefaultContent
All Implemented Interfaces:
Content, ContentEditor, ContentView

public final class DefaultContent extends Object implements Content
Default Content implementation backed by a HashMap<Slot, Button>. Not thread-safe; mutated only on the server main thread.
  • Constructor Details

    • DefaultContent

      public DefaultContent(@NotNull @NotNull Capacity capacity)
  • Method Details

    • capacity

      @NotNull public @NotNull Capacity capacity()
      Description copied from interface: ContentView
      Returns the capacity this content was created for.
      Specified by:
      capacity in interface ContentView
    • get

      @NotNull public @NotNull Optional<Button> get(@NotNull @NotNull Slot slot)
      Description copied from interface: ContentView
      Returns the button at the given slot, if one exists.
      Specified by:
      get in interface ContentView
    • size

      public int size()
      Description copied from interface: ContentView
      Returns the number of occupied slots.
      Specified by:
      size in interface ContentView
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ContentView
      Returns whether no buttons are present.
      Specified by:
      isEmpty in interface ContentView
    • nextEmpty

      @NotNull public @NotNull Optional<Slot> nextEmpty(@NotNull @NotNull Slot from)
      Description copied from interface: ContentView
      Returns the next empty slot starting from from.
      Specified by:
      nextEmpty in interface ContentView
    • entries

      @NotNull public @NotNull Stream<Map.Entry<Slot,Button>> entries()
      Description copied from interface: ContentView
      Returns the stored entries as a stream.
      Specified by:
      entries in interface ContentView
    • forEach

      public void forEach(@NotNull @NotNull BiConsumer<Slot,Button> consumer)
      Description copied from interface: ContentView
      Visits every stored button.
      Specified by:
      forEach in interface ContentView
    • set

      public void set(@NotNull @NotNull Slot slot, @Nullable @Nullable Button button)
      Description copied from interface: ContentEditor
      Sets or clears the button at the given slot.
      Specified by:
      set in interface ContentEditor
    • remove

      public void remove(@NotNull @NotNull Slot slot)
      Description copied from interface: ContentEditor
      Removes the button at the given slot.
      Specified by:
      remove in interface ContentEditor
    • update

      public void update(@NotNull @NotNull Slot slot, @NotNull @NotNull UnaryOperator<Button> updater)
      Description copied from interface: ContentEditor
      Replaces the button at the given slot using the updater result.
      Specified by:
      update in interface ContentEditor
    • fill

      public void fill(@NotNull @NotNull SlotMask mask, @NotNull @NotNull Button button)
      Description copied from interface: ContentEditor
      Fills all slots in the mask with the same button.
      Specified by:
      fill in interface ContentEditor
    • clear

      public void clear()
      Description copied from interface: ContentEditor
      Removes all buttons.
      Specified by:
      clear in interface ContentEditor
    • mergeWith

      @NotNull public @NotNull Content mergeWith(@NotNull @NotNull ContentView other)
      Description copied from interface: Content
      Returns a new content object with entries from both sources.

      Entries from other overwrite entries from this content when both use the same slot.

      Specified by:
      mergeWith in interface Content
    • trimTo

      public void trimTo(int maxButtons)
      Description copied from interface: Content
      Removes extra buttons after the given limit is reached.
      Specified by:
      trimTo in interface Content