Skip to content

Commit

Permalink
Add BlockUnderground configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
RestoreMonarchy committed Dec 3, 2024
1 parent f5f8492 commit 87a016a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
11 changes: 11 additions & 0 deletions MoreHomes/Commands/HomeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion MoreHomes/MoreHomes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net48</TargetFramework>
<LangVersion>latest</LangVersion>
<RootNamespace>RestoreMonarchy.MoreHomes</RootNamespace>
<Version>1.10.1</Version>
<Version>1.10.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions MoreHomes/MoreHomesConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<VIPPermission> VIPCooldowns { get; set; }
public List<VIPPermission> VIPDelays { get; set; }
public List<VIPPermission> VIPMaxHomes { get; set; }
Expand All @@ -28,6 +29,7 @@ public void LoadDefaults()
TeleportHeight = 0.5f;
CancelOnMove = true;
MoveMaxDistance = 0.5f;
BlockUnderground = false;

VIPCooldowns = new List<VIPPermission>()
{
Expand Down
3 changes: 2 additions & 1 deletion MoreHomes/MoreHomesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Allow players to claim and teleport to multiple beds.
<TeleportHeight>0.5</TeleportHeight>
<CancelOnMove>true</CancelOnMove>
<MoveMaxDistance>0.5</MoveMaxDistance>
<BlockUnderground>false</BlockUnderground>
<VIPCooldowns>
<VIPPermission PermissionTag="morehomes.vip" Value="10" />
<VIPPermission PermissionTag="morehomes.star" Value="5" />
Expand Down Expand Up @@ -81,5 +82,6 @@ Allow players to claim and teleport to multiple beds.
<Translation Id="HomeTeleportationFailed" Value="Failed to teleport to [[b]]{0}[[/b]] home" />
<Translation Id="HomeDestroyed" Value="Your [[b]]{0}[[/b]] home was destroyed" />
<Translation Id="HomeCanceledYouMoved" Value="Home teleportation canceled because you moved" />
<Translation Id="CantTeleportToBedUnderground" Value="You can't teleport to [[b]]{0}[[/b]] home, because it's underground." />
</Translations>
```

0 comments on commit 87a016a

Please sign in to comment.