Skip to content

Commit

Permalink
Fix error when opening inventory from init method: Fixes #135
Browse files Browse the repository at this point in the history
  • Loading branch information
MinusKube committed Jun 8, 2021
1 parent db84c2c commit 9c9dbbe
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/fr/minuskube/inv/SmartInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public Inventory open(Player player, int page) {
try {
this.provider.init(player, contents);

// If the current inventory has been closed or replaced within the init method, returns
if (!this.manager.getContents(player).equals(Optional.of(contents))) {
return null;
}

InventoryOpener opener = this.manager.findOpener(type)
.orElseThrow(() -> new IllegalStateException("No opener found for the inventory type " + type.name()));
Inventory handle = opener.open(this, player);
Expand Down

0 comments on commit 9c9dbbe

Please sign in to comment.