diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java index 486a112..04d3e43 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java @@ -207,7 +207,7 @@ public boolean isBungeeCordModeEnabled() { logger.warning("You have BungeeCord enabled, but it looks like you have not enabled it in your spigot.yml! You probably should check your configuration."); } - else if(!useBungee && spigotUsesBungee && getDatabaseType().equals("mysql")) + else if(!useBungee && spigotUsesBungee && getDatabaseType() == DatabaseType.MYSQL) { logger.warning("Your server is running behind a BungeeCord server. If you are using the plugin on more than one server please make sure to also enable the 'UseBungeeCord' config option."); } diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java index 567901e..98f6120 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java @@ -74,7 +74,7 @@ public void close() backend.setAsyncSave(false); unCacheStrategy.close(); cache.getCachedPlayers().forEach(player -> { - Backpack bp = ((Backpack) player.getBackpack()); + Backpack bp = player.getBackpack(); if(bp != null) bp.closeAll(); }); //TODO change when multi-page backpacks are added cache.close(); @@ -151,17 +151,19 @@ private void loadPlayer(final @NotNull MinepacksPlayerData player) backend.loadPlayer(player); player.notifyOnLoad(p -> { - if(bungeeCordMode) + if(!bungeeCordMode) { - //TODO delayed backpack loading - } - else - { - backend.loadBackpack(player); + loadBackpack(player); } }); } + public void loadBackpack(final @NotNull MinepacksPlayerData player) + { + player.setBackpackLoadingRequested(true); + backend.loadPlayer(player); + } + @EventHandler public void onPlayerLoginEvent(final @NotNull PlayerJoinEvent event) { diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/MinepacksPlayerData.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/MinepacksPlayerData.java index 85bd913..2a9e43b 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/MinepacksPlayerData.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/MinepacksPlayerData.java @@ -54,6 +54,7 @@ public class MinepacksPlayerData implements MinepacksPlayerExtended, ICacheableP private ItemConfig backpackStyle = null; @Getter private Backpack backpack = null; @Getter private long cooldown = 0; + @Getter @Setter private boolean backpackLoadingRequested = false; @Getter @Setter private Object databaseKey = null; private final Queue> backpackLoadedQueue = new ConcurrentLinkedQueue<>(); @@ -212,7 +213,11 @@ public boolean isBackpackLoaded() public void getBackpack(final @NotNull Callback callback) { if(isBackpackLoaded()) callback.onResult(backpack); - else backpackLoadedQueue.add(callback); + else + { + if(!backpackLoadingRequested) Minepacks.getInstance().getDatabase().loadBackpack(this); + backpackLoadedQueue.add(callback); + } } @Override diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java index 7076a98..e53c2f9 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java @@ -162,7 +162,7 @@ private void checkOldDataFolder() if(oldPluginFolder.exists() && !oldPluginFolder.renameTo(getDataFolder())) { getLogger().warning("Failed to rename the plugins data-folder.\n" + - "Please rename the \"MinePacks\" folder to \"Minepacks\" and restart the server, to move your data from Minepacks V1.X to Minepacks V2.X!"); + "Please rename the \"MinePacks\" folder to \"Minepacks\" and restart the server, to move your data from Minepacks V1.X to Minepacks V2.X!"); } } }