mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
Added a check to prevent playerdata from saving when it hasn't been fully loaded yet
This commit is contained in:
parent
59dd7ba4e1
commit
6c82011a77
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user