Adds check for max homes and a flag indicating if admins can bypass max homes

This commit is contained in:
zontreck 2025-01-18 14:43:05 -07:00
parent 93a9a5e8bc
commit a27b9847d0
3 changed files with 19 additions and 5 deletions

View file

@ -116,6 +116,7 @@ namespace AriasServerUtils
internal static TextCommandResult HandleSetHome(TextCommandCallingArgs args)
{
bool isOp = args.Caller.HasPrivilege(Privilege.controlserver);
string homeName = "default";
if (args.ArgCount > 0)
{
@ -124,11 +125,21 @@ namespace AriasServerUtils
if (args.Caller.Player is IServerPlayer isp)
{
bool bypass = isOp && ServerUtilities.config.AdminsBypassMaxHomes;
var data = ServerUtilities.GetPlayerData(isp);
data.Homes[homeName] = Home.MakeHome(args.Caller.Player.Entity, homeName);
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-set"));
if (bypass || data.Homes.Count < ServerUtilities.config.MaxHomes || data.Homes.ContainsKey(homeName))
{
data.Homes[homeName] = Home.MakeHome(args.Caller.Player.Entity, homeName);
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-set"));
}
else
{
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-max"));
}
ServerUtilities.MarkDirty();
}