Fix NPE during pvp protection checks.

This commit is contained in:
bloodshot 2020-04-09 15:57:49 -04:00
parent e79100c6f1
commit d043037d26
2 changed files with 3 additions and 3 deletions

View File

@ -399,7 +399,7 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
GDPermissionUser user = null;
if (source instanceof Player && targetUser != null) {
user = PermissionHolderCache.getInstance().getOrCreateUser(((Player) source).getUniqueId());
if (user.getOnlinePlayer() != null) {
if (user.getOnlinePlayer() != null && targetUser.getOnlinePlayer() != null) {
return this.getPvpProtectResult(event, claim, user, targetUser);
}
}
@ -422,7 +422,7 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
}
if (owner != null && targetUser != null && !owner.equals(targetUser.getUniqueId())) {
final GDPermissionUser sourceUser = PermissionHolderCache.getInstance().getOrCreateUser(owner);
if (sourceUser.getOnlinePlayer() != null) {
if (sourceUser.getOnlinePlayer() != null && targetUser.getOnlinePlayer() != null) {
return this.getPvpProtectResult(event, claim, sourceUser, targetUser);
}
}

View File

@ -500,7 +500,7 @@ public boolean protectEntity(Event event, Entity targetEntity, Cause cause, Dama
final GDPermissionUser targetUser = targetEntity instanceof Player ? PermissionHolderCache.getInstance().getOrCreateUser((Player) targetEntity) : null;
if (source instanceof Player && targetUser != null) {
final GDPermissionUser sourceUser = PermissionHolderCache.getInstance().getOrCreateUser(((Player) source).getUniqueId());
if (sourceUser.getOnlinePlayer() != null) {
if (sourceUser.getOnlinePlayer() != null && targetUser.getOnlinePlayer() != null) {
return this.getPvpProtectResult(event, claim, sourceUser, targetUser);
}
}