mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-12 01:01:23 +00:00
```diff
+ `Refactored Code`: Improved code structure for better maintainability.
+ `Player Penalties Command`: Introduced the `css_penalties` command to display player penalties.
+ `Admin Penalties Information`: Added functionality to provide information for admins regarding penalties of connecting players.
+ `Disconnected Players Command`: Added the `css_disconnected` command to show a list of disconnected players.
+ `Colorful Messages`: Implemented the `css_cssay` command to send colorful messages, e.g., `css_cssay {lightgreen}Test`.
+ `Respawn Functionality`: Updated the `css_respawn` command to respawn players at their death location.
+ `Menu Type Management`: Introduced the `css_menus` command to change the menu type via `MenuManagerCS2`.
+ `Dynamic Menu Control`: Enhanced menu interaction with dynamic controls using WASD + ER keys.
+ `Language File Updates`: Updated language files for better localization.
+ `API Integration`: Added a simple API for external interaction.
+ `Configurable Timezone`: Introduced timezone settings in the configuration.
+ `Admin Activity Display Options`: Added configurable settings for displaying admin activity:
+ `0`: Do not show
+ `1`: Hide admin name
+ `2`: Show admin name
+ `Discord Notification Customization`: Made Discord duration notifications customizable with `{relative}` and `{normal}` placeholders.
+ Improved command logging
+
`Configuration Options:`
+ `Timezone`
+ `Other Settings`
+ `Disconnected Players History Count`
+ `Show Activity Type`
```
57 lines
1.3 KiB
C#
57 lines
1.3 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using MySqlConnector;
|
|
|
|
namespace CS2_SimpleAdmin.Database;
|
|
|
|
public class Database(string dbConnectionString)
|
|
{
|
|
public MySqlConnection GetConnection()
|
|
{
|
|
try
|
|
{
|
|
var connection = new MySqlConnection(dbConnectionString);
|
|
connection.Open();
|
|
return connection;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CS2_SimpleAdmin._logger?.LogCritical($"Unable to connect to database: {ex.Message}");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<MySqlConnection> GetConnectionAsync()
|
|
{
|
|
try
|
|
{
|
|
var connection = new MySqlConnection(dbConnectionString);
|
|
await connection.OpenAsync();
|
|
return connection;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CS2_SimpleAdmin._logger?.LogCritical($"Unable to connect to database: {ex.Message}");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public void DatabaseMigration()
|
|
{
|
|
Migration migrator = new(this);
|
|
migrator.ExecuteMigrations();
|
|
}
|
|
|
|
public bool CheckDatabaseConnection()
|
|
{
|
|
using var connection = GetConnection();
|
|
|
|
try
|
|
{
|
|
return connection.Ping();
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
} |