mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 11:14:44 +02:00
mcMMO now checks in all places for a loaded profile before executing processing on said profile
This commit is contained in:
@ -1158,6 +1158,13 @@ public final class ExperienceAPI {
|
||||
return formulaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use UserManager::getPlayer(Player player) instead
|
||||
* @param player target player
|
||||
* @return McMMOPlayer for that player if the profile is loaded, otherwise null
|
||||
* @throws McMMOPlayerNotFoundException
|
||||
*/
|
||||
@Deprecated
|
||||
private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException {
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
throw new McMMOPlayerNotFoundException(player);
|
||||
|
@ -41,6 +41,9 @@ public final class PartyAPI {
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return false;
|
||||
|
||||
return UserManager.getPlayer(player).inParty();
|
||||
}
|
||||
|
||||
@ -79,6 +82,10 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
@ -113,7 +120,12 @@ public final class PartyAPI {
|
||||
* @param partyName The party to add the player to
|
||||
* @param bypassLimit if true bypasses party size limits
|
||||
*/
|
||||
//TODO: bypasslimit not used?
|
||||
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
@ -131,6 +143,10 @@ public final class PartyAPI {
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
PartyManager.removeFromParty(UserManager.getPlayer(player));
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,6 @@ public class McMMOPlayerNotFoundException extends RuntimeException {
|
||||
private static final long serialVersionUID = 761917904993202836L;
|
||||
|
||||
public McMMOPlayerNotFoundException(Player player) {
|
||||
super("McMMOPlayer object was not found for: " + player.getName() + " " + player.getUniqueId());
|
||||
super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet!] : " + player.getName() + " " + player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user