diff --git a/pom.xml b/pom.xml
index bc36ee3..183edbe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,14 +23,14 @@
org.bukkit
bukkit
- 1.9-R0.1-SNAPSHOT
+ 1.9.2-R0.1-SNAPSHOT
provided
org.bukkit
craftbukkit
- 1.9-R0.1-SNAPSHOT
+ 1.9.2-R0.1-SNAPSHOT
provided
diff --git a/src/main/java/com/lishid/openinv/commands/OpenInvCommand.java b/src/main/java/com/lishid/openinv/commands/OpenInvCommand.java
index ce7e8ba..66effa6 100644
--- a/src/main/java/com/lishid/openinv/commands/OpenInvCommand.java
+++ b/src/main/java/com/lishid/openinv/commands/OpenInvCommand.java
@@ -106,6 +106,7 @@ public class OpenInvCommand implements CommandExecutor {
if (player == null) {
return;
}
+
openInventory(player, target);
}
});
diff --git a/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java
index f8b74af..f2adfde 100644
--- a/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java
+++ b/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java
@@ -51,7 +51,6 @@ public class SpecialEnderChest extends InventorySubcontainer {
private void saveOnExit() {
if (transaction.isEmpty() && !playerOnline) {
owner.saveData();
- OpenInv.enderChests.remove(owner.getUniqueId());
}
}
@@ -82,6 +81,7 @@ public class SpecialEnderChest extends InventorySubcontainer {
public void onClose(CraftHumanEntity who) {
super.onClose(who);
saveOnExit();
+ OpenInv.enderChests.remove(owner.getUniqueId());
}
@Override
diff --git a/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java
index 18adb68..b0994ad 100644
--- a/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java
+++ b/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java
@@ -35,15 +35,14 @@ public class SpecialPlayerInventory extends PlayerInventory {
private final CraftInventory inventory = new CraftInventory(this);
private final ItemStack[] extra = new ItemStack[4];
- private final ItemStack[][] arrays;
private final CraftPlayer owner;
+ private ItemStack[][] arrays;
private boolean playerOnline;
public SpecialPlayerInventory(Player p, boolean online) {
super(((CraftPlayer) p).getHandle());
this.owner = (CraftPlayer) p;
reflectContents(getClass().getSuperclass(), player.inventory, this);
- this.arrays = new ItemStack[][] { this.items, this.armor, this.extraSlots, this.extra };
this.playerOnline = online;
OpenInv.inventories.put(owner.getUniqueId(), this);
}
@@ -70,6 +69,8 @@ public class SpecialPlayerInventory extends PlayerInventory {
} catch (IllegalAccessException e) {
e.printStackTrace();
}
+
+ arrays = new ItemStack[][] { this.items, this.armor, this.extraSlots, this.extra };
}
public Inventory getBukkitInventory() {
@@ -79,7 +80,6 @@ public class SpecialPlayerInventory extends PlayerInventory {
private void saveOnExit() {
if (transaction.isEmpty() && !playerOnline) {
owner.saveData();
- OpenInv.inventories.remove(owner.getUniqueId());
}
}
@@ -107,6 +107,7 @@ public class SpecialPlayerInventory extends PlayerInventory {
public void onClose(CraftHumanEntity who) {
super.onClose(who);
this.saveOnExit();
+ OpenInv.inventories.remove(owner.getUniqueId());
}
@Override
diff --git a/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java b/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java
index 9c2f9e4..2eb3ff1 100644
--- a/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java
+++ b/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java
@@ -30,6 +30,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.scheduler.BukkitRunnable;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
@@ -62,18 +63,28 @@ public class OpenInvPlayerListener implements Listener {
}
}
- @EventHandler(priority = EventPriority.MONITOR)
+ @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
- SpecialPlayerInventory inventory = OpenInv.inventories.get(player.getUniqueId());
+ final SpecialPlayerInventory inventory = OpenInv.inventories.get(player.getUniqueId());
if (inventory != null) {
- inventory.playerOffline();
+ new BukkitRunnable() {
+ @Override
+ public void run() {
+ inventory.playerOffline();
+ }
+ }.runTaskLater(plugin, 1);
}
- SpecialEnderChest enderChest = OpenInv.enderChests.get(player.getUniqueId());
+ final SpecialEnderChest enderChest = OpenInv.enderChests.get(player.getUniqueId());
if (enderChest != null) {
- enderChest.playerOffline();
+ new BukkitRunnable() {
+ @Override
+ public void run() {
+ enderChest.playerOffline();
+ }
+ }.runTaskLater(plugin, 1);
}
}