diff --git a/src/main/java/com/lishid/openinv/internal/ISpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/ISpecialPlayerInventory.java index f8ef50b2..4cc2b321 100644 --- a/src/main/java/com/lishid/openinv/internal/ISpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/ISpecialPlayerInventory.java @@ -23,7 +23,7 @@ public interface ISpecialPlayerInventory { public Inventory getBukkitInventory(); - public boolean inventoryRemovalCheck(); + public boolean inventoryRemovalCheck(boolean save); public void setPlayerOnline(Player player); diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java index 326a2e47..41c7ecf9 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java index b2e3b576..cd5f667b 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java index c85aebfd..52614a90 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java index d307c335..d90f3bfe 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java index 79e4fa06..0796b8b1 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java index 833f8137..85ee0a4e 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java @@ -51,18 +51,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -70,13 +73,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java index 0b4a5bb7..99c94051 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java index b2705770..fb17a425 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java index 847b18f5..d3f0771e 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java index 85ba2c1b..c8b9b0d3 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java index 5471848e..fd7f3e4f 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java index 1d5a5b88..d8463e80 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java index 9a555c49..fcded9d2 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java index 7fae684d..60b22ed5 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java index 058d7ace..e0ed3cbe 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java @@ -50,18 +50,21 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override public void setPlayerOnline(Player player) { if (!playerOnline) { - CraftPlayer p = (CraftPlayer) player; - p.getHandle().inventory.items = this.items; - p.getHandle().inventory.armor = this.armor; - p.saveData(); + owner = (CraftPlayer) player; + this.player = owner.getHandle(); + this.player.inventory.items = this.items; + this.player.inventory.armor = this.armor; playerOnline = true; } } @@ -69,13 +72,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override diff --git a/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialPlayerInventory.java index b6369b93..880eaa85 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialPlayerInventory.java @@ -89,9 +89,12 @@ public Inventory getBukkitInventory() { } @Override - public boolean inventoryRemovalCheck() { - owner.saveData(); - return transaction.isEmpty() && !playerOnline; + public boolean inventoryRemovalCheck(boolean save) { + boolean offline = transaction.isEmpty() && !playerOnline; + if (offline && save) { + owner.saveData(); + } + return offline; } @Override @@ -100,7 +103,6 @@ public void setPlayerOnline(Player player) { owner = (CraftPlayer) player; this.player = owner.getHandle(); setItemArrays(this.player.inventory, items, armor, extraSlots); - owner.saveData(); playerOnline = true; } } @@ -108,13 +110,13 @@ public void setPlayerOnline(Player player) { @Override public boolean setPlayerOffline() { playerOnline = false; - return this.inventoryRemovalCheck(); + return this.inventoryRemovalCheck(false); } @Override public void onClose(CraftHumanEntity who) { super.onClose(who); - this.inventoryRemovalCheck(); + this.inventoryRemovalCheck(true); } @Override