Skip to content

Commit

Permalink
fix: close current inventory when opening a book
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Apr 15, 2024
1 parent 7daf8d6 commit e8e22a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/net/minestom/server/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,11 @@ public void hideBossBar(@NotNull BossBar bar) {

@Override
public void openBook(@NotNull Book book) {
// Close the open inventory if there is one because the book will replace it.
if (getOpenInventory() != null) {
closeInventory();
}

final ItemStack writtenBook = ItemStack.builder(Material.WRITTEN_BOOK)
.meta(WrittenBookMeta.class, builder -> builder.resolved(false)
.generation(WrittenBookMeta.WrittenBookGeneration.ORIGINAL)
Expand Down

0 comments on commit e8e22a2

Please sign in to comment.