Skip to content

Commit 7a01f8d

Browse files
committed
Change version to 1.1.1, fix bug with uncloseable inventory
1 parent 65f0528 commit 7a01f8d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'fr.minuskube.inv'
2-
version '1.1.0'
2+
version '1.1.1'
33

44
apply plugin: 'java'
55
apply plugin: 'maven'

src/main/java/fr/minuskube/inv/SmartInventory.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.List;
1414
import java.util.Optional;
1515

16+
@SuppressWarnings("unchecked")
1617
public class SmartInventory {
1718

1819
private String id;
@@ -32,6 +33,17 @@ private SmartInventory() {}
3233
public Inventory open(Player player, int page) {
3334
InventoryManager manager = SmartInvsPlugin.manager();
3435

36+
Optional<SmartInventory> oldInv = manager.getInventory(player);
37+
38+
oldInv.ifPresent(inv -> {
39+
inv.getListeners().stream()
40+
.filter(listener -> listener.getType() == InventoryCloseEvent.class)
41+
.forEach(listener -> ((InventoryListener<InventoryCloseEvent>) listener)
42+
.accept(new InventoryCloseEvent(player.getOpenInventory())));
43+
44+
manager.setInventory(player, null);
45+
});
46+
3547
InventoryContents contents = new InventoryContents.Impl(this);
3648
contents.pagination().page(page);
3749

@@ -56,9 +68,9 @@ public void close(Player player) {
5668
.forEach(listener -> ((InventoryListener<InventoryCloseEvent>) listener)
5769
.accept(new InventoryCloseEvent(player.getOpenInventory())));
5870

71+
manager.setInventory(player, null);
5972
player.closeInventory();
6073

61-
manager.setInventory(player, null);
6274
manager.setContents(player, null);
6375
}
6476

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: SmartInvs
2-
version: 1.1.0
2+
version: 1.1.1
33
description: Inventory API for your Bukkit Plugins.
44
author: MinusKube
55
website: https://github.com/MinusKube/SmartInvs

0 commit comments

Comments
 (0)