diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java index b158a8ccf..366bc60af 100644 --- a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java +++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java @@ -17,14 +17,14 @@ import java.util.concurrent.ConcurrentHashMap; public class LimboCache { - private volatile static LimboCache singleton = null; + private volatile static LimboCache singleton; public ConcurrentHashMap cache; private JsonCache playerData; public AuthMe plugin; private LimboCache(AuthMe plugin) { this.plugin = plugin; - this.cache = new ConcurrentHashMap(); + this.cache = new ConcurrentHashMap<>(); this.playerData = new JsonCache(plugin); } @@ -77,7 +77,7 @@ public class LimboCache { } if (Settings.isForceSurvivalModeEnabled) { - if (Settings.isResetInventoryIfCreative && player.getGameMode() == GameMode.CREATIVE) { + if (Settings.isResetInventoryIfCreative && gameMode == GameMode.CREATIVE) { ResetInventoryEvent event = new ResetInventoryEvent(player); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -123,7 +123,7 @@ public class LimboCache { if (this.hasLimboPlayer(player.getName().toLowerCase())) { this.deleteLimboPlayer(player.getName().toLowerCase()); } - this.addLimboPlayer(player); + addLimboPlayer(player); } } diff --git a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java index b6362624a..7099486be 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java @@ -127,11 +127,28 @@ public class AsyncronousJoin { } placePlayerSafely(player, spawnLoc); LimboCache.getInstance().updateLimboPlayer(player); - try { - DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour()); - playerBackup.createCache(player, dataFile); - } catch (Exception e) { - ConsoleLogger.showError("Error on creating an inventory cache for " + name + ", maybe inventory wipe in preparation..."); + DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour()); + playerBackup.createCache(player, dataFile); + // protect inventory + if (Settings.protectInventoryBeforeLogInEnabled) { + LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); + ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour()); + plugin.getServer().getPluginManager().callEvent(ev); + if (ev.isCancelled()) { + if (!Settings.noConsoleSpam) + ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); + } else { + final ItemStack[] inv = ev.getEmptyArmor(); + final ItemStack[] armor = ev.getEmptyArmor(); + sched.scheduleSyncDelayedTask(plugin, new Runnable() { + + @Override + public void run() { + plugin.api.setPlayerInventory(player, inv, armor); + } + + }); + } } } else { if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) { @@ -171,26 +188,6 @@ public class AsyncronousJoin { } } - if (Settings.protectInventoryBeforeLogInEnabled) { - LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); - ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour()); - plugin.getServer().getPluginManager().callEvent(ev); - if (ev.isCancelled()) { - if (!Settings.noConsoleSpam) - ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); - } else { - final ItemStack[] inv = ev.getEmptyArmor(); - final ItemStack[] armor = ev.getEmptyArmor(); - sched.scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - plugin.api.setPlayerInventory(player, inv, armor); - } - - }); - } - } String[] msg; if (Settings.emailRegistration) { msg = database.isAuthAvailable(name) ? m.send("login_msg") : m.send("reg_email_msg");