From 8a507de8d63030c0486a3abbbc054e5bbe202368 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 22 Dec 2020 19:28:47 -0800 Subject: [PATCH] brain getting tired, time for break, more api migration included --- .../gmail/nossr50/listeners/PlayerListener.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 0da39109c..cbd87f3ce 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -276,12 +276,13 @@ public class PlayerListener implements Listener { } //Profile not loaded - if(mcMMO.getUserManager().queryPlayer(player) == null) - { + McMMOPlayer mmoPlayer = (McMMOPlayer) mcMMO.getUserManager().queryPlayer(player); + + if(mmoPlayer == null) { return; } - FishingManager fishingManager = mcMMO.getUserManager().queryPlayer(player).getFishingManager(); + FishingManager fishingManager = mmoPlayer.getFishingManager(); switch (event.getState()) { case CAUGHT_FISH: @@ -525,16 +526,15 @@ public class PlayerListener implements Listener { } //Profile not loaded - if(mcMMO.getUserManager().queryPlayer(player) == null) - { + OnlineMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player); + + if(mmoPlayer == null) { return; } - //No need for null checks here - OnlineMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player); //TODO: There's an issue with using Async saves on player quit //TODO: Basically there are conditions in which an async task does not execute fast enough to save the data if the server shutdown shortly after this task was scheduled - mcMMO.getUserManager().saveUserWithDelay(mmoPlayer.getPersistentPlayerData(), false, 20); + mcMMO.getUserManager().saveUserWithDelay(mmoPlayer.getMMOPlayerData(), false, 20); mcMMO.getUserManager().cleanupPlayer(mmoPlayer); //Handles cleaning up the player when their profile is no longer needed }