0.1.1: don't fail to load when the server starts before a map
This commit is contained in:
parent
a56dbad03a
commit
d89a078835
1 changed files with 4 additions and 10 deletions
|
|
@ -21,7 +21,7 @@ namespace PlaytimeHistory;
|
||||||
public class PlaytimeHistory : BasePlugin, IPluginConfig<PlaytimeHistoryConfig>
|
public class PlaytimeHistory : BasePlugin, IPluginConfig<PlaytimeHistoryConfig>
|
||||||
{
|
{
|
||||||
public override string ModuleName => "PlaytimeHistory";
|
public override string ModuleName => "PlaytimeHistory";
|
||||||
public override string ModuleVersion => "0.1.0";
|
public override string ModuleVersion => "0.1.1";
|
||||||
public override string ModuleAuthor => "astra";
|
public override string ModuleAuthor => "astra";
|
||||||
public override string ModuleDescription => "Records playtime per session, team and alive/dead state";
|
public override string ModuleDescription => "Records playtime per session, team and alive/dead state";
|
||||||
|
|
||||||
|
|
@ -73,6 +73,9 @@ public class PlaytimeHistory : BasePlugin, IPluginConfig<PlaytimeHistoryConfig>
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
ProtectConfigFile();
|
ProtectConfigFile();
|
||||||
|
// Null while the server is still starting, before the first map: OnMapStart sets it.
|
||||||
|
_map = Server.MapName ?? "";
|
||||||
|
_mapRunning = _map.Length > 0;
|
||||||
|
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
RegisterListener<Listeners.OnMapEnd>(OnMapEnd);
|
RegisterListener<Listeners.OnMapEnd>(OnMapEnd);
|
||||||
|
|
@ -108,15 +111,6 @@ public class PlaytimeHistory : BasePlugin, IPluginConfig<PlaytimeHistoryConfig>
|
||||||
Logger.LogInformation("Recording to {Host}:{Port}/{Database} as {User}, server id {Id}",
|
Logger.LogInformation("Recording to {Host}:{Port}/{Database} as {User}, server id {Id}",
|
||||||
Config.Database.Host, Config.Database.Port, Config.Database.Database, Config.Database.User, Config.ServerId);
|
Config.Database.Host, Config.Database.Port, Config.Database.Database, Config.Database.User, Config.ServerId);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_map = Server.MapName;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
_map = "";
|
|
||||||
}
|
|
||||||
_mapRunning = _map.Length > 0;
|
|
||||||
if (_mapRunning)
|
if (_mapRunning)
|
||||||
ServerSeenNow();
|
ServerSeenNow();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue