Class MultiMask<T>

java.lang.Object
io.github.projectunified.craftux.mask.MultiMask<T>
Type Parameters:
T - the type of the child element
All Implemented Interfaces:
Element, Mask
Direct Known Subclasses:
AnimatedMask, HybridMask, ListMask, MultiPositionMask

public abstract class MultiMask<T> extends Object implements Element, Mask
A base class for masks that manage multiple child elements. Provides functionality to add, retrieve, and manage lifecycle of child elements.

Example usage:


 MultiMask<Mask> multiMask = new MyMultiMask();
 multiMask.add(new SingleMask(Position.of(0, 0), button1), new SingleMask(Position.of(1, 1), button2));
 List<Mask> elements = multiMask.getElements();
 
  • Field Details

    • elements

      protected final List<T> elements
  • Constructor Details

    • MultiMask

      public MultiMask()
  • Method Details

    • add

      public <R extends T> void add(Collection<R> elements)
      Adds child elements to this mask.
      Type Parameters:
      R - the type of the child elements, must extend T
      Parameters:
      elements - the child elements to add
    • add

      @SafeVarargs public final void add(T... elements)
      Adds multiple child elements to this mask.
      Parameters:
      elements - the child elements to add
    • getElements

      public final List<T> getElements()
      Get the child elements
      Returns:
      the child elements
    • init

      public void init()
      Description copied from interface: Element
      Initialize the element. Should be called before adding to the GUI.
      Specified by:
      init in interface Element
    • stop

      public void stop()
      Description copied from interface: Element
      Stop the element. Should be called after removing from the GUI.
      Specified by:
      stop in interface Element