mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
Some null checks in playerManager
This commit is contained in:
parent
355074dffd
commit
d1417cc35a
@ -104,24 +104,28 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
public void addPlayerToCache(JobsPlayer jPlayer) {
|
||||
if (jPlayer.getUserName() != null)
|
||||
if (jPlayer.getUserName() != null && playersCache.get(jPlayer.getUserName().toLowerCase()) == null)
|
||||
playersCache.put(jPlayer.getUserName().toLowerCase(), jPlayer);
|
||||
if (jPlayer.getPlayerUUID() != null)
|
||||
if (jPlayer.getPlayerUUID() != null && playersUUIDCache.get(jPlayer.getPlayerUUID()) == null)
|
||||
playersUUIDCache.put(jPlayer.getPlayerUUID(), jPlayer);
|
||||
}
|
||||
|
||||
public void addPlayer(JobsPlayer jPlayer) {
|
||||
if (jPlayer.getUserName() != null)
|
||||
if (jPlayer.getUserName() != null && players.get(jPlayer.getUserName().toLowerCase()) == null)
|
||||
players.put(jPlayer.getUserName().toLowerCase(), jPlayer);
|
||||
if (jPlayer.getPlayerUUID() != null)
|
||||
if (jPlayer.getPlayerUUID() != null && playersUUID.get(jPlayer.getPlayerUUID()) == null)
|
||||
playersUUID.put(jPlayer.getPlayerUUID(), jPlayer);
|
||||
}
|
||||
|
||||
public JobsPlayer removePlayer(Player player) {
|
||||
if (player == null)
|
||||
return null;
|
||||
|
||||
if (players.get(player.getName()) != null)
|
||||
players.remove(player.getName().toLowerCase());
|
||||
JobsPlayer jPlayer = playersUUID.remove(player.getUniqueId());
|
||||
|
||||
JobsPlayer jPlayer = playersUUID.get(player.getUniqueId()) != null ?
|
||||
playersUUID.remove(player.getUniqueId()) : null;
|
||||
return jPlayer;
|
||||
}
|
||||
|
||||
@ -197,6 +201,7 @@ public class PlayerManager {
|
||||
JobsPlayer jPlayer = getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
if (Jobs.getGCManager().saveOnDisconnect()) {
|
||||
jPlayer.onDisconnect();
|
||||
jPlayer.save();
|
||||
|
Loading…
Reference in New Issue
Block a user