generated from AriasCreations/vsmodtemplate
Adds in warps
This commit is contained in:
parent
e776a6bb9e
commit
737c51989b
5 changed files with 114 additions and 4 deletions
|
@ -124,6 +124,11 @@ namespace AriasServerUtils
|
|||
.HandleWith(Events.HandleASU)
|
||||
.WithDescription("Lists all Aria's Server Utils commands")
|
||||
.EndSubCommand();
|
||||
|
||||
api.ChatCommands.Create("setwarp").RequiresPlayer().WithDescription("Creates a new server warp").HandleWith(Events.HandleWarpUpdate).WithArgs(parsers.OptionalWord("name"));
|
||||
api.ChatCommands.Create("warp").RequiresPlayer().WithDescription("Warp to the specified server warp").HandleWith(Events.HandleWarp).WithArgs(parsers.OptionalWord("name"));
|
||||
api.ChatCommands.Create("delwarp").RequiresPlayer().WithDescription("Deletes the specified warp").HandleWith(Events.HandleWarpDelete).WithArgs(parsers.OptionalWord("name"));
|
||||
api.ChatCommands.Create("warps").RequiresPlayer().WithDescription("Lists all server warps").HandleWith(Events.HandleWarpList);
|
||||
}
|
||||
|
||||
private void OnPlayerDC(IServerPlayer byPlayer)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace AriasServerUtils
|
|||
{
|
||||
internal static TextCommandResult HandleASU(TextCommandCallingArgs args)
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:help", ServerUtilities.config.MaxHomes, ServerUtilities.config.AdminsBypassMaxHomes, string.Join(", ", new string[] { "setspawn", "spawn", "delspawn", "sethome", "home", "delhome", "homes", "restoreinv", "asu" })));
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:help", ServerUtilities.config.MaxHomes, ServerUtilities.config.AdminsBypassMaxHomes, string.Join(", ", new string[] { "setspawn", "spawn", "delspawn", "sethome", "home", "delhome", "homes", "restoreinv", "asu", "warp", "setwarp", "delwarp", "warps" })));
|
||||
}
|
||||
|
||||
internal static TextCommandResult HandleClearSpawn(TextCommandCallingArgs args)
|
||||
|
@ -221,5 +221,89 @@ namespace AriasServerUtils
|
|||
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
|
||||
}
|
||||
|
||||
internal static TextCommandResult HandleWarp(TextCommandCallingArgs args)
|
||||
{
|
||||
string name = "default";
|
||||
if (args.ArgCount > 0) name = args[0] as string ?? "default";
|
||||
|
||||
if (args.Caller.Player is IServerPlayer isp)
|
||||
{
|
||||
if (ServerUtilities.serverWarps.warps.ContainsKey(name))
|
||||
{
|
||||
|
||||
ServerUtilities.serverWarps.warps[name].Location.Merge(isp.Entity);
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-set", name));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-fail", name));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
|
||||
internal static TextCommandResult HandleWarpDelete(TextCommandCallingArgs args)
|
||||
{
|
||||
string name = "default";
|
||||
if (args.ArgCount > 0) name = args[0] as string ?? "default";
|
||||
|
||||
if (args.Caller.Player is IServerPlayer isp)
|
||||
{
|
||||
if (isp.HasPrivilege(Privilege.controlserver) || !ServerUtilities.config.onlyAdminsCreateWarps)
|
||||
{
|
||||
ServerUtilities.serverWarps.warps.Remove(name);
|
||||
ServerUtilities.MarkDirty();
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-del"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-no"));
|
||||
}
|
||||
}
|
||||
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
|
||||
internal static TextCommandResult HandleWarpList(TextCommandCallingArgs args)
|
||||
{
|
||||
List<string> warps = new List<string>();
|
||||
foreach (string id in ServerUtilities.serverWarps.warps.Keys)
|
||||
{
|
||||
warps.Add(id);
|
||||
}
|
||||
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:warp-list", warps.Count, string.Join(", ", warps)));
|
||||
}
|
||||
|
||||
internal static TextCommandResult HandleWarpUpdate(TextCommandCallingArgs args)
|
||||
{
|
||||
string name = "default";
|
||||
if (args.ArgCount > 0) name = args[0] as string ?? "default";
|
||||
|
||||
if (args.Caller.Player is IServerPlayer isp)
|
||||
{
|
||||
if (isp.HasPrivilege(Privilege.controlserver) || !ServerUtilities.config.onlyAdminsCreateWarps)
|
||||
{
|
||||
ServerUtilities.serverWarps.warps[name] = Warp.Create(isp);
|
||||
ServerUtilities.MarkDirty();
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-set", name));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-no"));
|
||||
}
|
||||
}
|
||||
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Vintagestory.API.Server;
|
||||
|
||||
namespace AriasServerUtils
|
||||
{
|
||||
|
@ -24,6 +25,19 @@ namespace AriasServerUtils
|
|||
public class Warp
|
||||
{
|
||||
public PlayerPosition Location;
|
||||
public string CreatedBy;
|
||||
public DateTime CreatedAt;
|
||||
|
||||
|
||||
public static Warp Create(IServerPlayer player)
|
||||
{
|
||||
Warp warp = new Warp();
|
||||
warp.Location = PlayerPosition.from(player.Entity);
|
||||
warp.CreatedBy = player.PlayerName;
|
||||
warp.CreatedAt = DateTime.Now;
|
||||
|
||||
return warp;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
|
|
@ -20,5 +20,12 @@
|
|||
|
||||
"help": "All Aria's Server Utilities Commands: \n\nMax Homes: {0}; Admins can bypass max homes: {1}\n{2}",
|
||||
|
||||
"updatedconfig": "[ASU] server config updated"
|
||||
"updatedconfig": "[ASU] server config updated",
|
||||
|
||||
"warp-tp": "Teleported to warp [{0}]",
|
||||
"warp-set": "Warp [{0}] created!",
|
||||
"warp-no": "You lack permissions to manage a warp",
|
||||
"warp-fail": "Warp [{0}] does not exist",
|
||||
"warp-del": "Warp [{0}] deleted",
|
||||
"warp-list": "There are [{0}] total warps\n\n{1}"
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"modid": "ariasserverutils",
|
||||
"name": "Aria's Server Utilities",
|
||||
"authors": ["zontreck"],
|
||||
"description": "A collection of server utilities\n\nBuild Date: 01-18-2025 @ 03:18 PM",
|
||||
"version": "1.0.1-dev.1",
|
||||
"description": "A collection of server utilities\n\nBuild Date: 01-18-2025 @ 04:10 PM",
|
||||
"version": "1.0.1-dev.2",
|
||||
"dependencies": {
|
||||
"game": ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue