0.1.1: don't fail to load when the server starts before a map
This commit is contained in:
parent
a56dbad03a
commit
c0fc866cb1
1 changed files with 4 additions and 10 deletions
|
|
@ -21,7 +21,7 @@ namespace PlaytimeHistory;
|
|||
public class PlaytimeHistory : BasePlugin, IPluginConfig<PlaytimeHistoryConfig>
|
||||
{
|
||||
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 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)
|
||||
{
|
||||
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.OnMapEnd>(OnMapEnd);
|
||||
|
|
@ -108,15 +111,6 @@ public class PlaytimeHistory : BasePlugin, IPluginConfig<PlaytimeHistoryConfig>
|
|||
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);
|
||||
|
||||
try
|
||||
{
|
||||
_map = Server.MapName;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_map = "";
|
||||
}
|
||||
_mapRunning = _map.Length > 0;
|
||||
if (_mapRunning)
|
||||
ServerSeenNow();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue