From f4406bd9cf3a389ff996814e7352c422f9ebb74e Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 24 Nov 2014 05:23:37 -0800 Subject: [PATCH 1/4] Move PlayerQuit logic to mcMMOPlayer.logout() --- .../nossr50/datatypes/player/McMMOPlayer.java | 21 +++++++++++++++++++ .../nossr50/listeners/PlayerListener.java | 13 +----------- 2 files changed, 22 insertions(+), 12 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 a818d7665..842cd3954 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -5,6 +5,9 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import com.gmail.nossr50.runnables.skills.BleedTimerTask; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; @@ -879,4 +882,22 @@ public class McMMOPlayer { public FixedMetadataValue getPlayerMetadata() { return playerMetadata; } + + /** + * This method is called by PlayerQuitEvent to tear down the mcMMOPlayer. + */ + public void logout() { + Player thisPlayer = getPlayer(); + resetAbilityMode(); + BleedTimerTask.bleedOut(thisPlayer); + + getProfile().scheduleAsyncSave(); + + UserManager.remove(thisPlayer); + ScoreboardManager.teardownPlayer(thisPlayer); + + if (inParty()) { + party.removeOnlineMember(thisPlayer); + } + } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 3e6893834..dc65d8f07 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -42,7 +42,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; -import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; @@ -62,7 +61,6 @@ import com.gmail.nossr50.util.MobHealthbarUtils; import com.gmail.nossr50.util.Motd; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; -import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.skills.SkillUtils; public class PlayerListener implements Listener { @@ -361,16 +359,7 @@ public class PlayerListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - - mcMMOPlayer.resetAbilityMode(); - BleedTimerTask.bleedOut(player); - mcMMOPlayer.getProfile().scheduleAsyncSave(); - UserManager.remove(player); - ScoreboardManager.teardownPlayer(player); - - if (mcMMOPlayer.inParty()) { - mcMMOPlayer.logoutParty(); - } + mcMMOPlayer.logout(); } /** From 5db09bf45c03f719bdbc00ca523fc773ca4a7fdd Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 24 Nov 2014 05:24:13 -0800 Subject: [PATCH 2/4] 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); } /** From d0881ab3fd48485ac334632cdf9e213bfad93b3e Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 24 Nov 2014 05:28:28 -0800 Subject: [PATCH 3/4] Downgrade Bukkit to 1.7.9 to compile --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index de4aa4b0a..c7bb70308 100755 --- a/pom.xml +++ b/pom.xml @@ -136,7 +136,7 @@ org.bukkit bukkit - 1.7.10-R0.1-SNAPSHOT + 1.7.9-R0.2 jar provided From 3275395d53a4abfa8cc63820e8e6a860709023b4 Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 24 Nov 2014 05:28:46 -0800 Subject: [PATCH 4/4] Remove dead logoutParty() method --- .../java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java | 4 ---- 1 file changed, 4 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 ed7dc163d..4f8bcf019 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -588,10 +588,6 @@ public class McMMOPlayer { party.addOnlineMember(this.getPlayer()); } - public void logoutParty() { - party.removeOnlineMember(this.getPlayer()); - } - public int getItemShareModifier() { if (itemShareModifier < 10) { setItemShareModifier(10);