Some refactoring work

Add command aliases
Begin adding the sethomemount command

Part of #6
This commit is contained in:
zontreck 2025-06-05 12:18:07 -07:00
parent 45b024654a
commit bd12021575
5 changed files with 45 additions and 21 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
using Vintagestory.API.Config;
using Vintagestory.API.MathTools;
using Vintagestory.API.Server;
@ -126,8 +127,10 @@ namespace AriasServerUtils
if (data.Homes.ContainsKey(homeName))
{
Home home = data.Homes[homeName];
ServerUtilities.NewBackCacheForPlayer(isp);
data.Homes[homeName].Location.Merge(isp.Entity);
home.Location.Merge(isp.Entity, unmount: !home.CanHaveMount);
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-tp"));
}
@ -199,6 +202,12 @@ namespace AriasServerUtils
if (args.Caller.Player is IServerPlayer isp)
{
if (args.Command.FullName == "sethomemount")
{
// Check for the gears and pay here, or show error.
}
bool bypass = isOp && ServerUtilities.config.AdminsBypassMaxHomes;
var data = ServerUtilities.GetPlayerData(isp);
@ -207,6 +216,13 @@ namespace AriasServerUtils
data.Homes[homeName] = Home.MakeHome(args.Caller.Player.Entity, homeName);
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-set"));
if (args.Command.FullName == "sethomemount")
{
// Enable mount in the home
data.Homes[homeName].CanHaveMount = true;
}
}
else
{
@ -355,15 +371,13 @@ namespace AriasServerUtils
if (ServerUtilities.serverWarps.warps.ContainsKey(name))
{
Warp warp = ServerUtilities.serverWarps.warps[name];
ServerUtilities.NewBackCacheForPlayer(isp);
ServerUtilities.serverWarps.warps[name].Location.Merge(isp.Entity);
warp.Location.Merge(isp.Entity, unmount: !warp.CanHaveMount);
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-tp", name));
data.ActiveCooldowns.Add(CooldownType.Warp, TimeUtil.DecodeTimeNotation(ServerUtilities.config.Cooldowns.Get(CooldownType.Warp)) + TimeUtil.GetUnixEpochTimestamp());
ServerUtilities.MarkDirty();
}