generated from AriasCreations/vsmodtemplate
parent
a88807045e
commit
bdbf67c86e
2 changed files with 52 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
using System.Runtime.ConstrainedExecution;
|
using System.Runtime.ConstrainedExecution;
|
||||||
using Vintagestory.API.Common;
|
using Vintagestory.API.Common;
|
||||||
using Vintagestory.API.Server;
|
using Vintagestory.API.Server;
|
||||||
|
@ -23,7 +24,7 @@ namespace AriasServerUtils
|
||||||
{ CooldownType.RTP, "30s" },
|
{ CooldownType.RTP, "30s" },
|
||||||
{ CooldownType.Back, "5s" }
|
{ CooldownType.Back, "5s" }
|
||||||
};
|
};
|
||||||
private static readonly int CURRENT_VERSION = 6;
|
private static readonly int CURRENT_VERSION = 7;
|
||||||
|
|
||||||
|
|
||||||
public int Version { get; set; } = 0;
|
public int Version { get; set; } = 0;
|
||||||
|
@ -36,6 +37,7 @@ namespace AriasServerUtils
|
||||||
public int PlayerSleepingPercentage { get; set; } = 50;
|
public int PlayerSleepingPercentage { get; set; } = 50;
|
||||||
public int MaxRTPBlockDistance { get; set; } = 50000;
|
public int MaxRTPBlockDistance { get; set; } = 50000;
|
||||||
public Dictionary<CooldownType, string> Cooldowns { get; set; } = new Dictionary<CooldownType, string>();
|
public Dictionary<CooldownType, string> Cooldowns { get; set; } = new Dictionary<CooldownType, string>();
|
||||||
|
public Costs costs { get; set; } = new Costs();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -72,6 +74,29 @@ namespace AriasServerUtils
|
||||||
Version = CURRENT_VERSION;
|
Version = CURRENT_VERSION;
|
||||||
ServerUtilities.MarkDirty(); // This is here to ensure that the config gets saved when there is a update. Whenever a new field is added to config, the CURRENT_VERSION should get bumped so that this SanityCheck can properly work
|
ServerUtilities.MarkDirty(); // This is here to ensure that the config gets saved when there is a update. Whenever a new field is added to config, the CURRENT_VERSION should get bumped so that this SanityCheck can properly work
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sanity check costs config
|
||||||
|
bool checkCostDefaults = false;
|
||||||
|
if (costs == null)
|
||||||
|
{
|
||||||
|
costs = new Costs(); // Initialize a brand new costs object
|
||||||
|
checkCostDefaults = true;
|
||||||
|
}
|
||||||
|
else if (costs.costs.Count != Costs.defaults.Count) checkCostDefaults = true;
|
||||||
|
|
||||||
|
if (checkCostDefaults)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (var def in Costs.defaults)
|
||||||
|
{
|
||||||
|
if (!costs.costs.ContainsKey(def.Key))
|
||||||
|
{
|
||||||
|
costs.costs.Add(def.Key, def.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerUtilities.MarkDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +147,29 @@ namespace AriasServerUtils
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Costs
|
public class Costs
|
||||||
{
|
{
|
||||||
public Dictionary<string, int> costs = new Dictionary<string, int>();
|
public enum CostType
|
||||||
|
{
|
||||||
|
sethome,
|
||||||
|
home,
|
||||||
|
delhome,
|
||||||
|
sethomemount,
|
||||||
|
warp,
|
||||||
|
setwarp,
|
||||||
|
delwarp,
|
||||||
|
spawn
|
||||||
|
}
|
||||||
|
public Dictionary<CostType, int> costs = new Dictionary<CostType, int>();
|
||||||
|
public static readonly Dictionary<CostType, int> defaults = new Dictionary<CostType, int>()
|
||||||
|
{
|
||||||
|
{ CostType.sethome, 0 },
|
||||||
|
{ CostType.home, 0 },
|
||||||
|
{ CostType.delhome, 0 },
|
||||||
|
{ CostType.sethomemount, 10 },
|
||||||
|
{ CostType.setwarp, 5 },
|
||||||
|
{ CostType.warp, 1 },
|
||||||
|
{ CostType.delwarp, 5 },
|
||||||
|
{ CostType.spawn, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the player has the balance required to use the command
|
/// Checks if the player has the balance required to use the command
|
||||||
|
@ -130,7 +177,7 @@ namespace AriasServerUtils
|
||||||
/// <param name="cmd">The command the player is trying to use</param>
|
/// <param name="cmd">The command the player is trying to use</param>
|
||||||
/// <param name="player">The player</param>
|
/// <param name="player">The player</param>
|
||||||
/// <returns>True if the player has the required balance</returns>
|
/// <returns>True if the player has the required balance</returns>
|
||||||
public bool PlayerHasBalance(string cmd, EntityPlayer player)
|
public bool PlayerHasBalance(CostType cmd, EntityPlayer player)
|
||||||
{
|
{
|
||||||
int gears = 0;
|
int gears = 0;
|
||||||
int required = 0;
|
int required = 0;
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"modid": "ariasserverutils",
|
"modid": "ariasserverutils",
|
||||||
"name": "Aria's Server Utilities",
|
"name": "Aria's Server Utilities",
|
||||||
"authors": ["zontreck"],
|
"authors": ["zontreck"],
|
||||||
"description": "A collection of server utilities\n\nBuild Date: 06-05-2025 @ 4:44 PM MST",
|
"description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 1:18 AM MST",
|
||||||
"version": "1.1.0-dev.3",
|
"version": "1.1.0-dev.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"game": ""
|
"game": ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue