- Minor changes
- Added `css_gravity` command
- Added `css_money` command
- Changed Utc time to LocalTime
- Updated translations (ChatGPT generated)
- Updated css version
This commit is contained in:
Dawid Bepierszcz
2024-03-07 13:34:31 +01:00
parent da6fb2fc22
commit 2ab2f9c4dc
27 changed files with 731 additions and 489 deletions

View File

@@ -21,7 +21,7 @@ public class AdminSQLManager
public async Task<List<(List<string>, int)>> GetAdminFlags(string steamId)
{
DateTime now = DateTime.UtcNow;
DateTime now = DateTime.UtcNow.ToLocalTime();
await using var connection = await _database.GetConnectionAsync();
@@ -62,7 +62,7 @@ public class AdminSQLManager
public async Task<List<(string, List<string>, int, DateTime?)>> GetAllPlayersFlags()
{
DateTime now = DateTime.UtcNow;
DateTime now = DateTime.UtcNow.ToLocalTime();
try
{
@@ -181,10 +181,10 @@ public class AdminSQLManager
flags = flags.Replace(" ", "");
DateTime now = DateTime.UtcNow;
DateTime now = DateTime.UtcNow.ToLocalTime();
DateTime? futureTime;
if (time != 0)
futureTime = now.AddMinutes(time);
futureTime = now.ToLocalTime().AddMinutes(time);
else
futureTime = null;
@@ -214,7 +214,7 @@ public class AdminSQLManager
await using var connection = await _database.GetConnectionAsync();
string sql = "DELETE FROM sa_admins WHERE ends IS NOT NULL AND ends <= @CurrentTime";
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now.ToLocalTime() });
}
catch (Exception)
{

View File

@@ -15,8 +15,8 @@ internal class BanManager
public async Task BanPlayer(PlayerInfo player, PlayerInfo issuer, string reason, int time = 0)
{
DateTime now = DateTime.UtcNow;
DateTime futureTime = now.AddMinutes(time);
DateTime now = DateTime.UtcNow.ToLocalTime();
DateTime futureTime = now.AddMinutes(time).ToLocalTime();
await using var connection = await _database.GetConnectionAsync();
@@ -42,8 +42,8 @@ internal class BanManager
{
if (string.IsNullOrEmpty(playerSteamId)) return;
DateTime now = DateTime.UtcNow;
DateTime futureTime = now.AddMinutes(time);
DateTime now = DateTime.UtcNow.ToLocalTime();
DateTime futureTime = now.AddMinutes(time).ToLocalTime();
await using var connection = await _database.GetConnectionAsync();
@@ -67,8 +67,8 @@ internal class BanManager
{
if (string.IsNullOrEmpty(playerIp)) return;
DateTime now = DateTime.UtcNow;
DateTime futureTime = now.AddMinutes(time);
DateTime now = DateTime.UtcNow.ToLocalTime();
DateTime futureTime = now.AddMinutes(time).ToLocalTime();
await using var connection = await _database.GetConnectionAsync();
@@ -96,13 +96,13 @@ internal class BanManager
}
#if DEBUG
if (CS2_SimpleAdmin._logger != null)
if (CS2_SimpleAdmin._logger!= null)
CS2_SimpleAdmin._logger.LogCritical($"IsPlayerBanned for {player.Name}");
#endif
int banCount = 0;
DateTime currentTime = DateTime.Now;
DateTime currentTime = DateTime.Now.ToLocalTime();
try
{
@@ -175,7 +175,7 @@ internal class BanManager
{
try
{
DateTime currentTime = DateTime.UtcNow;
DateTime currentTime = DateTime.UtcNow.ToLocalTime();
await using var connection = await _database.GetConnectionAsync();
@@ -184,7 +184,7 @@ internal class BanManager
await using var connection = await _database.GetConnectionAsync();
sql = "UPDATE sa_bans SET status = 'EXPIRED' WHERE status = 'ACTIVE' AND `duration` > 0 AND ends <= @CurrentTime";
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.UtcNow });
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.UtcNow.ToLocalTime() });
*/
string sql = @"
@@ -202,7 +202,7 @@ internal class BanManager
if (_config.ExpireOldIpBans > 0)
{
DateTime ipBansTime = currentTime.AddDays(-_config.ExpireOldIpBans);
DateTime ipBansTime = currentTime.AddDays(-_config.ExpireOldIpBans).ToLocalTime();
sql = @"
UPDATE sa_bans

View File

@@ -17,8 +17,8 @@ internal class MuteManager
await using var connection = await _database.GetConnectionAsync();
DateTime now = DateTime.UtcNow;
DateTime futureTime = now.AddMinutes(time);
DateTime now = DateTime.UtcNow.ToLocalTime();
DateTime futureTime = now.AddMinutes(time).ToLocalTime();
string muteType = "GAG";
if (type == 1)
@@ -50,8 +50,8 @@ internal class MuteManager
await using var connection = await _database.GetConnectionAsync();
DateTime now = DateTime.UtcNow;
DateTime futureTime = now.AddMinutes(time);
DateTime now = DateTime.UtcNow.ToLocalTime();
DateTime futureTime = now.AddMinutes(time).ToLocalTime();
string muteType = "GAG";
if (type == 1)
@@ -84,14 +84,14 @@ internal class MuteManager
}
#if DEBUG
if (CS2_SimpleAdmin._logger != null)
if (CS2_SimpleAdmin._logger!= null)
CS2_SimpleAdmin._logger.LogCritical($"IsPlayerMuted for {steamId}");
#endif
try
{
await using var connection = await _database.GetConnectionAsync();
DateTime currentTime = DateTime.Now;
DateTime currentTime = DateTime.Now.ToLocalTime();
string sql = "SELECT * FROM sa_mutes WHERE player_steamid = @PlayerSteamID AND status = 'ACTIVE' AND (duration = 0 OR ends > @CurrentTime)";
var parameters = new { PlayerSteamID = steamId, CurrentTime = currentTime };
@@ -152,7 +152,7 @@ internal class MuteManager
await using var connection = await _database.GetConnectionAsync();
string sql = "UPDATE sa_mutes SET status = 'EXPIRED' WHERE status = 'ACTIVE' AND `duration` > 0 AND ends <= @CurrentTime";
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now.ToLocalTime() });
}
catch (Exception)
{

View File

@@ -37,7 +37,7 @@ public class PlayerPenaltyManager
{
//Console.WriteLine($"Found penalties for player with slot {slot} and penalty type {penaltyType}");
DateTime now = DateTime.UtcNow;
DateTime now = DateTime.UtcNow.ToLocalTime();
// Check if any active penalties exist
foreach (var penalty in penaltiesList.ToList())
@@ -115,7 +115,7 @@ public class PlayerPenaltyManager
// Remove all expired penalties for all players and penalty types
public void RemoveExpiredPenalties()
{
DateTime now = DateTime.UtcNow;
DateTime now = DateTime.UtcNow.ToLocalTime();
foreach (var kvp in penalties.ToList()) // Use ToList to avoid modification while iterating
{
var playerSlot = kvp.Key;
@@ -124,7 +124,7 @@ public class PlayerPenaltyManager
// Remove expired penalties for the player
foreach (var penaltiesList in penaltyDict.Values)
{
penaltiesList.RemoveAll(p => p.Duration > 0 && now >= p.EndDateTime.AddSeconds(p.Duration));
penaltiesList.RemoveAll(p => p.Duration > 0 && now >= p.EndDateTime.AddSeconds(p.Duration).ToLocalTime());
}
// Remove player slot if no penalties left