File tree Expand file tree Collapse file tree
core/src/main/java/net/j4c0b3y/api/menu Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,6 +180,11 @@ public void open() {
180180 }, async );
181181 }
182182
183+ /**
184+ * Updates the inventory's title while open.
185+ *
186+ * @param title The new title.
187+ */
183188 public void setTitle (String title ) {
184189 this .title = title ;
185190
@@ -190,10 +195,14 @@ public void setTitle(String title) {
190195 inventory .setContents (this .inventory .getContents ());
191196 this .inventory = inventory ;
192197
193- // Open the new inventory for the player.
194- handler .schedule (() ->
195- player .openInventory (this .inventory )
196- );
198+ handler .ifOpen (player , menu -> {
199+ if (menu != this ) return ;
200+
201+ // Open the new inventory for the player.
202+ handler .schedule (() ->
203+ player .openInventory (this .inventory )
204+ );
205+ });
197206 }
198207
199208 /**
You can’t perform that action at this time.
0 commit comments