File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
inventory-framework-api/src/main/java/me/devnatan/inventoryframework/context
inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/context
inventory-framework-platform-minestom/src/main/kotlin/me/devnatan/inventoryframework/context Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 44import me .devnatan .inventoryframework .ViewConfig ;
55import me .devnatan .inventoryframework .ViewConfigBuilder ;
66import me .devnatan .inventoryframework .ViewContainer ;
7+ import me .devnatan .inventoryframework .state .AsyncState ;
78import org .jetbrains .annotations .ApiStatus ;
89import org .jetbrains .annotations .NotNull ;
910
@@ -34,6 +35,18 @@ public interface IFOpenContext extends IFConfinedContext {
3435 */
3536 void waitUntil (@ NotNull CompletableFuture <Void > task );
3637
38+ /**
39+ * Waits for a asynchronous state to be complete before ending this opening context and
40+ * transitioning to the rendering context (waits to show the inventory to the player).
41+ * <p>
42+ * <b>This API is experimental and is not subject to the general compatibility guarantees such API
43+ * may be changed or may be removed completely in any further release.</b>
44+ *
45+ * @param state The state to wait before opening the inventory.
46+ */
47+ @ ApiStatus .Experimental
48+ void waitFor (@ NotNull AsyncState <?> state );
49+
3750 /**
3851 * Whether opening the container to the viewer has been cancelled.
3952 *
Original file line number Diff line number Diff line change 1313import me .devnatan .inventoryframework .ViewConfigBuilder ;
1414import me .devnatan .inventoryframework .ViewContainer ;
1515import me .devnatan .inventoryframework .Viewer ;
16+ import me .devnatan .inventoryframework .state .AsyncState ;
1617import org .bukkit .entity .Player ;
1718import org .jetbrains .annotations .ApiStatus ;
1819import org .jetbrains .annotations .NotNull ;
@@ -31,6 +32,7 @@ public class OpenContext extends PlatformConfinedContext implements IFOpenContex
3132
3233 // --- User Provided ---
3334 private CompletableFuture <Void > waitTask ;
35+ private AsyncState <?> waitState ;
3436 private ViewConfigBuilder inheritedConfigBuilder ;
3537
3638 // --- Properties ---
@@ -139,6 +141,11 @@ public final void waitUntil(@NotNull CompletableFuture<Void> task) {
139141 this .waitTask = task ;
140142 }
141143
144+ @ Override
145+ public void waitFor (@ NotNull AsyncState <?> state ) {
146+ this .waitState = state ;
147+ }
148+
142149 @ Override
143150 public final @ NotNull ViewConfig getConfig () {
144151 return inheritedConfigBuilder == null
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import me.devnatan.inventoryframework.ViewConfig
66import me.devnatan.inventoryframework.ViewConfigBuilder
77import me.devnatan.inventoryframework.ViewContainer
88import me.devnatan.inventoryframework.Viewer
9+ import me.devnatan.inventoryframework.state.AsyncState
910import net.kyori.adventure.text.Component
1011import net.minestom.server.entity.Player
1112import org.jetbrains.annotations.ApiStatus
@@ -44,6 +45,7 @@ class OpenContext
4445 // --- User Provided ---
4546
4647 private var waitTask: CompletableFuture <Void >? = null
48+ private var waitState: AsyncState <* >? = null
4749 private var inheritedConfigBuilder: ViewConfigBuilder ? = null
4850
4951 // --- Properties ---
@@ -109,6 +111,10 @@ class OpenContext
109111 this .waitTask = task
110112 }
111113
114+ override fun waitFor (state : AsyncState <* >) {
115+ this .waitState = state
116+ }
117+
112118 override fun getConfig (): ViewConfig =
113119 if (inheritedConfigBuilder == null ) {
114120 getRoot().config
You can’t perform that action at this time.
0 commit comments