Skip to content

Commit

Permalink
Fix For Unnecessarily Saving Config
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr4ken-9 committed May 31, 2020
1 parent 9a096ac commit ee04d60
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions InfiniteSentry/InfiniteSentry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ public class InfiniteSentry : RocketPlugin<InfiniteSentryConfiguration>
{
public static InfiniteSentry Instance { get; private set; }
public bool ShuttingDown { get; private set; }

public static FieldInfo HasWeapon;

public bool ChangedConfig;

protected override void Load()
{
Instance = this;
ShuttingDown = false;
ChangedConfig = false;
Provider.onServerShutdown += OnShutdown;
Level.onPostLevelLoaded += OnLevelLoaded;

Expand All @@ -38,7 +39,8 @@ protected override void Load()

protected override void Unload()
{
Instance.Configuration.Save();
if (ChangedConfig)
Instance.Configuration.Save();

Provider.onServerShutdown -= OnShutdown;
Level.onPostLevelLoaded -= OnLevelLoaded;
Expand Down
4 changes: 2 additions & 2 deletions InfiniteSentry/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
2 changes: 2 additions & 0 deletions InfiniteSentry/SentryTrackerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public SentryTrackerComponent()
return;

InfiniteSentry.Instance.Configuration.Instance.sentries.Add(newPos);
InfiniteSentry.Instance.ChangedConfig = true;
}

public void OnDisable()
Expand All @@ -32,6 +33,7 @@ public void OnDisable()
return;

InfiniteSentry.Instance.Configuration.Instance.sentries.Remove(pos);
InfiniteSentry.Instance.ChangedConfig = true;
}
}
}

0 comments on commit ee04d60

Please sign in to comment.