From 5db09bf45c03f719bdbc00ca523fc773ca4a7fdd Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 24 Nov 2014 05:24:13 -0800 Subject: [PATCH] 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. --- .../gmail/nossr50/datatypes/player/McMMOPlayer.java | 10 ++++++++-- .../com/gmail/nossr50/listeners/PlayerListener.java | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 842cd3954..ed7dc163d 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -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); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index dc65d8f07..6f546cb63 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -359,7 +359,7 @@ public class PlayerListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - mcMMOPlayer.logout(); + mcMMOPlayer.logout(false); } /**