Class IFViewFrame<S extends IFViewFrame<S,V>,V extends PlatformView<S,?,?,?,?,?,?,?>>

java.lang.Object
me.devnatan.inventoryframework.IFViewFrame<S,V>

public abstract class IFViewFrame<S extends IFViewFrame<S,V>,V extends PlatformView<S,?,?,?,?,?,?,?>> extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Consumer<me.devnatan.inventoryframework.ViewConfigBuilder>
     
    static final me.devnatan.inventoryframework.pipeline.PipelinePhase
    Called when a IFViewFrame is registered.
    static final me.devnatan.inventoryframework.pipeline.PipelinePhase
    Called when a IFViewFrame is unregistered.
    protected final Map<UUID,V>
     
    protected final Map<String,me.devnatan.inventoryframework.Viewer>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addViewer(@NotNull me.devnatan.inventoryframework.Viewer viewer)
    This is an internal inventory-framework API that should not be used from outside of this library.
    final me.devnatan.inventoryframework.context.EndlessContextInfo
    createEndlessContext(@NotNull Class<? extends me.devnatan.inventoryframework.RootView> viewClass)
    Creates a context that is never invalidated.
    final me.devnatan.inventoryframework.context.EndlessContextInfo
    createEndlessContext(@NotNull Class<? extends me.devnatan.inventoryframework.RootView> viewClass, Object initialData)
    Creates a context that is never invalidated.
    final S
    defaultConfig(@NotNull Consumer<me.devnatan.inventoryframework.ViewConfigBuilder> defaultConfig)
    Sets the default configuration that will be used for all views registered from this framework.
    final S
    Enables internal code debugs.
    (package private) final Consumer<me.devnatan.inventoryframework.ViewConfigBuilder>
    The default configuration applier of this framework.
    final @NotNull me.devnatan.inventoryframework.pipeline.Pipeline<IFViewFrame>
    This is an internal inventory-framework API that should not be used from outside of this library.
    final V
    getRegisteredViewByType(@NotNull Class<?> type)
    Gets an instance of a registered view from its class-type.
    protected final @NotNull @UnmodifiableView Map<UUID,V>
    All registered views.
    protected final String
    internalOpen(@NotNull Class<? extends V> viewClass, @NotNull Map<String,?> viewers, Object initialData)
    Opens a view to more than one player with initial data.
    protected final void
    internalOpenActiveContext(Class<? extends me.devnatan.inventoryframework.RootView> viewClass, String contextId, Object viewer, Object initialData)
    Opens an active context.
    final boolean
    If this view frame is registered.
    abstract S
    Registers this view frame.
    final void
    remove(V... views)
    Removes a view from this view frame.
    (package private) void
    removeViewer(@NotNull me.devnatan.inventoryframework.Viewer viewer)
     
    protected final void
    setRegistered(boolean registered)
    Sets the registered state of this view frame.
    abstract void
    Unregisters this view frame and closes all registered views.
    final S
    with(V... views)
    Registers a new view to this view frame.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FRAME_REGISTERED

      public static final me.devnatan.inventoryframework.pipeline.PipelinePhase FRAME_REGISTERED
      Called when a IFViewFrame is registered.
    • FRAME_UNREGISTERED

      public static final me.devnatan.inventoryframework.pipeline.PipelinePhase FRAME_UNREGISTERED
      Called when a IFViewFrame is unregistered.
    • registeredViews

      protected final Map<UUID,V extends PlatformView<S,?,?,?,?,?,?,?>> registeredViews
    • viewerById

      protected final Map<String,me.devnatan.inventoryframework.Viewer> viewerById
    • defaultConfig

      protected Consumer<me.devnatan.inventoryframework.ViewConfigBuilder> defaultConfig
  • Constructor Details

    • IFViewFrame

      protected IFViewFrame()
  • Method Details

    • getPipeline

      @Internal @NotNull public final @NotNull me.devnatan.inventoryframework.pipeline.Pipeline<IFViewFrame> getPipeline()
      This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
    • getRegisteredViews

      @NotNull protected final @NotNull @UnmodifiableView Map<UUID,V> getRegisteredViews()
      All registered views.
      Returns:
      A Map containing all registered views in this view frame.
    • getRegisteredViewByType

      @NotNull public final V getRegisteredViewByType(@NotNull @NotNull Class<?> type)
      Gets an instance of a registered view from its class-type.
      Parameters:
      type - The view type.
      Returns:
      An RootView instance of the given type.
      Throws:
      IllegalArgumentException - If the given cannot be found.
    • with

      @Contract("_ -> this") public final S with(V... views)
      Registers a new view to this view frame.
      Parameters:
      views - The views that'll be registered.
      Returns:
      This platform view frame.
    • remove

      public final void remove(V... views)
      Removes a view from this view frame.
      Parameters:
      views - The views that'll be removed.
    • register

      public abstract S register()
      Registers this view frame.
      Returns:
      This platform view frame.
      Throws:
      IllegalStateException - If this view frame is already registered.
    • unregister

      public abstract void unregister()
      Unregisters this view frame and closes all registered views.
    • isRegistered

      public final boolean isRegistered()
      If this view frame is registered.
      Returns:
      true if it's registered or false otherwise.
    • setRegistered

      protected final void setRegistered(boolean registered)
      Sets the registered state of this view frame.
      Parameters:
      registered - true to mark this view frame as registered.
    • internalOpen

      protected final String internalOpen(@NotNull @NotNull Class<? extends V> viewClass, @NotNull @NotNull Map<String,?> viewers, Object initialData)
      Opens a view to more than one player with initial data.

      These players will see the same inventory and share the same context.

      Parameters:
      viewClass - The target view to be opened.
      viewers - The viewers that the view will be open to.
      initialData - The initial data.
      Returns:
      The id of the newly created IFContext.
    • internalOpenActiveContext

      protected final void internalOpenActiveContext(Class<? extends me.devnatan.inventoryframework.RootView> viewClass, String contextId, Object viewer, Object initialData)
      Opens an active context.
      Parameters:
      viewClass - The target view to be opened.
      contextId - Context id to open into.
      viewer - The viewer to attach into the specified context.
      initialData - The initial viewer data.
    • createEndlessContext

      @Experimental public final me.devnatan.inventoryframework.context.EndlessContextInfo createEndlessContext(@NotNull @NotNull Class<? extends me.devnatan.inventoryframework.RootView> viewClass)
      Creates a context that is never invalidated.

      This API is experimental and is not subject to the general compatibility guarantees such API may be changed or may be removed completely in any further release.

      Parameters:
      viewClass - The view of the context to be later opened.
      Returns:
      The id of the context.
    • createEndlessContext

      @Experimental public final me.devnatan.inventoryframework.context.EndlessContextInfo createEndlessContext(@NotNull @NotNull Class<? extends me.devnatan.inventoryframework.RootView> viewClass, Object initialData)
      Creates a context that is never invalidated.

      This API is experimental and is not subject to the general compatibility guarantees such API may be changed or may be removed completely in any further release.

      Parameters:
      viewClass - The view of the context to be later opened.
      initialData - Initial setup data to pass to opening handler.
      Returns:
      The id of the context.
    • addViewer

      @Internal public void addViewer(@NotNull @NotNull me.devnatan.inventoryframework.Viewer viewer)
      This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
    • removeViewer

      void removeViewer(@NotNull @NotNull me.devnatan.inventoryframework.Viewer viewer)
    • defaultConfig

      @Experimental public final S defaultConfig(@NotNull @NotNull Consumer<me.devnatan.inventoryframework.ViewConfigBuilder> defaultConfig)
      Sets the default configuration that will be used for all views registered from this framework.

      This API is experimental and is not subject to the general compatibility guarantees such API may be changed or may be removed completely in any further release.

      Returns:
      This framework instance.
      See Also:
    • getDefaultConfig

      final Consumer<me.devnatan.inventoryframework.ViewConfigBuilder> getDefaultConfig()
      The default configuration applier of this framework.
      Returns:
      The default configuration applier of this framework.
    • enableDebug

      @Internal public final S enableDebug()
      Enables internal code debugs.

      This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.

      Returns:
      Enable InventoryFramework debugs.