diff --git a/src/main/java/net/Indyuce/mmocore/MMOCore.java b/src/main/java/net/Indyuce/mmocore/MMOCore.java index c4e34745..8909bbe3 100644 --- a/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -352,7 +352,7 @@ public class MMOCore extends JavaPlugin { new BukkitRunnable() { public void run() { for (PlayerData loaded : PlayerData.getAll()) - dataProvider.getDataManager().saveData(loaded); + if(loaded.isFullyLoaded()) dataProvider.getDataManager().saveData(loaded); for (Guild guild : dataProvider.getGuildManager().getAll()) dataProvider.getGuildManager().save(guild); @@ -363,6 +363,7 @@ public class MMOCore extends JavaPlugin { public void onDisable() { for (PlayerData data : PlayerData.getAll()) { + if(!data.isFullyLoaded()) return; data.getQuestData().resetBossBar(); dataProvider.getDataManager().saveData(data); } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 4fb107b5..e03c86b1 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -97,6 +97,8 @@ public class PlayerData extends OfflinePlayerData { public boolean nocd; public CombatRunnable combat; + private boolean fullyLoaded = false; + public PlayerData(MMOPlayerData mmoData) { super(mmoData.getUniqueId()); @@ -577,6 +579,14 @@ public class PlayerData extends OfflinePlayerData { stellium = Math.max(0, Math.min(amount, getStats().getStat(StatType.MAX_STELLIUM))); } + public boolean isFullyLoaded() { + return fullyLoaded; + } + + public void setFullyLoaded() { + this.fullyLoaded = true; + } + public boolean isCasting() { return skillCasting != null; } diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java b/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java index 68c4767d..11de26de 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java @@ -105,6 +105,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager { } } } + data.setFullyLoaded(); } catch (SQLException e) { e.printStackTrace(); } @@ -249,7 +250,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager { @Override public void remove(PlayerData data) { - saveData(data); + if(data.isFullyLoaded()) saveData(data); remove(data.getUniqueId()); } } diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java b/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java index 3d95c6c1..cc0e4f4b 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java @@ -67,6 +67,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager { } catch (IllegalArgumentException exception) { MMOCore.log(Level.WARNING, "Could not load class info '" + key + "': " + exception.getMessage()); } + data.setFullyLoaded(); } @Override