Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions VIPCore/src/Config/ConfigModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class VipConfig
public string DatabaseConnection { get; set; } = "default";
public int TimeMode { get; set; } = 0;
public bool VipLogging { get; set; } = true;
public int? ServerId { get; set; } = null;
}

public class GroupsConfig
Expand Down
16 changes: 15 additions & 1 deletion VIPCore/src/Services/ServerIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
using VIPCore.Database;
using VIPCore.Database.Repositories;
using VIPCore.Models;
using VIPCore.Config;

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace VIPCore.Services;

Expand All @@ -12,6 +14,7 @@ public class ServerIdentifier
private readonly ISwiftlyCore _core;
private readonly DatabaseConnectionFactory _connectionFactory;
private readonly IUserRepository _userRepository;
private readonly IOptionsMonitor<VipConfig> _coreConfigMonitor;

private long _serverId;
private string? _serverIp;
Expand All @@ -23,17 +26,28 @@ public class ServerIdentifier
public int ServerPort => _serverPort;
public bool IsInitialized => _initialized;

public ServerIdentifier(ISwiftlyCore core, DatabaseConnectionFactory connectionFactory, IUserRepository userRepository)
public ServerIdentifier(ISwiftlyCore core, DatabaseConnectionFactory connectionFactory, IUserRepository userRepository, IOptionsMonitor<VipConfig> coreConfigMonitor)
{
_core = core;
_connectionFactory = connectionFactory;
_userRepository = userRepository;
_coreConfigMonitor = coreConfigMonitor;
}

public async Task InitializeAsync()
{
try
{
if (_coreConfigMonitor.CurrentValue.ServerId.HasValue)
{
_serverId = _coreConfigMonitor.CurrentValue.ServerId.Value;
_serverIp = "configured";
_serverPort = 0;
_initialized = true;
_core.Logger.LogInformation("[VIPCore] Server identified using configured ID {ServerId}.", _serverId);
return;
}

_serverIp = _core.Engine.ServerIP;
var hostport = _core.ConVar.Find<int>("hostport");

Expand Down
2 changes: 1 addition & 1 deletion VIPCore/src/VIPCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace VIPCore;

[PluginMetadata(Id = "VIPCore", Version = "1.0.1", Name = "VIPCore", Author = "aga", Description = "Core VIP management plugin ported to SwiftlyS2.")]
[PluginMetadata(Id = "VIPCore", Version = "1.0.1-beta", Name = "VIPCore", Author = "aga", Description = "Core VIP management plugin ported to SwiftlyS2.")]
public partial class VIPCore : BasePlugin
{
private VipConfig? _config;
Expand Down