Class PlatformView<TFramework extends IFViewFrame<?,?>,TViewer,TItem extends me.devnatan.inventoryframework.component.ItemComponentBuilder<TItem,TContext> & me.devnatan.inventoryframework.component.ComponentFactory,TContext extends me.devnatan.inventoryframework.context.IFContext,TOpenContext extends me.devnatan.inventoryframework.context.IFOpenContext,TCloseContext extends me.devnatan.inventoryframework.context.IFCloseContext,TRenderContext extends me.devnatan.inventoryframework.context.IFRenderContext,TSlotClickContext extends me.devnatan.inventoryframework.context.IFSlotClickContext>
- All Implemented Interfaces:
Iterable<TContext>,me.devnatan.inventoryframework.RootView,me.devnatan.inventoryframework.state.StateAccess<TContext,,TItem> me.devnatan.inventoryframework.VirtualView
-
Field Summary
Fields inherited from class me.devnatan.inventoryframework.DefaultRootView
stateRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContext(TContext context) Adds a context to this view.final voidback(@NotNull me.devnatan.inventoryframework.Viewer viewer) This is an internal inventory-framework API that should not be used from outside of this library.final voidThis is an internal inventory-framework API that should not be used from outside of this library.buildComputedAsyncPaginationState(@NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider) buildComputedPaginationState(@NotNull Function<TContext, List<? super T>> sourceProvider) buildLazyAsyncPaginationState(@NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider) buildLazyPaginationState(@NotNull Function<TContext, List<? super T>> sourceProvider) buildLazyPaginationState(@NotNull Supplier<List<? super T>> sourceProvider) buildPaginationState(@NotNull List<? super T> sourceProvider) final voidCloses all contexts that are currently active in this view.final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination>computedAsyncPaginationState(@NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider, @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination>computedPaginationState(@NotNull Function<TContext, List<? super T>> sourceProvider, @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) final <T> me.devnatan.inventoryframework.state.State<T>computedState(@NotNull Function<TContext, T> computation) final <T> me.devnatan.inventoryframework.state.State<T>computedState(@NotNull Supplier<T> computation) final @NotNull me.devnatan.inventoryframework.ViewConfigBuilderCreates a new ViewConfigBuilder instance with the default platform configuration.(package private) final StringcreateEndless(Object initialData) Setups a endless context.final @NotNull me.devnatan.inventoryframework.context.IFContextgetContext(@NotNull String viewerId) Returns the context that is linked to the specified viewer in this view.final @NotNull me.devnatan.inventoryframework.context.IFContextgetContext(@NotNull me.devnatan.inventoryframework.Viewer viewer) Returns the context that is linked to the specified viewer in this view.@NotNull me.devnatan.inventoryframework.internal.ElementFactoryfinal TFrameworkThis is an internal inventory-framework API that should not be used from outside of this library.booleanhasContext(@NotNull UUID id) This is an internal inventory-framework API that should not be used from outside of this library.final <T> me.devnatan.inventoryframework.state.MutableState<T>final <T> me.devnatan.inventoryframework.state.MutableState<T>initialState(@NotNull String key) (package private) final voidinternalInitialization(IFViewFrame<?, ?> framework) Called internally before the first initialization.voidinvalidateEndlessContext(String contextId) (package private) final booleanThe initialization state of this view.iterator()final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination>lazyAsyncPaginationState(@NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider, @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination>lazyPaginationState(@NotNull Function<TContext, List<? super T>> sourceProvider, @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination>lazyPaginationState(@NotNull Supplier<List<? super T>> sourceProvider, @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) final <T> me.devnatan.inventoryframework.state.State<T>final <T> me.devnatan.inventoryframework.state.State<T>protected final <E> me.devnatan.inventoryframework.Ref<List<E>>Creates a new empty reference instance that can hold multiple elements of the same type.final me.devnatan.inventoryframework.state.MutableIntStatemutableState(int initialValue) final <T> me.devnatan.inventoryframework.state.MutableState<T>mutableState(T initialValue) final voidnavigateTo(@NotNull Class<? extends PlatformView> target, @NotNull me.devnatan.inventoryframework.context.IFRenderContext origin, @NotNull me.devnatan.inventoryframework.Viewer viewer, Object initialData) This is an internal inventory-framework API that should not be used from outside of this library.final voidnavigateTo(@NotNull Class<? extends PlatformView> target, @NotNull me.devnatan.inventoryframework.context.IFRenderContext origin, Object initialData) This is an internal inventory-framework API that should not be used from outside of this library.voidonClick(TSlotClickContext click) Called when an actor clicks on a container while it has a view open.voidonClose(TCloseContext close) Called when the player closes the view's inventory.voidonFirstRender(TRenderContext render) Called only once before the container is displayed to a player.voidonInit(@NotNull me.devnatan.inventoryframework.ViewConfigBuilder config) Called when the view is about to be configured, the returned object will be the view's configuration.voidonOpen(TOpenContext open) Called before a context is rendered, used to set up it.voidCalled when a context is resumed byIFConfinedContext.back().voidCalled when the view is updated for a player.voidonViewerAdded(TContext context, TViewer viewer, Object data) Called when avieweris added to a context.voidonViewerRemoved(TContext context, TViewer viewer) Called when avieweris removed from a context.(package private) final voidOpens an already active context to a viewer.(package private) final StringOpens this view to one or more viewers.final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination>paginationState(@NotNull List<? super T> sourceProvider, @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> elementConsumer) protected final <E> me.devnatan.inventoryframework.Ref<E>ref()Creates a new unassigned reference instance.(package private) abstract voidvoidremoveAndTryInvalidateContext(@NotNull me.devnatan.inventoryframework.Viewer viewer, TContext context) voidremoveContext(@NotNull me.devnatan.inventoryframework.context.IFContext context) Removes a given context from this view if that context is linked to this view.voidrenderContext(TRenderContext context) Renders a given context in this view.(package private) final voidsetInitialized(boolean initialized) Sets the initialization state of this view.final <T> me.devnatan.inventoryframework.state.State<T>state(T initialValue) Methods inherited from class me.devnatan.inventoryframework.DefaultRootView
getConfig, getContexts, getInternalContexts, getPipeline, getScheduledUpdateJob, getUniqueId, nextTick, setConfig, setScheduledUpdateJobMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PlatformView
public PlatformView()
-
-
Method Details
-
closeForEveryone
public final void closeForEveryone()Closes all contexts that are currently active in this view. -
createEndless
Setups a endless context.- Parameters:
initialData- Initial data to pass through opening handler.- Returns:
- The id of the generated context.
-
open
Opens this view to one or more viewers.- Parameters:
viewers- The viewers that'll see this view.initialData- The initial data.- Returns:
- The id of the generated context.
-
open
Opens an already active context to a viewer.- Parameters:
contextId- The id of the context.viewer- The viewer to open the context to.initialData- Initial data.
-
back
@Internal public final void back(@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.
-
back
@Internal public final void back(@NotNull @NotNull me.devnatan.inventoryframework.Viewer viewer, Object initialData) This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
-
createConfig
@NotNull public final @NotNull me.devnatan.inventoryframework.ViewConfigBuilder createConfig()Creates a new ViewConfigBuilder instance with the default platform configuration. Configuration is inherited from theframeworkif available.- Returns:
- A new ViewConfigBuilder instance.
-
getContext
@Internal @NotNull public final @NotNull me.devnatan.inventoryframework.context.IFContext getContext(@NotNull @NotNull me.devnatan.inventoryframework.Viewer viewer) Returns the context that is linked to the specified viewer in this view.This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
- Parameters:
viewer- The viewer.- Returns:
- The context of the viewer in this context.
- Throws:
IllegalArgumentException- If there's no context linked to the given viewer.
-
getContext
@NotNull public final @NotNull me.devnatan.inventoryframework.context.IFContext getContext(@NotNull @NotNull String viewerId) Returns the context that is linked to the specified viewer in this view.This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
- Parameters:
viewerId- The id of the viewer.- Returns:
- The context of the viewer in this context.
- Throws:
IllegalArgumentException- If there's no context linked to the given viewer.
-
addContext
Adds a context to this view.This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
- Parameters:
context- The context to add.
-
removeContext
@Internal public void removeContext(@NotNull @NotNull me.devnatan.inventoryframework.context.IFContext context) Removes a given context from this view if that context is linked to this view.This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
- Parameters:
context- The context to remove.
-
hasContext
This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided. -
renderContext
Renders a given context in this view.This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
- Parameters:
context- The context to render.
-
removeAndTryInvalidateContext
@Internal public void removeAndTryInvalidateContext(@NotNull @NotNull me.devnatan.inventoryframework.Viewer viewer, @NotNull TContext context) -
invalidateEndlessContext
- Specified by:
invalidateEndlessContextin interfaceme.devnatan.inventoryframework.RootView
-
iterator
- Specified by:
iteratorin interfaceIterable<TFramework extends IFViewFrame<?,?>>
-
ref
@Experimental protected final <E> me.devnatan.inventoryframework.Ref<E> ref()Creates a new unassigned reference instance.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.
- Type Parameters:
E- Type of the element hold by this reference.- Returns:
- A new unassigned
Refinstance. - See Also:
-
multiRefs
Creates a new empty reference instance that can hold multiple elements of the same type.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.
- Type Parameters:
E- Type of the element hold by this reference.- Returns:
- A new unassigned
Refinstance. - See Also:
-
onInit
@OverrideOnly public void onInit(@NotNull @NotNull me.devnatan.inventoryframework.ViewConfigBuilder config) Called when the view is about to be configured, the returned object will be the view's configuration.- Parameters:
config- A ViewConfigBuilder instance to configure this view.
-
onOpen
Called before a context is rendered, used to set up it.This handler is often called "pre-rendering" because it is possible to set the title and size of the inventory and also cancel the opening of the View without even doing any handling related to the inventory.
It is not possible to manipulate the inventory in this handler, if it happens an exception will be thrown.
This method is called once in Shared Contexts. To know when a viewer is added/removed from this kind of context use
onViewerAdded(TContext, TViewer, Object)/onViewerRemoved(TContext, TViewer).- Parameters:
open- The open context.
-
onFirstRender
Called only once before the container is displayed to a player.The
contextis not cancelable, for cancellation useonOpen(IFOpenContext)instead.This function should only be used to render items, any external call is completely forbidden as the function runs on the main thread.
- Parameters:
render- The rendering context.
-
onUpdate
Called when the view is updated for a player.This is a rendering function and can modify the view's inventory.
- Parameters:
update- The update context.
-
onClose
Called when the player closes the view's inventory.It is possible to cancel this event and have the view's inventory open again for the player.
- Parameters:
close- The player view context.
-
onClick
Called when an actor clicks on a container while it has a view open.You can know if the click was on entity inventory or view inventory by
IFSlotContext.isOnEntityContainer()Any function that triggers an inventory modification is prohibited from being used in this handler.This context is cancelable and canceling this context will cancel the click, thus canceling all subsequent interceptors causing the pipeline to terminate immediately.
- Parameters:
click- The click context.
-
onResume
@OverrideOnly @Experimental public void onResume(@NotNull TContext origin, @NotNull TContext target) Called when a context is resumed byIFConfinedContext.back().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:
origin- Who calledto back.target- The context that was back to.
-
onViewerAdded
@OverrideOnly @Experimental public void onViewerAdded(@NotNull TContext context, @NotNull TViewer viewer, Object data) Called when avieweris added to a context.This method is called after
initial render phase.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:
context- The context.viewer- Who was added to the context.data- Initial data set wen the viewer was added.
-
onViewerRemoved
@OverrideOnly @Experimental public void onViewerRemoved(@NotNull TContext context, @NotNull TViewer viewer) Called when avieweris removed from a context.This method is called on
close phasebefore context invalidation.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:
context- The context.viewer- Who was removed from the context.
-
getFramework
This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
-
isInitialized
final boolean isInitialized()The initialization state of this view.- Returns:
- If this view was initialized.
-
setInitialized
final void setInitialized(boolean initialized) Sets the initialization state of this view.- Parameters:
initialized- The new initialization state.
-
internalInitialization
Called internally before the first initialization.Use it to register pipeline interceptors.
- Throws:
IllegalStateException- If this platform view is already initialized.
-
registerPlatformInterceptors
abstract void registerPlatformInterceptors() -
getElementFactory
@Internal @NotNull public @NotNull me.devnatan.inventoryframework.internal.ElementFactory getElementFactory()- Specified by:
getElementFactoryin interfaceme.devnatan.inventoryframework.RootView- Overrides:
getElementFactoryin classme.devnatan.inventoryframework.DefaultRootView
-
state
public final <T> me.devnatan.inventoryframework.state.State<T> state(T initialValue) - Specified by:
statein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
mutableState
public final <T> me.devnatan.inventoryframework.state.MutableState<T> mutableState(T initialValue) - Specified by:
mutableStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
mutableState
public final me.devnatan.inventoryframework.state.MutableIntState mutableState(int initialValue) - Specified by:
mutableStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
computedState
public final <T> me.devnatan.inventoryframework.state.State<T> computedState(@NotNull @NotNull Function<TContext, T> computation) - Specified by:
computedStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
computedState
public final <T> me.devnatan.inventoryframework.state.State<T> computedState(@NotNull @NotNull Supplier<T> computation) - Specified by:
computedStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
lazyState
public final <T> me.devnatan.inventoryframework.state.State<T> lazyState(@NotNull @NotNull Function<TContext, T> computation) - Specified by:
lazyStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
lazyState
public final <T> me.devnatan.inventoryframework.state.State<T> lazyState(@NotNull @NotNull Supplier<T> computation) - Specified by:
lazyStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
initialState
public final <T> me.devnatan.inventoryframework.state.MutableState<T> initialState()- Specified by:
initialStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
initialState
public final <T> me.devnatan.inventoryframework.state.MutableState<T> initialState(@NotNull @NotNull String key) - Specified by:
initialStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
paginationState
public final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination> paginationState(@NotNull @NotNull List<? super T> sourceProvider, @NotNull @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> elementConsumer) - Specified by:
paginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
computedPaginationState
public final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination> computedPaginationState(@NotNull @NotNull Function<TContext, List<? super T>> sourceProvider, @NotNull @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) - Specified by:
computedPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
computedAsyncPaginationState
public final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination> computedAsyncPaginationState(@NotNull @NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider, @NotNull @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) - Specified by:
computedAsyncPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
lazyPaginationState
public final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination> lazyPaginationState(@NotNull @NotNull Function<TContext, List<? super T>> sourceProvider, @NotNull @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) - Specified by:
lazyPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
lazyPaginationState
public final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination> lazyPaginationState(@NotNull @NotNull Supplier<List<? super T>> sourceProvider, @NotNull @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) - Specified by:
lazyPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
lazyAsyncPaginationState
public final <T> me.devnatan.inventoryframework.state.State<me.devnatan.inventoryframework.component.Pagination> lazyAsyncPaginationState(@NotNull @NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider, @NotNull @NotNull me.devnatan.inventoryframework.component.PaginationValueConsumer<TContext, TItem, T> valueConsumer) - Specified by:
lazyAsyncPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
buildPaginationState
public final <T> me.devnatan.inventoryframework.component.PaginationStateBuilder<TContext,TItem, buildPaginationStateT> (@NotNull @NotNull List<? super T> sourceProvider) - Specified by:
buildPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
buildComputedPaginationState
public final <T> me.devnatan.inventoryframework.component.PaginationStateBuilder<TContext,TItem, buildComputedPaginationStateT> (@NotNull @NotNull Function<TContext, List<? super T>> sourceProvider) - Specified by:
buildComputedPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
buildComputedAsyncPaginationState
public final <T> me.devnatan.inventoryframework.component.PaginationStateBuilder<TContext,TItem, buildComputedAsyncPaginationStateT> (@NotNull @NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider) - Specified by:
buildComputedAsyncPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
buildLazyPaginationState
public final <T> me.devnatan.inventoryframework.component.PaginationStateBuilder<TContext,TItem, buildLazyPaginationStateT> (@NotNull @NotNull Supplier<List<? super T>> sourceProvider) - Specified by:
buildLazyPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
buildLazyPaginationState
public final <T> me.devnatan.inventoryframework.component.PaginationStateBuilder<TContext,TItem, buildLazyPaginationStateT> (@NotNull @NotNull Function<TContext, List<? super T>> sourceProvider) - Specified by:
buildLazyPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-
buildLazyAsyncPaginationState
public final <T> me.devnatan.inventoryframework.component.PaginationStateBuilder<TContext,TItem, buildLazyAsyncPaginationStateT> (@NotNull @NotNull Function<TContext, CompletableFuture<List<T>>> sourceProvider) - Specified by:
buildLazyAsyncPaginationStatein interfaceme.devnatan.inventoryframework.state.StateAccess<TFramework extends IFViewFrame<?,?>, TViewer>
-