mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Fix NPE for new data tracker
This commit is contained in:
parent
3ce3ac5350
commit
426b2d27e7
@ -16,9 +16,7 @@ public final class UserManager {
|
||||
|
||||
private static HashSet<McMMOPlayer> playerDataSet; //Used to track players for sync saves on shutdown
|
||||
|
||||
private UserManager() {
|
||||
playerDataSet = new HashSet<>();
|
||||
}
|
||||
private UserManager() {}
|
||||
|
||||
/**
|
||||
* Track a new user.
|
||||
@ -27,6 +25,10 @@ public final class UserManager {
|
||||
*/
|
||||
public static void track(McMMOPlayer mcMMOPlayer) {
|
||||
mcMMOPlayer.getPlayer().setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
|
||||
|
||||
if(playerDataSet == null)
|
||||
playerDataSet = new HashSet<>();
|
||||
|
||||
playerDataSet.add(mcMMOPlayer); //for sync saves on shutdown
|
||||
}
|
||||
|
||||
@ -42,6 +44,8 @@ public final class UserManager {
|
||||
public static void remove(Player player) {
|
||||
McMMOPlayer mcMMOPlayer = getPlayer(player);
|
||||
player.removeMetadata(mcMMO.playerDataKey, mcMMO.p);
|
||||
|
||||
if(playerDataSet != null && playerDataSet.contains(mcMMOPlayer))
|
||||
playerDataSet.remove(mcMMOPlayer); //Clear sync save tracking
|
||||
}
|
||||
|
||||
@ -53,6 +57,7 @@ public final class UserManager {
|
||||
remove(player);
|
||||
}
|
||||
|
||||
if(playerDataSet != null)
|
||||
playerDataSet.clear(); //Clear sync save tracking
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user