forked from Upstream/mmocore
PlayerData.get returns empty PlayerData instance if UUID not loaded
This commit is contained in:
parent
89788cd03b
commit
c48b1df43e
@ -103,6 +103,19 @@ public class PlayerData extends OfflinePlayerData {
|
||||
questData = new PlayerQuests(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* easily solves some issues where other plugins use PlayerData.get
|
||||
*/
|
||||
public static final PlayerData NOT_LOADED = new PlayerData();
|
||||
|
||||
@Deprecated
|
||||
private PlayerData() {
|
||||
super(UUID.randomUUID());
|
||||
|
||||
playerStats = new PlayerStats(this);
|
||||
questData = new PlayerQuests(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* update all references after /mmocore reload so there can be garbage
|
||||
* collection with old plugin objects like class or skill instances.
|
||||
|
@ -22,7 +22,7 @@ public abstract class PlayerDataManager {
|
||||
}
|
||||
|
||||
public PlayerData get(UUID uuid) {
|
||||
return map.get(uuid);
|
||||
return map.getOrDefault(uuid, PlayerData.NOT_LOADED);
|
||||
}
|
||||
|
||||
public abstract OfflinePlayerData getOffline(UUID uuid);
|
||||
|
Loading…
Reference in New Issue
Block a user