Allow synchronous save on logout

This is intended for plugins that have foreknowledge of a logout
happening (e.g. a BungeeCord server hop about to happen), so that they
can tell mcMMO to save the data, and the new server will be able to pull
the profile correctly from the database.
This commit is contained in:
riking 2014-11-24 05:24:13 -08:00
parent f4406bd9cf
commit 5db09bf45c
2 changed files with 9 additions and 3 deletions

View File

@ -885,13 +885,19 @@ public class McMMOPlayer {
/**
* This method is called by PlayerQuitEvent to tear down the mcMMOPlayer.
*
* @param syncSave if true, data is saved synchronously
*/
public void logout() {
public void logout(boolean syncSave) {
Player thisPlayer = getPlayer();
resetAbilityMode();
BleedTimerTask.bleedOut(thisPlayer);
getProfile().scheduleAsyncSave();
if (syncSave) {
getProfile().save();
} else {
getProfile().scheduleAsyncSave();
}
UserManager.remove(thisPlayer);
ScoreboardManager.teardownPlayer(thisPlayer);

View File

@ -359,7 +359,7 @@ public class PlayerListener implements Listener {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
mcMMOPlayer.logout();
mcMMOPlayer.logout(false);
}
/**