From 1f3f1ae748b64d2feda86705f47662114f641e0d Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sat, 28 Mar 2015 20:14:40 +0100 Subject: [PATCH] No longer loading the backpack on disconnect --- pom.xml | 2 +- .../pcgamingfreaks/georgh/MinePacks/Database/Database.java | 4 ++-- src/at/pcgamingfreaks/georgh/MinePacks/EventListener.java | 6 +++--- src/at/pcgamingfreaks/georgh/MinePacks/MinePacks.java | 2 +- src/at/pcgamingfreaks/georgh/MinePacks/OnCommand.java | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 836bc38..1fdcd71 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 at.pcgamingfreaks MinePacks - 1.6 + 1.6.1 in-project diff --git a/src/at/pcgamingfreaks/georgh/MinePacks/Database/Database.java b/src/at/pcgamingfreaks/georgh/MinePacks/Database/Database.java index a034717..20bec5a 100644 --- a/src/at/pcgamingfreaks/georgh/MinePacks/Database/Database.java +++ b/src/at/pcgamingfreaks/georgh/MinePacks/Database/Database.java @@ -62,10 +62,10 @@ public Backpack getBackpack(String title) return null; } - public Backpack getBackpack(OfflinePlayer player) + public Backpack getBackpack(OfflinePlayer player, boolean loadedonly) { Backpack lbp = findBackpack(player); - if(lbp == null) + if(lbp == null && !loadedonly) { lbp = LoadBackpack(player); if(lbp == null) diff --git a/src/at/pcgamingfreaks/georgh/MinePacks/EventListener.java b/src/at/pcgamingfreaks/georgh/MinePacks/EventListener.java index afd53c0..3ed1352 100644 --- a/src/at/pcgamingfreaks/georgh/MinePacks/EventListener.java +++ b/src/at/pcgamingfreaks/georgh/MinePacks/EventListener.java @@ -51,7 +51,7 @@ public void onDeath(PlayerDeathEvent event) Player player = event.getEntity(); if (drop_on_death && !player.hasPermission("backpack.KeepOnDeath")) { - Inventory BP = plugin.DB.getBackpack(player).getBackpack(); + Inventory BP = plugin.DB.getBackpack(player, false).getBackpack(); for (ItemStack i : BP.getContents()) { if (i != null) @@ -111,8 +111,8 @@ public void PlayerLoginEvent(PlayerJoinEvent event) @EventHandler public void PlayerLeaveEvent(PlayerQuitEvent event) { - Backpack bp = plugin.DB.getBackpack(event.getPlayer()); - if(!bp.isOpen()) + Backpack bp = plugin.DB.getBackpack(event.getPlayer(), true); + if(bp != null && !bp.isOpen()) { plugin.DB.UnloadBackpack(bp); } diff --git a/src/at/pcgamingfreaks/georgh/MinePacks/MinePacks.java b/src/at/pcgamingfreaks/georgh/MinePacks/MinePacks.java index 3433651..917c73e 100644 --- a/src/at/pcgamingfreaks/georgh/MinePacks/MinePacks.java +++ b/src/at/pcgamingfreaks/georgh/MinePacks/MinePacks.java @@ -68,7 +68,7 @@ public void onDisable() public void OpenBackpack(Player opener, OfflinePlayer owener, boolean editable) { - OpenBackpack(opener, DB.getBackpack(owener), editable); + OpenBackpack(opener, DB.getBackpack(owener, false), editable); } public void OpenBackpack(Player opener, Backpack backpack, boolean editable) diff --git a/src/at/pcgamingfreaks/georgh/MinePacks/OnCommand.java b/src/at/pcgamingfreaks/georgh/MinePacks/OnCommand.java index c63598c..631f9e7 100644 --- a/src/at/pcgamingfreaks/georgh/MinePacks/OnCommand.java +++ b/src/at/pcgamingfreaks/georgh/MinePacks/OnCommand.java @@ -63,7 +63,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String arg, String[] // Open player backpack if(player.hasPermission("backpack")) { - Backpack bp = plugin.DB.getBackpack(player); + Backpack bp = plugin.DB.getBackpack(player, false); if(bp == null) { player.sendMessage(Message_IvalidBackpack); @@ -128,7 +128,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String arg, String[] { OP = Bukkit.getOfflinePlayer(args[1]); } - Backpack BP = plugin.DB.getBackpack(OP); + Backpack BP = plugin.DB.getBackpack(OP, false); BP.getBackpack().clear(); player.sendMessage(Message_BackpackCleaned); }