mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-30 14:43:49 +01:00
Puts a null check on player UUID
It's possible for fake players to have null UUIDs apparently. So this check avoids an NPE.
This commit is contained in:
parent
c4e28b7937
commit
f0564b7c78
@ -142,10 +142,11 @@ public class JoinLeaveListener implements Listener {
|
|||||||
* @param user Targeted user.
|
* @param user Targeted user.
|
||||||
*/
|
*/
|
||||||
private void clearPlayersInventory(World world, @NonNull User user) {
|
private void clearPlayersInventory(World world, @NonNull User user) {
|
||||||
|
if (user.getUniqueId() == null) return;
|
||||||
// Clear inventory if required
|
// Clear inventory if required
|
||||||
Players playerData = players.getPlayer(user.getUniqueId());
|
Players playerData = players.getPlayer(user.getUniqueId());
|
||||||
|
|
||||||
if (playerData.getPendingKicks().contains(world.getName())) {
|
if (playerData != null && playerData.getPendingKicks().contains(world.getName())) {
|
||||||
if (plugin.getIWM().isOnLeaveResetEnderChest(world)) {
|
if (plugin.getIWM().isOnLeaveResetEnderChest(world)) {
|
||||||
user.getPlayer().getEnderChest().clear();
|
user.getPlayer().getEnderChest().clear();
|
||||||
}
|
}
|
||||||
@ -214,13 +215,13 @@ public class JoinLeaveListener implements Listener {
|
|||||||
|
|
||||||
// Call Protection Range Change event. Does not support cancelling.
|
// Call Protection Range Change event. Does not support cancelling.
|
||||||
IslandEvent.builder()
|
IslandEvent.builder()
|
||||||
.island(island)
|
.island(island)
|
||||||
.location(island.getCenter())
|
.location(island.getCenter())
|
||||||
.reason(IslandEvent.Reason.RANGE_CHANGE)
|
.reason(IslandEvent.Reason.RANGE_CHANGE)
|
||||||
.involvedPlayer(user.getUniqueId())
|
.involvedPlayer(user.getUniqueId())
|
||||||
.admin(true)
|
.admin(true)
|
||||||
.protectionRange(range, oldRange)
|
.protectionRange(range, oldRange)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -103,8 +103,9 @@ public class PlayersManager {
|
|||||||
/**
|
/**
|
||||||
* Get player by UUID. Adds player to cache if not in there already
|
* Get player by UUID. Adds player to cache if not in there already
|
||||||
* @param uuid of player
|
* @param uuid of player
|
||||||
* @return player object or null if it does not exist
|
* @return player object or null if it does not exist, for example the UUID is null
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Players getPlayer(UUID uuid){
|
public Players getPlayer(UUID uuid){
|
||||||
if (!playerCache.containsKey(uuid)) {
|
if (!playerCache.containsKey(uuid)) {
|
||||||
addPlayer(uuid);
|
addPlayer(uuid);
|
||||||
|
Loading…
Reference in New Issue
Block a user