changed player graph update interval to every 5 minutes

hopefully fixed skipping the logging of Kayak library issue.
I'm an idiot, 59 in playerhistory, not 60
added IW4 callback gsc for custom scriptkills.
Fixed duplicate death events
Trusted group can be enabled/disabled with !enable/disabletrusted
This commit is contained in:
RaidMax
2017-11-02 11:49:45 -05:00
parent c19d6e98f5
commit 9699f7c3f1
21 changed files with 189 additions and 29 deletions

View File

@ -7,7 +7,9 @@ namespace SharedLibrary.Helpers
public class ConfigurationManager
{
ConcurrentDictionary<string, Dictionary<string, object>> ConfigurationSet;
ConcurrentDictionary<string, object> ConfigSet;
Type PluginType;
Server ServerInstance;
public ConfigurationManager(Type PluginType)
{
@ -15,6 +17,27 @@ namespace SharedLibrary.Helpers
this.PluginType = PluginType;
}
public ConfigurationManager(Server S)
{
try
{
ConfigSet = Interfaces.Serialize<ConcurrentDictionary<string, object>>.Read($"config/Plugins_{S}.cfg");
}
catch (Exception)
{
S.Logger.WriteInfo("ConfigurationManager could not deserialize configuration file, so initializing default config set");
ConfigSet = new ConcurrentDictionary<string, object>();
}
ServerInstance = S;
}
private void SaveChanges()
{
Interfaces.Serialize<ConcurrentDictionary<string, object>>.Write($"config/Plugins_{ServerInstance}.cfg", ConfigSet);
}
public void AddConfiguration(Server S)
{
/* if (ConfigurationSet.ContainsKey(S.ToString()))
@ -41,15 +64,44 @@ namespace SharedLibrary.Helpers
Interfaces.Serialize<Dictionary<string, object>>.Write($"config/{PluginType.ToString()}_{S.ToString()}.cfg", ConfigurationSet[S.ToString()]);
}
public void AddProperty(KeyValuePair<string, object> prop)
{
if (!ConfigSet.ContainsKey(prop.Key))
ConfigSet.TryAdd(prop.Key, prop.Value);
SaveChanges();
}
public void UpdateProperty(Server S, KeyValuePair<string, object> Property)
{
ConfigurationSet[S.ToString()][Property.Key] = Property.Value;
Interfaces.Serialize<Dictionary<string, object>>.Write($"config/{PluginType.ToString()}_{S.ToString()}.cfg", ConfigurationSet[S.ToString()]);
}
public void UpdateProperty(KeyValuePair<string, object> prop)
{
if (ConfigSet.ContainsKey(prop.Key))
ConfigSet[prop.Key] = prop.Value;
SaveChanges();
}
public IDictionary<string, object> GetConfiguration(Server S)
{
return ConfigurationSet[S.ToString()];
}
public object GetProperty(string prop)
{
try
{
return ConfigSet[prop];
}
catch (Exception)
{
return null;
}
}
}
}

View File

@ -4,17 +4,20 @@ namespace SharedLibrary.Helpers
{
public class PlayerHistory
{
// how many minutes between updates
public static readonly int UpdateInterval = 5;
public PlayerHistory(int cNum)
{
DateTime t = DateTime.UtcNow;
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, Math.Min(59, 15 * (int)Math.Round(t.Minute / 15.0)), 0);
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, Math.Min(59, UpdateInterval * (int)Math.Round(t.Minute / (float)UpdateInterval)), 0);
PlayerCount = cNum;
}
#if DEBUG
public PlayerHistory(DateTime t, int cNum)
{
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, Math.Min(59, 15 * (int)Math.Round(t.Minute / 15.0)), 0);
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, Math.Min(59, UpdateInterval * (int)Math.Round(t.Minute / (float)UpdateInterval)), 0);
PlayerCount = cNum;
}
#endif