generated from AriasCreations/vsmodtemplate
parent
ced16d9fb9
commit
6b6e2af0fc
6 changed files with 179 additions and 32 deletions
|
@ -1,11 +1,7 @@
|
|||
using System;
|
||||
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;
|
||||
using Vintagestory.API.Util;
|
||||
using Vintagestory.GameContent;
|
||||
|
@ -21,27 +17,46 @@ namespace AriasServerUtils
|
|||
|
||||
internal static TextCommandResult HandleBack(TextCommandCallingArgs args)
|
||||
{
|
||||
PlayerStorage ps = ServerUtilities.GetPlayerData(args.Caller.Player as IServerPlayer);
|
||||
if (ps.ActiveCooldowns.ContainsKey(CooldownType.Back))
|
||||
if (args.Caller.Player is IServerPlayer isp)
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:cmd-cooldown", "/back", TimeUtil.EncodeTimeNotation(ps.ActiveCooldowns.Get(CooldownType.Back) - TimeUtil.GetUnixEpochTimestamp())));
|
||||
}
|
||||
|
||||
PlayerPosition pos = ServerUtilities.backCaches.ReadAndPopNewestPosition(args.Caller.Player.PlayerName);
|
||||
if (pos == null)
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:back-no"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Go back to old position
|
||||
pos.Merge(args.Caller.Player.Entity);
|
||||
ps.ActiveCooldowns.Add(CooldownType.Back, TimeUtil.DecodeTimeNotation(ServerUtilities.config.Cooldowns.Get(CooldownType.Back)) + TimeUtil.GetUnixEpochTimestamp());
|
||||
ServerUtilities.MarkDirty();
|
||||
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:back"));
|
||||
PlayerStorage ps = ServerUtilities.GetPlayerData(isp);
|
||||
if (ps.ActiveCooldowns.ContainsKey(CooldownType.Back))
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:cmd-cooldown", "/back", TimeUtil.EncodeTimeNotation(ps.ActiveCooldowns.Get(CooldownType.Back) - TimeUtil.GetUnixEpochTimestamp())));
|
||||
}
|
||||
|
||||
PlayerPosition pos = ServerUtilities.backCaches.ReadAndPopNewestPosition(args.Caller.Player.PlayerName);
|
||||
if (pos == null)
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:back-no"));
|
||||
}
|
||||
else
|
||||
{
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.back];
|
||||
int balance = RustyGearUtils.CountRustyGears(isp);
|
||||
if (cost > 0)
|
||||
{
|
||||
if (balance >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, balance));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
// Go back to old position
|
||||
pos.Merge(isp.Entity);
|
||||
ps.ActiveCooldowns.Add(CooldownType.Back, TimeUtil.DecodeTimeNotation(ServerUtilities.config.Cooldowns.Get(CooldownType.Back)) + TimeUtil.GetUnixEpochTimestamp());
|
||||
ServerUtilities.MarkDirty();
|
||||
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:back"));
|
||||
}
|
||||
}
|
||||
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
|
||||
internal static TextCommandResult HandleClearSpawn(TextCommandCallingArgs args)
|
||||
|
@ -73,6 +88,21 @@ namespace AriasServerUtils
|
|||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:cmd-cooldown", "/rtp", TimeUtil.EncodeTimeNotation(ps.ActiveCooldowns.Get(CooldownType.RTP) - TimeUtil.GetUnixEpochTimestamp())));
|
||||
}
|
||||
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.rtp];
|
||||
int balance = RustyGearUtils.CountRustyGears(isp);
|
||||
if (cost > 0)
|
||||
{
|
||||
if (balance >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, balance));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:rtp-search"));
|
||||
|
||||
|
@ -94,6 +124,21 @@ namespace AriasServerUtils
|
|||
PlayerStorage data = ServerUtilities.GetPlayerData(isp);
|
||||
if (data.Homes.ContainsKey(homeName))
|
||||
{
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.delhome];
|
||||
int balance = RustyGearUtils.CountRustyGears(isp);
|
||||
if (cost > 0)
|
||||
{
|
||||
if (balance >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, balance));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
data.Homes.Remove(homeName);
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-del"));
|
||||
|
@ -127,6 +172,21 @@ namespace AriasServerUtils
|
|||
|
||||
if (data.Homes.ContainsKey(homeName))
|
||||
{
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.home];
|
||||
int balance = RustyGearUtils.CountRustyGears(isp);
|
||||
if (cost > 0)
|
||||
{
|
||||
if (balance >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, balance));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
Home home = data.Homes[homeName];
|
||||
ServerUtilities.NewBackCacheForPlayer(isp);
|
||||
|
||||
|
@ -214,6 +274,22 @@ namespace AriasServerUtils
|
|||
|
||||
if (bypass || data.Homes.Count < ServerUtilities.config.MaxHomes || data.Homes.ContainsKey(homeName))
|
||||
{
|
||||
// Check for a cost, then check and try to charge the player.
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[withMount ? CommandCosts.CostType.sethomemount : CommandCosts.CostType.sethome];
|
||||
if (cost > 0)
|
||||
{
|
||||
int userTotal = RustyGearUtils.CountRustyGears(isp);
|
||||
if (userTotal >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, userTotal));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
data.Homes[homeName] = Home.MakeHome(args.Caller.Player.Entity, homeName, withMount: withMount);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-set"));
|
||||
}
|
||||
|
@ -264,6 +340,26 @@ namespace AriasServerUtils
|
|||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:tp-spawn"));
|
||||
ServerUtilities.NewBackCacheForPlayer(isp);
|
||||
|
||||
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.spawn];
|
||||
int playerBalance = RustyGearUtils.CountRustyGears(isp);
|
||||
|
||||
if (cost > 0)
|
||||
{
|
||||
|
||||
if (playerBalance >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, playerBalance));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ServerUtilities.config.Spawn.Merge(args.Caller.Player.Entity);
|
||||
|
||||
|
||||
|
@ -364,6 +460,25 @@ namespace AriasServerUtils
|
|||
|
||||
if (ServerUtilities.serverWarps.warps.ContainsKey(name))
|
||||
{
|
||||
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.warp];
|
||||
int balance = RustyGearUtils.CountRustyGears(isp);
|
||||
|
||||
if (cost > 0)
|
||||
{
|
||||
if (balance >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, balance));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Warp warp = ServerUtilities.serverWarps.warps[name];
|
||||
ServerUtilities.NewBackCacheForPlayer(isp);
|
||||
warp.Location.Merge(isp.Entity, unmount: !warp.CanHaveMount);
|
||||
|
@ -394,6 +509,23 @@ namespace AriasServerUtils
|
|||
{
|
||||
if (isp.HasPrivilege(Privilege.controlserver) || !ServerUtilities.config.onlyAdminsCreateWarps)
|
||||
{
|
||||
// Try to charge the player
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.delwarp];
|
||||
int balance = RustyGearUtils.CountRustyGears(isp);
|
||||
if (cost > 0)
|
||||
{
|
||||
if (balance >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, balance));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
|
||||
ServerUtilities.serverWarps.warps.Remove(name);
|
||||
ServerUtilities.MarkDirty();
|
||||
|
||||
|
@ -428,6 +560,21 @@ namespace AriasServerUtils
|
|||
{
|
||||
if (isp.HasPrivilege(Privilege.controlserver) || !ServerUtilities.config.onlyAdminsCreateWarps)
|
||||
{
|
||||
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.setwarp];
|
||||
int balance = RustyGearUtils.CountRustyGears(isp);
|
||||
if (cost > 0)
|
||||
{
|
||||
if (balance >= cost)
|
||||
{
|
||||
RustyGearUtils.SubtractRustyGears(isp, cost);
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-charged", cost));
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:cost-insufficient", cost, balance));
|
||||
return TextCommandResult.Success();
|
||||
}
|
||||
}
|
||||
ServerUtilities.serverWarps.warps[name] = Warp.Create(isp);
|
||||
ServerUtilities.MarkDirty();
|
||||
|
||||
|
|
|
@ -147,7 +147,9 @@ namespace AriasServerUtils
|
|||
warp,
|
||||
setwarp,
|
||||
delwarp,
|
||||
spawn
|
||||
spawn,
|
||||
back,
|
||||
rtp
|
||||
}
|
||||
public Dictionary<CostType, int> costs = new Dictionary<CostType, int>();
|
||||
public static readonly Dictionary<CostType, int> defaults = new Dictionary<CostType, int>()
|
||||
|
|
|
@ -2,17 +2,13 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using AriasServerUtils;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using Vintagestory.API.Common;
|
||||
using Vintagestory.API.Common.Entities;
|
||||
using Vintagestory.API.Config;
|
||||
using Vintagestory.API.MathTools;
|
||||
using Vintagestory.API.Server;
|
||||
using Vintagestory.GameContent;
|
||||
|
||||
namespace AriasServerUtils;
|
||||
|
||||
public class RTPFactory
|
||||
{
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ using Vintagestory.API.Common;
|
|||
using Vintagestory.API.Config;
|
||||
using Vintagestory.API.Datastructures;
|
||||
using Vintagestory.API.Server;
|
||||
using Vintagestory.API.Util;
|
||||
|
||||
public static class RustyGearUtils
|
||||
{
|
||||
|
|
|
@ -46,5 +46,8 @@
|
|||
"cmd-cooldown": "[{0}] is currently on cooldown. You can use this command again in [{1}]",
|
||||
|
||||
"psp": "[ASU] PSP Starting... you do not need to stay in bed",
|
||||
"psp-ending": "[ASU] PSP Complete"
|
||||
"psp-ending": "[ASU] PSP Complete",
|
||||
|
||||
"cost-insufficient": "You only have {1} rusty gears, you need {0}.",
|
||||
"cost-charged": "You have been charged {0} rusty gears."
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"modid": "ariasserverutils",
|
||||
"name": "Aria's Server Utilities",
|
||||
"authors": ["zontreck"],
|
||||
"description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 12:16 PM MST",
|
||||
"version": "1.1.0-dev.5",
|
||||
"description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 1:03 PM MST",
|
||||
"version": "1.1.0-dev.6",
|
||||
"dependencies": {
|
||||
"game": ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue