ソースを参照

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.
riking 10 年 前
コミット
5db09bf45c

+ 8 - 2
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);

+ 1 - 1
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);
     }
 
     /**