diff --git a/bukkit/src/main/java/com/griefdefender/cache/MessageCache.java b/bukkit/src/main/java/com/griefdefender/cache/MessageCache.java index ba3cee1..8ba9ce0 100644 --- a/bukkit/src/main/java/com/griefdefender/cache/MessageCache.java +++ b/bukkit/src/main/java/com/griefdefender/cache/MessageCache.java @@ -368,6 +368,7 @@ public static MessageCache getInstance() { public Component SCHEMATIC_CREATE_FAIL; public Component SCHEMATIC_NONE; public Component SPAWN_NOT_SET; + public Component TELEPORT_NO_SAFE_LOCATION; public Component TITLE_ACCESSOR; public Component TITLE_ALL; public Component TITLE_BUILDER; @@ -717,6 +718,7 @@ public void loadCache() { SCHEMATIC_CREATE_FAIL = MessageStorage.MESSAGE_DATA.getMessage("schematic-create-fail"); SCHEMATIC_NONE = MessageStorage.MESSAGE_DATA.getMessage("schematic-none"); SPAWN_NOT_SET = MessageStorage.MESSAGE_DATA.getMessage("spawn-not-set"); + TELEPORT_NO_SAFE_LOCATION = MessageStorage.MESSAGE_DATA.getMessage("teleport-no-safe-location"); TITLE_ACCESSOR = MessageStorage.MESSAGE_DATA.getMessage("title-accessor"); TITLE_ALL = MessageStorage.MESSAGE_DATA.getMessage("title-all"); TITLE_BUILDER = MessageStorage.MESSAGE_DATA.getMessage("title-builder"); diff --git a/bukkit/src/main/java/com/griefdefender/claim/GDClaimManager.java b/bukkit/src/main/java/com/griefdefender/claim/GDClaimManager.java index 945269d..f0760e4 100644 --- a/bukkit/src/main/java/com/griefdefender/claim/GDClaimManager.java +++ b/bukkit/src/main/java/com/griefdefender/claim/GDClaimManager.java @@ -458,7 +458,11 @@ public Map getPlayerDataMap() { public Set findOverlappingClaims(Claim claim) { Set claimSet = new HashSet<>(); for (Long chunkHash : claim.getChunkHashes()) { - for (Claim chunkClaim : this.chunksToClaimsMap.get(chunkHash)) { + final Set chunkClaims = this.chunksToClaimsMap.get(chunkHash); + if (chunkClaims == null) { + continue; + } + for (Claim chunkClaim : chunkClaims) { if (!chunkClaim.equals(claim) && (claim.overlaps(chunkClaim) || chunkClaim.overlaps(claim))) { claimSet.add(chunkClaim); } diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandHelper.java b/bukkit/src/main/java/com/griefdefender/command/CommandHelper.java index 7f07bdf..07bae54 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandHelper.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandHelper.java @@ -98,6 +98,7 @@ import com.griefdefender.permission.ui.UIHelper; import com.griefdefender.text.action.GDCallbackHolder; import com.griefdefender.util.PermissionUtil; +import com.griefdefender.util.PlayerUtil; import com.griefdefender.util.TaskUtil; import net.kyori.text.Component; @@ -1018,13 +1019,19 @@ public static Consumer createTeleportConsumer(CommandSender src, } } - player.teleport(location, TeleportCause.PLUGIN); - }; - } + final double safeY = player.getWorld().getHighestBlockYAt(location); + location.setY(safeY); + int currentY = location.getBlockY(); + while (currentY < player.getWorld().getMaxHeight()) { + if (PlayerUtil.getInstance().isSafeLocation(location)) { + player.teleport(location, TeleportCause.PLUGIN); + return; + } + currentY++; + location.setY(currentY); + } - public static Consumer createForceTeleportConsumer(Player player, Location location) { - return teleport -> { - player.teleport(location, TeleportCause.PLUGIN); + TextAdapter.sendComponent(player, MessageCache.getInstance().TELEPORT_NO_SAFE_LOCATION); }; } diff --git a/bukkit/src/main/java/com/griefdefender/util/PlayerUtil.java b/bukkit/src/main/java/com/griefdefender/util/PlayerUtil.java index db1b377..dcfdcd0 100644 --- a/bukkit/src/main/java/com/griefdefender/util/PlayerUtil.java +++ b/bukkit/src/main/java/com/griefdefender/util/PlayerUtil.java @@ -35,6 +35,7 @@ import com.griefdefender.cache.PermissionHolderCache; import com.griefdefender.claim.GDClaim; import com.griefdefender.configuration.MessageStorage; +import com.griefdefender.internal.util.NMSUtil; import com.griefdefender.internal.visual.ClaimVisual; import com.griefdefender.internal.visual.GDClaimVisualType; import com.griefdefender.permission.GDPermissionUser; @@ -44,8 +45,11 @@ import net.kyori.text.format.TextColor; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -181,4 +185,20 @@ public void sendInteractEntityDenyMessage(GDClaim claim, Player player, ItemStac GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message); } } + + public boolean isSafeLocation(Location location) { + final Block currentBlock = location.getBlock(); + final Block aboveBlock = currentBlock.getRelative(BlockFace.UP); + final Block belowBlock =currentBlock.getRelative(BlockFace.DOWN); + if (!NMSUtil.getInstance().isBlockTransparent(currentBlock)) { + return false; + } + if (!NMSUtil.getInstance().isBlockTransparent(aboveBlock)) { + return false; + } + if (!belowBlock.getType().isSolid()) { + return false; + } + return true; + } } diff --git a/bukkit/src/main/resources/assets/lang/en_US.conf b/bukkit/src/main/resources/assets/lang/en_US.conf index 4aebb63..ad399e1 100644 --- a/bukkit/src/main/resources/assets/lang/en_US.conf +++ b/bukkit/src/main/resources/assets/lang/en_US.conf @@ -579,6 +579,7 @@ GriefDefender { tax-claim-paid-partial="&aThe tax debt of '&6{amount}&a' has been partially paid. In order to unfreeze your claim, the remaining tax owed balance of '&6{balance}&a' must be paid." tax-info="&aYour next scheduled tax payment of &6{amount}&a will be withdrawn from your account on &b{date}&a." tax-past-due="&cYou currently have a past due tax balance of &a{balance}&c that must be paid by &b{date}&c. Failure to pay off your tax balance will result in losing your property." + teleport-no-safe-location="&cNo safe location found in claim to teleport!\n&aUse the '&f/claiminfo&a' command to set a safe spawn point instead." title-accessor=ACCESSOR title-all=ALL title-builder=BUILDER diff --git a/bukkit/src/main/resources/assets/lang/fr_FR.conf b/bukkit/src/main/resources/assets/lang/fr_FR.conf index ce8f452..0b7f21c 100644 --- a/bukkit/src/main/resources/assets/lang/fr_FR.conf +++ b/bukkit/src/main/resources/assets/lang/fr_FR.conf @@ -576,6 +576,7 @@ GriefDefender { tax-claim-paid-partial="&aLa dette de taxe de '&6{amount}&a' a été partiellement payée. Pour lever la mise en demeure de la protection, le reste de la taxe due de '&6{balance}&a' doit être payé." tax-info="&aTon prélèvement de taxe d'un montant de &6{amount}&a va être prélevé depuis ton compte le &b{date}&a." tax-past-due="&cTu as actuellement un défaut de paiement passé de taxe de &a{balance}&c qui nécessite d'être payé pour le &b{date}&c. L'échec de paiement de cette taxe entrainera la perte de la propriété." + teleport-no-safe-location="&cAucun emplacement sûr trouvé dans la protection pour la téléportation.\n&aUtilise la commande '&f/claiminfo&a' pour définir un point d'apparition sûr." title-accessor=ACCÉDANT title-all=TOUS title-builder=CONSTRUTEUR diff --git a/bukkit/src/main/resources/assets/lang/ru_RU.conf b/bukkit/src/main/resources/assets/lang/ru_RU.conf index 5470fd7..1b92916 100644 --- a/bukkit/src/main/resources/assets/lang/ru_RU.conf +++ b/bukkit/src/main/resources/assets/lang/ru_RU.conf @@ -579,6 +579,7 @@ GriefDefender { tax-claim-paid-partial="&aЗадолженность по налогам в размере '&6{amount}&a' частично оплачена. Чтобы разморозить регион, остаток долга в размере '&6{balance}&a' должен быть уплачен." tax-info="&aСледующая выплата по налогам в размере &6{amount}&a будет списана с вашего счёта &b{date}&a." tax-past-due="&cУ вас есть задолженность по налогам в размере &a{balance}&c, которая должна быть выплачена до &b{date}&c. В случае неуплаты ваша собственность будет потеряна." + teleport-no-safe-location="&cВ регионе не найдено безопасных мест для телепортации!\n&aВоспользуйтесь '&f/claiminfo&a', чтобы установить безопасную точку для возрождения/телепортации." title-accessor=ДОСТУП title-all=ВСЕ title-builder=СТРОИТЕЛЬСТВО diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 0d71f92..9a257e5 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -3,5 +3,5 @@ main: com.griefdefender.GDBootstrap softdepend: [WorldEdit, WorldGuard, Vault] depend: [LuckPerms] load: STARTUP -version: '1.2.0' +version: '1.2.1' api-version: 1.13