Release 1.0.3

Fix: Permissions on /homes
Add: /back
This commit is contained in:
zontreck 2025-01-18 21:23:21 -07:00
parent 1f43ffaa6c
commit 3e0896f5f9
5 changed files with 97 additions and 8 deletions

View file

@ -16,6 +16,7 @@ namespace AriasServerUtils
public int MaxHomes { get; set; } = 20;
public bool AdminsBypassMaxHomes { get; set; } = true;
public bool onlyAdminsCreateWarps { get; set; } = true;
public int MaxBackCache { get; set; } = 10;
public PlayerPosition Spawn { get; set; }
@ -45,4 +46,39 @@ namespace AriasServerUtils
{
public Dictionary<string, Warp> warps = new Dictionary<string, Warp>();
}
public class BackCaches
{
private const int MaxCacheSize = 10;
private readonly Dictionary<string, LinkedList<PlayerPosition>> playerCache = new();
public void AddPosition(string playerName, PlayerPosition position)
{
if (!playerCache.TryGetValue(playerName, out var positions))
{
positions = new LinkedList<PlayerPosition>();
playerCache[playerName] = positions;
}
if (positions.Count >= MaxCacheSize)
{
positions.RemoveFirst(); // Remove the oldest position
}
positions.AddLast(position.Clone()); // Add the new position
}
public PlayerPosition ReadAndPopNewestPosition(string playerName)
{
if (playerCache.TryGetValue(playerName, out var positions) && positions.Count > 0)
{
var newestPosition = positions.Last.Value;
positions.RemoveLast(); // Remove the newest position
return newestPosition;
}
return null; // Return null if no positions are available
}
}
}