mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +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) {
|
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);
|
playersCache.put(jPlayer.getUserName().toLowerCase(), jPlayer);
|
||||||
if (jPlayer.getPlayerUUID() != null)
|
if (jPlayer.getPlayerUUID() != null && playersUUIDCache.get(jPlayer.getPlayerUUID()) == null)
|
||||||
playersUUIDCache.put(jPlayer.getPlayerUUID(), jPlayer);
|
playersUUIDCache.put(jPlayer.getPlayerUUID(), jPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(JobsPlayer 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);
|
players.put(jPlayer.getUserName().toLowerCase(), jPlayer);
|
||||||
if (jPlayer.getPlayerUUID() != null)
|
if (jPlayer.getPlayerUUID() != null && playersUUID.get(jPlayer.getPlayerUUID()) == null)
|
||||||
playersUUID.put(jPlayer.getPlayerUUID(), jPlayer);
|
playersUUID.put(jPlayer.getPlayerUUID(), jPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JobsPlayer removePlayer(Player player) {
|
public JobsPlayer removePlayer(Player player) {
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
if (players.get(player.getName()) != null)
|
||||||
players.remove(player.getName().toLowerCase());
|
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;
|
return jPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,6 +201,7 @@ public class PlayerManager {
|
|||||||
JobsPlayer jPlayer = getJobsPlayer(player);
|
JobsPlayer jPlayer = getJobsPlayer(player);
|
||||||
if (jPlayer == null)
|
if (jPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Jobs.getGCManager().saveOnDisconnect()) {
|
if (Jobs.getGCManager().saveOnDisconnect()) {
|
||||||
jPlayer.onDisconnect();
|
jPlayer.onDisconnect();
|
||||||
jPlayer.save();
|
jPlayer.save();
|
||||||
|
Loading…
Reference in New Issue
Block a user