Fix NPE in entity move handler.

This commit is contained in:
bloodshot 2019-12-19 13:25:25 -05:00
parent 1f1a1e655e
commit 3f8156836e

View File

@ -110,8 +110,10 @@ public boolean onEntityMove(MoveEntityEvent event, Location<World> fromLocation,
final Entity controller = EntityUtils.getControllingPassenger(targetEntity);
if (controller != null && controller instanceof Player) {
player = (Player) controller;
user = PermissionHolderCache.getInstance().getOrCreateUser(player);
} else {
user = PermissionHolderCache.getInstance().getOrCreateUser(targetEntity.getCreator().orElse(null));
}
user = PermissionHolderCache.getInstance().getOrCreateUser(targetEntity.getCreator().orElse(null));
}
if (user != null) {
@ -168,7 +170,7 @@ public boolean onEntityMove(MoveEntityEvent event, Location<World> fromLocation,
fromClaim = this.storage.getClaimAt(fromLocation);
}
if (player != null && GDFlags.ENTER_CLAIM && !enterBlacklisted && user.getInternalPlayerData().lastClaim != null) {
if (player != null && GDFlags.ENTER_CLAIM && !enterBlacklisted && user != null && user.getInternalPlayerData().lastClaim != null) {
final GDClaim lastClaim = (GDClaim) user.getInternalPlayerData().lastClaim.get();
if (lastClaim != null && lastClaim != fromClaim) {
if (GDPermissionManager.getInstance().getFinalPermission(event, toLocation, toClaim, GDPermissions.ENTER_CLAIM, targetEntity, targetEntity, player, TrustTypes.ACCESSOR, false) == Tristate.FALSE) {