Prevent TP if world is not loaded. Fixes #191

This commit is contained in:
bloodshot 2020-04-30 18:26:35 -04:00
parent c3b6e3b6fb
commit 051632eba6
2 changed files with 10 additions and 0 deletions

View File

@ -992,6 +992,12 @@ public static Consumer<CommandSender> createTeleportConsumer(CommandSender src,
}
final Player player = (Player) src;
// check if world is loaded
if (Bukkit.getWorld(location.getWorld().getUID()) == null) {
TextAdapter.sendComponent(player, MessageCache.getInstance().TELEPORT_NO_SAFE_LOCATION);
return;
}
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
final int teleportDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PLAYER_TELEPORT_DELAY, claim);
if (isClaimSpawn) {

View File

@ -225,6 +225,10 @@ public void sendInteractEntityDenyMessage(GDClaim claim, Player player, ItemStac
}
public boolean isSafeLocation(Location location) {
// check if world is loaded
if (Bukkit.getWorld(location.getWorld().getUID()) == null) {
return false;
}
final Block currentBlock = location.getBlock();
final Block aboveBlock = currentBlock.getRelative(BlockFace.UP);
final Block belowBlock =currentBlock.getRelative(BlockFace.DOWN);