-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix context switch workflow and pipeline calls order #703
Conversation
for (final Viewer viewer : renderContext.getIndexedViewers().values()) { | ||
setupViewer(viewer, renderContext, root); | ||
} | ||
|
||
final Viewer viewer = renderContext.getViewer(); | ||
if (viewer != null) setupViewer(viewer, renderContext, root); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code opens support to include players in the context of another player without needing to added then through open(...)
.
|
||
@Override | ||
public void onFirstRender(@NotNull RenderContext render) { | ||
render.slot(1, new ItemStack(Material.DIAMOND)).onClick(click -> click.openForPlayer(SimplePagination.class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we also should test the other way around, when this view is opened by another without using back.
I noticed that in samples, debugs we're displaying the wrong values for "Viewer added to..." and "Viewer removed from...", when switching contexts the context shown in "Viewer added" and "Viewer removed" debugs were the same (which is wrong);
getPreviousContext
must ensure thatisSwitching
to true in Viewer APIPlatformView#onViewerAdded
and pipelineVIEWER_ADDED
/VIEWER_REMOVED
calls order.getCurrentContext
that ensures context consistency when switching from a context to another.isSwitching
reset once a player is switched successfully to the next context.onViewerAdded
is also called when switching back to a context (onViewerAdded -> onResume).With all the changes, when switching back to a context (
context.back()
) state values of that context will be kept. I'll address it in the next PR. For now you need to manually reset (if you want) viaonResume
.Fixes #696; Fixes #658; Fixes #657; Fixes #649; Fixes #647; Fixes #383