mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-03 23:17:41 +01:00
Fix for NPE on safe teleport when location cannot be found.
This commit is contained in:
parent
eb855edfeb
commit
ae1eeec7cf
@ -105,13 +105,22 @@ public class SafeSpotTeleport {
|
|||||||
if (portal && bestSpot != null) {
|
if (portal && bestSpot != null) {
|
||||||
// No portals found, teleport to the best spot we found
|
// No portals found, teleport to the best spot we found
|
||||||
teleportEntity(bestSpot);
|
teleportEntity(bestSpot);
|
||||||
} else if (entity instanceof Player && !failureMessage.isEmpty()) {
|
|
||||||
// Failed, no safe spot
|
|
||||||
entity.sendMessage(failureMessage);
|
|
||||||
}
|
|
||||||
if (entity instanceof Player && ((Player)entity).getGameMode().equals(GameMode.SPECTATOR)) {
|
if (entity instanceof Player && ((Player)entity).getGameMode().equals(GameMode.SPECTATOR)) {
|
||||||
((Player)entity).setGameMode(plugin.getIWM().getDefaultGameMode(bestSpot.getWorld()));
|
((Player)entity).setGameMode(plugin.getIWM().getDefaultGameMode(bestSpot.getWorld()));
|
||||||
}
|
}
|
||||||
|
} else if (entity instanceof Player && !failureMessage.isEmpty()) {
|
||||||
|
// Failed, no safe spot
|
||||||
|
entity.sendMessage(failureMessage);
|
||||||
|
if (entity instanceof Player && ((Player)entity).getGameMode().equals(GameMode.SPECTATOR)) {
|
||||||
|
if (plugin.getIWM().inWorld(entity.getLocation())) {
|
||||||
|
((Player)entity).setGameMode(plugin.getIWM().getDefaultGameMode(entity.getWorld()));
|
||||||
|
} else {
|
||||||
|
// Last resort
|
||||||
|
((Player)entity).setGameMode(GameMode.SURVIVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user