generated from AriasCreations/vsmodtemplate
Some refactoring work
Add command aliases Begin adding the sethomemount command Part of #6
This commit is contained in:
parent
45b024654a
commit
bd12021575
5 changed files with 45 additions and 21 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ namespace AriasServerUtils
|
|||
public PlayerPosition Location;
|
||||
public string CreatedBy;
|
||||
public DateTime CreatedAt;
|
||||
public bool CanHaveMount = false;
|
||||
|
||||
|
||||
public static Warp Create(IServerPlayer player)
|
||||
|
|
|
@ -99,19 +99,20 @@ namespace AriasServerUtils
|
|||
|
||||
|
||||
|
||||
api.ChatCommands.Create("setspawn").RequiresPrivilege(Privilege.controlserver).HandleWith(Events.HandleSetSpawn);
|
||||
api.ChatCommands.Create("spawn").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSpawn);
|
||||
api.ChatCommands.Create("delspawn").RequiresPrivilege(Privilege.controlserver).HandleWith(Events.HandleClearSpawn);
|
||||
api.ChatCommands.Create("setspawn").RequiresPrivilege(Privilege.controlserver).HandleWith(Events.HandleSetSpawn).WithAlias("ss");
|
||||
api.ChatCommands.Create("spawn").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSpawn).WithAlias("s");
|
||||
api.ChatCommands.Create("delspawn").RequiresPrivilege(Privilege.controlserver).HandleWith(Events.HandleClearSpawn).WithAlias("ds");
|
||||
|
||||
|
||||
//api.ChatCommands.Create("test_death").RequiresPlayer().RequiresPrivilege(Privilege.controlserver).HandleWith(TestDeath);
|
||||
var parsers = api.ChatCommands.Parsers;
|
||||
api.ChatCommands.Create("restoreinv").RequiresPlayer().WithArgs(parsers.OnlinePlayer("player")).HandleWith(Events.HandleReturnItems).WithDescription("Returns items to a player in the event of a problem").RequiresPrivilege(Privilege.controlserver);
|
||||
|
||||
api.ChatCommands.Create("sethome").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Creates a home").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSetHome);
|
||||
api.ChatCommands.Create("home").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Teleports you to home").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleGoHome);
|
||||
api.ChatCommands.Create("delhome").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Deletes a home entry").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleDelHome);
|
||||
api.ChatCommands.Create("homes").RequiresPlayer().WithDescription("Lists your homes").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleListHomes);
|
||||
api.ChatCommands.Create("sethome").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Creates a home").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSetHome).WithAlias("sh");
|
||||
api.ChatCommands.Create("home").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Teleports you to home").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleGoHome).WithAlias("h");
|
||||
api.ChatCommands.Create("delhome").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Deletes a home entry").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleDelHome).WithAlias("dh");
|
||||
api.ChatCommands.Create("homes").RequiresPlayer().WithDescription("Lists your homes").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleListHomes).WithAlias("lh");
|
||||
api.ChatCommands.Create("sethomemount").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Create a home with the ability to take a mount with you. Costs [undefined] gears.").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSetHome).WithAlias("shm", "shb");
|
||||
|
||||
api.ChatCommands.Create("asu")
|
||||
.RequiresPrivilege(Privilege.chat)
|
||||
|
@ -263,16 +264,16 @@ namespace AriasServerUtils
|
|||
.EndSubCommand()
|
||||
.EndSubCommand();
|
||||
|
||||
api.ChatCommands.Create("setwarp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Creates a new server warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarpUpdate);
|
||||
api.ChatCommands.Create("warp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Warp to the specified server warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarp);
|
||||
api.ChatCommands.Create("delwarp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Deletes the specified warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarpDelete);
|
||||
api.ChatCommands.Create("warps").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Lists all server warps").HandleWith(Events.HandleWarpList);
|
||||
api.ChatCommands.Create("setwarp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Creates a new server warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarpUpdate).WithAlias("sw");
|
||||
api.ChatCommands.Create("warp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Warp to the specified server warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarp).WithAlias("w");
|
||||
api.ChatCommands.Create("delwarp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Deletes the specified warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarpDelete).WithAlias("dw");
|
||||
api.ChatCommands.Create("warps").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Lists all server warps").HandleWith(Events.HandleWarpList).WithAlias("lw");
|
||||
|
||||
api.ChatCommands.Create("back").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Returns you to the last location you were at").HandleWith(Events.HandleBack);
|
||||
api.ChatCommands.Create("back").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Returns you to the last location you were at").HandleWith(Events.HandleBack).WithAlias("b");
|
||||
|
||||
api.ChatCommands.Create("rtp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithArgs(parsers.OptionalInt("maxDist", defaultValue: -1)).WithDescription("Seeks a position possibly thousands of blocks away to teleport to.").HandleWith(Events.HandleRTP);
|
||||
|
||||
api.ChatCommands.Create("listcooldowns").RequiresPrivilege(Privilege.chat).WithDescription("Lists the cooldown settings on the server, as well as your own active cooldowns if applicable.").HandleWith(Events.HandleListCooldowns);
|
||||
api.ChatCommands.Create("listcooldowns").RequiresPrivilege(Privilege.chat).WithDescription("Lists the cooldown settings on the server, as well as your own active cooldowns if applicable.").HandleWith(Events.HandleListCooldowns).WithAlias("lc");
|
||||
}
|
||||
|
||||
private TextCommandResult TestSleep(TextCommandCallingArgs args)
|
||||
|
|
|
@ -31,8 +31,15 @@ namespace AriasServerUtils
|
|||
}
|
||||
|
||||
|
||||
public void Merge(Entity entity)
|
||||
public void Merge(Entity entity, bool unmount = true)
|
||||
{
|
||||
if (entity is EntityPlayer player)
|
||||
{
|
||||
if (unmount && player.MountedOn.Entity != null)
|
||||
{
|
||||
player.TryUnmount();
|
||||
}
|
||||
}
|
||||
entity.TeleportTo(new BlockPos(X, Y, Z, Dimension));
|
||||
entity.Pos.SetYaw(Yaw);
|
||||
entity.Pos.Pitch = Pitch;
|
||||
|
@ -88,6 +95,7 @@ namespace AriasServerUtils
|
|||
public class Home
|
||||
{
|
||||
public PlayerPosition Location { get; set; }
|
||||
public bool CanHaveMount = false;
|
||||
|
||||
public static Home MakeHome(Entity player, string homeName)
|
||||
{
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"modid": "ariasserverutils",
|
||||
"name": "Aria's Server Utilities",
|
||||
"authors": ["zontreck"],
|
||||
"description": "A collection of server utilities\n\nBuild Date: 05-7-2025 @ 12:21 PM MST",
|
||||
"version": "1.0.11",
|
||||
"description": "A collection of server utilities\n\nBuild Date: 06-05-2025 @ 11:56 AM MST",
|
||||
"version": "1.1.0-dev.1",
|
||||
"dependencies": {
|
||||
"game": ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue