* Fixed - player data glitch and online/offline events #41
@@ -51,7 +51,6 @@ public class SpecialEnderChest extends InventorySubcontainer {
 | 
				
			|||||||
    private void saveOnExit() {
 | 
					    private void saveOnExit() {
 | 
				
			||||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
					        if (transaction.isEmpty() && !playerOnline) {
 | 
				
			||||||
            owner.saveData();
 | 
					            owner.saveData();
 | 
				
			||||||
            OpenInv.enderChests.remove(owner.getUniqueId());
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -82,6 +81,7 @@ public class SpecialEnderChest extends InventorySubcontainer {
 | 
				
			|||||||
    public void onClose(CraftHumanEntity who) {
 | 
					    public void onClose(CraftHumanEntity who) {
 | 
				
			||||||
        super.onClose(who);
 | 
					        super.onClose(who);
 | 
				
			||||||
        saveOnExit();
 | 
					        saveOnExit();
 | 
				
			||||||
 | 
					        OpenInv.enderChests.remove(owner.getUniqueId());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,7 @@ public class SpecialPlayerInventory extends PlayerInventory {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private final CraftInventory inventory = new CraftInventory(this);
 | 
					    private final CraftInventory inventory = new CraftInventory(this);
 | 
				
			||||||
    private final ItemStack[] extra = new ItemStack[4];
 | 
					    private final ItemStack[] extra = new ItemStack[4];
 | 
				
			||||||
    private final ItemStack[][] arrays;
 | 
					    private ItemStack[][] arrays;
 | 
				
			||||||
    private final CraftPlayer owner;
 | 
					    private final CraftPlayer owner;
 | 
				
			||||||
    private boolean playerOnline;
 | 
					    private boolean playerOnline;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -41,7 +41,6 @@ public class SpecialPlayerInventory extends PlayerInventory {
 | 
				
			|||||||
        super(((CraftPlayer) p).getHandle());
 | 
					        super(((CraftPlayer) p).getHandle());
 | 
				
			||||||
        this.owner = (CraftPlayer) p;
 | 
					        this.owner = (CraftPlayer) p;
 | 
				
			||||||
        reflectContents(getClass().getSuperclass(), player.inventory, this);
 | 
					        reflectContents(getClass().getSuperclass(), player.inventory, this);
 | 
				
			||||||
        this.arrays = new ItemStack[][] { this.items, this.armor, this.extraSlots, this.extra };
 | 
					 | 
				
			||||||
        this.playerOnline = online;
 | 
					        this.playerOnline = online;
 | 
				
			||||||
        OpenInv.inventories.put(owner.getUniqueId(), this);
 | 
					        OpenInv.inventories.put(owner.getUniqueId(), this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -68,6 +67,7 @@ public class SpecialPlayerInventory extends PlayerInventory {
 | 
				
			|||||||
        } catch (IllegalAccessException e) {
 | 
					        } catch (IllegalAccessException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        arrays = new ItemStack[][] { this.items, this.armor, this.extraSlots, this.extra };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Inventory getBukkitInventory() {
 | 
					    public Inventory getBukkitInventory() {
 | 
				
			||||||
@@ -77,7 +77,6 @@ public class SpecialPlayerInventory extends PlayerInventory {
 | 
				
			|||||||
    private void saveOnExit() {
 | 
					    private void saveOnExit() {
 | 
				
			||||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
					        if (transaction.isEmpty() && !playerOnline) {
 | 
				
			||||||
            owner.saveData();
 | 
					            owner.saveData();
 | 
				
			||||||
            OpenInv.inventories.remove(owner.getUniqueId());
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -105,6 +104,7 @@ public class SpecialPlayerInventory extends PlayerInventory {
 | 
				
			|||||||
    public void onClose(CraftHumanEntity who) {
 | 
					    public void onClose(CraftHumanEntity who) {
 | 
				
			||||||
        super.onClose(who);
 | 
					        super.onClose(who);
 | 
				
			||||||
        this.saveOnExit();
 | 
					        this.saveOnExit();
 | 
				
			||||||
 | 
					        OpenInv.inventories.remove(owner.getUniqueId());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,6 +30,7 @@ import org.bukkit.event.block.Action;
 | 
				
			|||||||
import org.bukkit.event.player.PlayerInteractEvent;
 | 
					import org.bukkit.event.player.PlayerInteractEvent;
 | 
				
			||||||
import org.bukkit.event.player.PlayerJoinEvent;
 | 
					import org.bukkit.event.player.PlayerJoinEvent;
 | 
				
			||||||
import org.bukkit.event.player.PlayerQuitEvent;
 | 
					import org.bukkit.event.player.PlayerQuitEvent;
 | 
				
			||||||
 | 
					import org.bukkit.scheduler.BukkitRunnable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.lishid.openinv.OpenInv;
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
@@ -52,19 +53,29 @@ public class OpenInvPlayerListener implements Listener {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @EventHandler(priority = EventPriority.MONITOR)
 | 
					    @EventHandler
 | 
				
			||||||
    public void onPlayerQuit(PlayerQuitEvent event) {
 | 
					    public void onPlayerQuit(PlayerQuitEvent event) {
 | 
				
			||||||
        Player player = event.getPlayer();
 | 
					        Player player = event.getPlayer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        SpecialPlayerInventory inventory = OpenInv.inventories.get(player.getUniqueId());
 | 
					        final SpecialPlayerInventory inventory = OpenInv.inventories.get(player.getUniqueId());
 | 
				
			||||||
        if (inventory != null) {
 | 
					        if (inventory != null) {
 | 
				
			||||||
 | 
					            new BukkitRunnable() {
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void run() {
 | 
				
			||||||
                    inventory.playerOffline();
 | 
					                    inventory.playerOffline();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }.runTaskLater(OpenInv.mainPlugin, 1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        SpecialEnderChest chest = OpenInv.enderChests.get(player.getUniqueId());
 | 
					        final SpecialEnderChest chest = OpenInv.enderChests.get(player.getUniqueId());
 | 
				
			||||||
        if (chest != null) {
 | 
					        if (chest != null) {
 | 
				
			||||||
 | 
					            new BukkitRunnable() {
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void run() {
 | 
				
			||||||
                    chest.playerOffline();
 | 
					                    chest.playerOffline();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }.runTaskLater(OpenInv.mainPlugin, 1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @EventHandler
 | 
					    @EventHandler
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user