generated from AriasCreations/vsmodtemplate
Begin adding cooldowns to specific commands
This commit is contained in:
parent
107f502736
commit
85f728babf
7 changed files with 204 additions and 3 deletions
|
@ -6,6 +6,7 @@ using Vintagestory.API.Common;
|
|||
using Vintagestory.API.Config;
|
||||
using Vintagestory.API.MathTools;
|
||||
using Vintagestory.API.Server;
|
||||
using Vintagestory.API.Util;
|
||||
|
||||
namespace AriasServerUtils
|
||||
{
|
||||
|
@ -18,6 +19,12 @@ namespace AriasServerUtils
|
|||
|
||||
internal static TextCommandResult HandleBack(TextCommandCallingArgs args)
|
||||
{
|
||||
PlayerStorage ps = ServerUtilities.GetPlayerData(args.Caller.Player as IServerPlayer);
|
||||
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)
|
||||
{
|
||||
|
@ -27,6 +34,9 @@ namespace AriasServerUtils
|
|||
{
|
||||
// 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"));
|
||||
}
|
||||
|
||||
|
@ -44,8 +54,19 @@ namespace AriasServerUtils
|
|||
{
|
||||
if (args.Caller.Player is IServerPlayer isp)
|
||||
{
|
||||
|
||||
PlayerStorage ps = ServerUtilities.GetPlayerData(isp);
|
||||
if (ps.ActiveCooldowns.ContainsKey(CooldownType.RTP))
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:cmd-cooldown", "/rtp", TimeUtil.EncodeTimeNotation(ps.ActiveCooldowns.Get(CooldownType.RTP) - TimeUtil.GetUnixEpochTimestamp())));
|
||||
}
|
||||
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:rtp-search"));
|
||||
|
||||
ps.ActiveCooldowns.Add(CooldownType.RTP, TimeUtil.DecodeTimeNotation(ServerUtilities.config.Cooldowns.Get(CooldownType.RTP)) + TimeUtil.GetUnixEpochTimestamp());
|
||||
ServerUtilities.MarkDirty();
|
||||
|
||||
PlayerPosition pPos = RTPFactory.GetRandomPosition(isp);
|
||||
if (pPos == null)
|
||||
{
|
||||
|
@ -103,6 +124,12 @@ namespace AriasServerUtils
|
|||
if (args.Caller.Player is IServerPlayer isp)
|
||||
{
|
||||
PlayerStorage data = ServerUtilities.GetPlayerData(isp);
|
||||
if (data.ActiveCooldowns.ContainsKey(CooldownType.Home))
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:cmd-cooldown", "/home", TimeUtil.EncodeTimeNotation(data.ActiveCooldowns.Get(CooldownType.Home) - TimeUtil.GetUnixEpochTimestamp())));
|
||||
}
|
||||
|
||||
|
||||
if (data.Homes.ContainsKey(homeName))
|
||||
{
|
||||
ServerUtilities.NewBackCacheForPlayer(isp);
|
||||
|
@ -114,6 +141,11 @@ namespace AriasServerUtils
|
|||
{
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-no"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
data.ActiveCooldowns.Add(CooldownType.Home, TimeUtil.DecodeTimeNotation(ServerUtilities.config.Cooldowns.Get(CooldownType.Home)) + TimeUtil.GetUnixEpochTimestamp());
|
||||
ServerUtilities.MarkDirty();
|
||||
}
|
||||
|
||||
return TextCommandResult.Success();
|
||||
|
@ -219,10 +251,23 @@ namespace AriasServerUtils
|
|||
{
|
||||
if (args.Caller.Player is IServerPlayer isp)
|
||||
{
|
||||
|
||||
PlayerStorage data = ServerUtilities.GetPlayerData(isp);
|
||||
if (data.ActiveCooldowns.ContainsKey(CooldownType.Spawn))
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:cmd-cooldown", "/spawn", TimeUtil.EncodeTimeNotation(data.ActiveCooldowns.Get(CooldownType.Spawn) - TimeUtil.GetUnixEpochTimestamp())));
|
||||
}
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:tp-spawn"));
|
||||
ServerUtilities.NewBackCacheForPlayer(isp);
|
||||
|
||||
ServerUtilities.config.Spawn.Merge(args.Caller.Player.Entity);
|
||||
|
||||
|
||||
|
||||
|
||||
data.ActiveCooldowns.Add(CooldownType.Spawn, TimeUtil.DecodeTimeNotation(ServerUtilities.config.Cooldowns.Get(CooldownType.Spawn)) + TimeUtil.GetUnixEpochTimestamp());
|
||||
ServerUtilities.MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,12 +339,26 @@ namespace AriasServerUtils
|
|||
|
||||
if (args.Caller.Player is IServerPlayer isp)
|
||||
{
|
||||
PlayerStorage data = ServerUtilities.GetPlayerData(isp);
|
||||
if (data.ActiveCooldowns.ContainsKey(CooldownType.Warp))
|
||||
{
|
||||
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:cmd-cooldown", "/warp", TimeUtil.EncodeTimeNotation(data.ActiveCooldowns.Get(CooldownType.Warp) - TimeUtil.GetUnixEpochTimestamp())));
|
||||
}
|
||||
|
||||
|
||||
if (ServerUtilities.serverWarps.warps.ContainsKey(name))
|
||||
{
|
||||
ServerUtilities.NewBackCacheForPlayer(isp);
|
||||
ServerUtilities.serverWarps.warps[name].Location.Merge(isp.Entity);
|
||||
|
||||
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-set", name));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.ActiveCooldowns.Add(CooldownType.Warp, TimeUtil.DecodeTimeNotation(ServerUtilities.config.Cooldowns.Get(CooldownType.Warp)) + TimeUtil.GetUnixEpochTimestamp());
|
||||
ServerUtilities.MarkDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue