From 87a016a1385c432fd5f6a7d1b2282be8851b2ab8 Mon Sep 17 00:00:00 2001 From: MCrow Date: Tue, 3 Dec 2024 12:24:21 +0100 Subject: [PATCH] Add BlockUnderground configuration option --- MoreHomes/Commands/HomeCommand.cs | 11 +++++++++++ MoreHomes/MoreHomes.csproj | 2 +- MoreHomes/MoreHomesConfiguration.cs | 2 ++ MoreHomes/MoreHomesPlugin.cs | 3 ++- README.md | 2 ++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/MoreHomes/Commands/HomeCommand.cs b/MoreHomes/Commands/HomeCommand.cs index fe7979a..4953104 100644 --- a/MoreHomes/Commands/HomeCommand.cs +++ b/MoreHomes/Commands/HomeCommand.cs @@ -107,6 +107,17 @@ private bool ValidateTeleportation(UnturnedPlayer player, PlayerHome home) if (!ValitedateRaidAndCombat(player)) return false; } + + if (pluginInstance.Configuration.Instance.BlockUnderground) + { + Vector3 position = home.LivePosition; + float height = LevelGround.getHeight(position); + if (height > position.y) + { + pluginInstance.SendMessageToPlayer(player, "CantTeleportToBedUnderground", home.Name); + return false; + } + } return true; } diff --git a/MoreHomes/MoreHomes.csproj b/MoreHomes/MoreHomes.csproj index 167a305..794921e 100644 --- a/MoreHomes/MoreHomes.csproj +++ b/MoreHomes/MoreHomes.csproj @@ -4,7 +4,7 @@ net48 latest RestoreMonarchy.MoreHomes - 1.10.1 + 1.10.2 diff --git a/MoreHomes/MoreHomesConfiguration.cs b/MoreHomes/MoreHomesConfiguration.cs index 55bcaf1..0491703 100644 --- a/MoreHomes/MoreHomesConfiguration.cs +++ b/MoreHomes/MoreHomesConfiguration.cs @@ -14,6 +14,7 @@ public class MoreHomesConfiguration : IRocketPluginConfiguration public float TeleportHeight { get; set; } public bool CancelOnMove { get; set; } public float MoveMaxDistance { get; set; } + public bool BlockUnderground { get; set; } = false; public List VIPCooldowns { get; set; } public List VIPDelays { get; set; } public List VIPMaxHomes { get; set; } @@ -28,6 +29,7 @@ public void LoadDefaults() TeleportHeight = 0.5f; CancelOnMove = true; MoveMaxDistance = 0.5f; + BlockUnderground = false; VIPCooldowns = new List() { diff --git a/MoreHomes/MoreHomesPlugin.cs b/MoreHomes/MoreHomesPlugin.cs index c310305..bf8a4a4 100644 --- a/MoreHomes/MoreHomesPlugin.cs +++ b/MoreHomes/MoreHomesPlugin.cs @@ -113,7 +113,8 @@ private void OnPluginsLoaded() { "HomeClaimed", "New home claimed with the name [[b]]{0}[[/b]]" }, { "HomeTeleportationFailed", "Failed to teleport to [[b]]{0}[[/b]] home" }, { "HomeDestroyed", "Your [[b]]{0}[[/b]] home was destroyed" }, - { "HomeCanceledYouMoved", "Home teleportation canceled because you moved" } + { "HomeCanceledYouMoved", "Home teleportation canceled because you moved" }, + { "CantTeleportToBedUnderground", "You can't teleport to [[b]]{0}[[/b]] home, because it's underground." } }; internal void SendMessageToPlayer(IRocketPlayer player, string translationKey, params object[] placeholder) diff --git a/README.md b/README.md index f66ec61..28dd1eb 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Allow players to claim and teleport to multiple beds. 0.5 true 0.5 + false @@ -81,5 +82,6 @@ Allow players to claim and teleport to multiple beds. + ```