mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Move PlayerQuit logic to mcMMOPlayer.logout()
This commit is contained in:
		@@ -5,6 +5,9 @@ import java.util.Map;
 | 
				
			|||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
import java.util.UUID;
 | 
					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.GameMode;
 | 
				
			||||||
import org.bukkit.Location;
 | 
					import org.bukkit.Location;
 | 
				
			||||||
import org.bukkit.Sound;
 | 
					import org.bukkit.Sound;
 | 
				
			||||||
@@ -879,4 +882,22 @@ public class McMMOPlayer {
 | 
				
			|||||||
    public FixedMetadataValue getPlayerMetadata() {
 | 
					    public FixedMetadataValue getPlayerMetadata() {
 | 
				
			||||||
        return playerMetadata;
 | 
					        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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
 | 
				
			|||||||
import com.gmail.nossr50.locale.LocaleLoader;
 | 
					import com.gmail.nossr50.locale.LocaleLoader;
 | 
				
			||||||
import com.gmail.nossr50.party.ShareHandler;
 | 
					import com.gmail.nossr50.party.ShareHandler;
 | 
				
			||||||
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
 | 
					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.fishing.FishingManager;
 | 
				
			||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
 | 
					import com.gmail.nossr50.skills.herbalism.HerbalismManager;
 | 
				
			||||||
import com.gmail.nossr50.skills.mining.MiningManager;
 | 
					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.Motd;
 | 
				
			||||||
import com.gmail.nossr50.util.Permissions;
 | 
					import com.gmail.nossr50.util.Permissions;
 | 
				
			||||||
import com.gmail.nossr50.util.player.UserManager;
 | 
					import com.gmail.nossr50.util.player.UserManager;
 | 
				
			||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
 | 
					 | 
				
			||||||
import com.gmail.nossr50.util.skills.SkillUtils;
 | 
					import com.gmail.nossr50.util.skills.SkillUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class PlayerListener implements Listener {
 | 
					public class PlayerListener implements Listener {
 | 
				
			||||||
@@ -361,16 +359,7 @@ public class PlayerListener implements Listener {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
 | 
					        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
 | 
				
			||||||
 | 
					        mcMMOPlayer.logout();
 | 
				
			||||||
        mcMMOPlayer.resetAbilityMode();
 | 
					 | 
				
			||||||
        BleedTimerTask.bleedOut(player);
 | 
					 | 
				
			||||||
        mcMMOPlayer.getProfile().scheduleAsyncSave();
 | 
					 | 
				
			||||||
        UserManager.remove(player);
 | 
					 | 
				
			||||||
        ScoreboardManager.teardownPlayer(player);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (mcMMOPlayer.inParty()) {
 | 
					 | 
				
			||||||
            mcMMOPlayer.logoutParty();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user