more config updates
This commit is contained in:
parent
c1a1d65261
commit
40be4bdf4d
@ -12,6 +12,9 @@ namespace SharedLibrary.Configuration
|
||||
public string DiscordInviteCode { get; set; }
|
||||
public string IPHubAPIKey { get; set; }
|
||||
public List<ServerConfiguration> Servers { get; set; }
|
||||
|
||||
public int AutoMessagePeriod { get; set; }
|
||||
public List<string> AutoMessages { get; set; }
|
||||
public List<string> Rules { get; set; }
|
||||
public List<MapConfiguration> Maps { get; set; }
|
||||
}
|
||||
}
|
||||
|
16
SharedLibrary/Configuration/MapConfiguration.cs
Normal file
16
SharedLibrary/Configuration/MapConfiguration.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using static SharedLibrary.Server;
|
||||
|
||||
namespace SharedLibrary.Configuration
|
||||
{
|
||||
public class MapConfiguration
|
||||
{
|
||||
public Game Game { get; set; }
|
||||
public List<Map> Maps { get; set; }
|
||||
}
|
||||
}
|
@ -5,18 +5,9 @@ namespace SharedLibrary
|
||||
{
|
||||
public class Map
|
||||
{
|
||||
public Map(String N, String A)
|
||||
{
|
||||
Name = N;
|
||||
Alias = A;
|
||||
}
|
||||
public String Name { get; set; }
|
||||
public String Alias { get; set; }
|
||||
|
||||
public String Name { get; private set; }
|
||||
public String Alias { get; private set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Alias;
|
||||
}
|
||||
public override string ToString() => Alias;
|
||||
}
|
||||
}
|
||||
|
@ -39,13 +39,11 @@ namespace SharedLibrary
|
||||
|
||||
Players = new List<Player>(new Player[18]);
|
||||
Reports = new List<Report>();
|
||||
PlayerHistory = new Queue<Helpers.PlayerHistory>();
|
||||
PlayerHistory = new Queue<PlayerHistory>();
|
||||
ChatHistory = new List<ChatInfo>();
|
||||
//Configuration = new ConfigurationManager(this.GetType());
|
||||
NextMessage = 0;
|
||||
InitializeTokens();
|
||||
InitializeAutoMessages();
|
||||
InitializeMaps();
|
||||
InitializeRules();
|
||||
}
|
||||
|
||||
@ -255,24 +253,7 @@ namespace SharedLibrary
|
||||
protected void InitializeMaps()
|
||||
{
|
||||
Maps = new List<Map>();
|
||||
|
||||
IFile mapfile = new IFile($"{Utilities.OperatingDirectory}config/maps.cfg");
|
||||
String[] _maps = mapfile.ReadAllLines();
|
||||
mapfile.Close();
|
||||
if (_maps.Length > 2) // readAll returns minimum one empty string
|
||||
{
|
||||
foreach (String m in _maps)
|
||||
{
|
||||
String[] m2 = m.Split(':');
|
||||
if (m2.Length > 1)
|
||||
{
|
||||
Map map = new Map(m2[0].Trim(), m2[1].Trim());
|
||||
Maps.Add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
Logger.WriteInfo("Maps configuration appears to be empty - skipping...");
|
||||
Maps.AddRange(Manager.GetApplicationSettings().Maps.First(m => m.Game == GameName).Maps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -283,34 +264,7 @@ namespace SharedLibrary
|
||||
{
|
||||
BroadcastMessages = new List<String>();
|
||||
|
||||
IFile messageCFG = new IFile($"{Utilities.OperatingDirectory}config/messages.cfg");
|
||||
String[] lines = messageCFG.ReadAllLines();
|
||||
messageCFG.Close();
|
||||
|
||||
if (lines.Length < 2) //readAll returns minimum one empty string
|
||||
{
|
||||
Logger.WriteInfo("Messages configuration appears empty - skipping...");
|
||||
return;
|
||||
}
|
||||
|
||||
int mTime = -1;
|
||||
int.TryParse(lines[0], out mTime);
|
||||
|
||||
if (MessageTime == -1)
|
||||
MessageTime = 60;
|
||||
else
|
||||
MessageTime = mTime;
|
||||
|
||||
foreach (String l in lines)
|
||||
{
|
||||
if (lines[0] != l && l.Length > 1)
|
||||
BroadcastMessages.Add(l);
|
||||
}
|
||||
|
||||
messageCFG.Close();
|
||||
|
||||
//if (Program.Version != Program.latestVersion && Program.latestVersion != 0)
|
||||
// messages.Add("^5IW4M Admin ^7is outdated. Please ^5update ^7to version " + Program.latestVersion);
|
||||
BroadcastMessages.AddRange(Manager.GetApplicationSettings().AutoMessages);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -321,21 +275,7 @@ namespace SharedLibrary
|
||||
{
|
||||
Rules = new List<String>();
|
||||
|
||||
IFile ruleFile = new IFile($"{Utilities.OperatingDirectory}config/rules.cfg");
|
||||
String[] _rules = ruleFile.ReadAllLines();
|
||||
ruleFile.Close();
|
||||
if (_rules.Length > 2) // readAll returns minimum one empty string
|
||||
{
|
||||
foreach (String r in _rules)
|
||||
{
|
||||
if (r.Length > 1)
|
||||
Rules.Add(r);
|
||||
}
|
||||
}
|
||||
else
|
||||
Logger.WriteInfo("Rules configuration appears empty - skipping...");
|
||||
|
||||
ruleFile.Close();
|
||||
Rules.AddRange(Manager.GetApplicationSettings().Rules);
|
||||
}
|
||||
|
||||
public ConfigurationManager Configuration { get; private set; }
|
||||
@ -392,7 +332,6 @@ namespace SharedLibrary
|
||||
protected string IP;
|
||||
protected int Port;
|
||||
protected string FSGame;
|
||||
protected int MessageTime;
|
||||
protected int NextMessage;
|
||||
protected int ConnectionErrors;
|
||||
protected List<string> BroadcastMessages;
|
||||
|
@ -146,6 +146,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Configuration\MapConfiguration.cs" />
|
||||
<Compile Include="Configuration\ServerConfiguration.cs" />
|
||||
<Compile Include="Database\Importer.cs" />
|
||||
<Compile Include="Database\DatabaseContext.cs" />
|
||||
|
@ -1,44 +0,0 @@
|
||||
mp_rust:Rust
|
||||
mp_highrise:Highrise
|
||||
mp_terminal:Terminal
|
||||
mp_crash:Crash
|
||||
mp_nightshift:Skidrow
|
||||
mp_quarry:Quarry
|
||||
mp_afghan:Afghan
|
||||
mp_derail:Derail
|
||||
mp_estate:Estate
|
||||
mp_favela:Favela
|
||||
mp_highrise:Highrise
|
||||
mp_invasion:Invasion
|
||||
mp_checkpoint:Karachi
|
||||
mp_quarry:Quarry
|
||||
mp_rundown:Rundown
|
||||
mp_boneyard:Scrapyard
|
||||
mp_nightshift:Skidrow
|
||||
mp_subbase:Sub Base
|
||||
mp_underpass:Underpass
|
||||
mp_brecourt:Wasteland
|
||||
mp_overgrown:Overgrown
|
||||
mp_strike:Strike
|
||||
mp_vacant:Vacant
|
||||
mp_abandon:Carnival
|
||||
mp_trailerpark:Trailer Park
|
||||
mp_fuel2:Fuel
|
||||
mp_storm:Storm
|
||||
mp_complex:Bailout
|
||||
mp_compact:Salvage
|
||||
mp_nuked:Nuketown
|
||||
iw4_credits:IW4 Credits
|
||||
mp_killhouse:Killhouse
|
||||
mp_bog_sh:Bog
|
||||
mp_cargoship_sh:Freighter
|
||||
mp_shipment:Shipment
|
||||
mp_shipment_long:Shipment - Long
|
||||
mp_rust_long:Rust - Long
|
||||
mp_firingrange:Firing Range
|
||||
mp_storm_spring:Chemical Plant
|
||||
mp_fav_tropical:Favela - Tropical
|
||||
mp_estate_tropical:Estate - Tropical
|
||||
mp_crash_tropical:Crash - Tropical
|
||||
mp_bloc_sh:Forgotten City
|
||||
mp_raidmax:^1L^23^33^4T^5M^6A^75^8T^93^0R
|
@ -1,8 +0,0 @@
|
||||
60
|
||||
Over ^5{{TOTALPLAYTIME}} ^7man hours have been played on this server!
|
||||
This server uses ^5IW4M Admin v{{VERSION}} ^7get it at ^5raidmax.org/IW4MAdmin
|
||||
^5IW4M Admin ^7sees ^5YOU!
|
||||
This server has harvested the information of ^5{{TOTALPLAYERS}} ^7players!
|
||||
Cheaters are ^1unwelcome ^7 on this server
|
||||
Did you know 8/10 people agree with unverified statistics?
|
||||
^5{{TOTALKILLS}} ^7innocent people have been murdered in this server!
|
@ -1,6 +0,0 @@
|
||||
Cheating/Exploiting is not allowed
|
||||
Respect other players
|
||||
Administrators have the final say
|
||||
No Racism or excessive trolling
|
||||
Keep grenade launcher use to a minimum
|
||||
Balance teams at ALL times
|
@ -44,7 +44,6 @@ namespace IW4MAdmin
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Console.Write("Enter server RCON password: ");
|
||||
|
@ -111,12 +111,17 @@ namespace IW4MAdmin
|
||||
BuildConfiguration();
|
||||
var settings = AppSettings.Get<ApplicationConfiguration>();
|
||||
|
||||
if (settings == null)
|
||||
if (settings?.Servers == null)
|
||||
{
|
||||
settings = ConfigurationGenerator.GenerateApplicationConfig();
|
||||
settings.Servers = ConfigurationGenerator.GenerateServerConfig(new List<ServerConfiguration>());
|
||||
var newSettings = ConfigurationGenerator.GenerateApplicationConfig();
|
||||
newSettings.Servers = ConfigurationGenerator.GenerateServerConfig(new List<ServerConfiguration>());
|
||||
newSettings.AutoMessagePeriod = settings.AutoMessagePeriod;
|
||||
newSettings.AutoMessages = settings.AutoMessages;
|
||||
newSettings.Rules = settings.Rules;
|
||||
newSettings.Maps = settings.Maps;
|
||||
settings = newSettings;
|
||||
|
||||
var appConfigJSON = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
||||
var appConfigJSON = JsonConvert.SerializeObject(newSettings, Formatting.Indented);
|
||||
File.WriteAllText($"{AppDomain.CurrentDomain.BaseDirectory}IW4MAdminSettings.json", appConfigJSON);
|
||||
BuildConfiguration();
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ namespace IW4MAdmin
|
||||
playerCountStart = DateTime.Now;
|
||||
}
|
||||
|
||||
if (LastMessage.TotalSeconds > MessageTime && BroadcastMessages.Count > 0 && ClientNum > 0)
|
||||
if (LastMessage.TotalSeconds > Manager.GetApplicationSettings().AutoMessagePeriod && BroadcastMessages.Count > 0 && ClientNum > 0)
|
||||
{
|
||||
await Broadcast(Utilities.ProcessMessageToken(Manager.GetMessageTokens(), BroadcastMessages[NextMessage]));
|
||||
NextMessage = NextMessage == (BroadcastMessages.Count - 1) ? 0 : NextMessage + 1;
|
||||
@ -588,8 +588,10 @@ namespace IW4MAdmin
|
||||
Website = "this server's website";
|
||||
}
|
||||
|
||||
InitializeMaps();
|
||||
|
||||
this.Hostname = hostname.Value.StripColors();
|
||||
this.CurrentMap = Maps.Find(m => m.Name == mapname.Value) ?? new Map(mapname.Value, mapname.Value);
|
||||
this.CurrentMap = Maps.Find(m => m.Name == mapname.Value) ?? new Map() { Alias = mapname.Value, Name = mapname.Value };
|
||||
this.MaxClients = maxplayers.Value;
|
||||
this.FSGame = game.Value;
|
||||
|
||||
@ -619,7 +621,7 @@ namespace IW4MAdmin
|
||||
}
|
||||
|
||||
#endif
|
||||
string mainPath = (GameName == Game.IW4 && onelog.Value >=0) ? "userraw" : "main";
|
||||
string mainPath = (GameName == Game.IW4 && onelog.Value >= 0) ? "userraw" : "main";
|
||||
|
||||
string logPath = (game.Value == "" || onelog?.Value == 1) ?
|
||||
$"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{mainPath}{Path.DirectorySeparatorChar}{logfile.Value}" :
|
||||
@ -643,7 +645,6 @@ namespace IW4MAdmin
|
||||
Logger.WriteInfo($"Log file is {logPath}");
|
||||
#if !DEBUG
|
||||
await Broadcast("IW4M Admin is now ^2ONLINE");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -753,7 +754,7 @@ namespace IW4MAdmin
|
||||
FSGame = (await this.GetDvarAsync<string>("fs_game")).Value.StripColors();
|
||||
|
||||
string mapname = this.GetDvarAsync<string>("mapname").Result.Value;
|
||||
CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map(mapname, mapname);
|
||||
CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map() { Alias = mapname, Name = mapname };
|
||||
|
||||
// todo: make this more efficient
|
||||
((ApplicationManager)(Manager)).AdministratorIPs = (await new GenericRepository<EFClient>().FindAsync(c => c.Level > Player.Permission.Trusted))
|
||||
|
@ -0,0 +1,241 @@
|
||||
{
|
||||
"AutoMessagePeriod": 60,
|
||||
"AutoMessages": [
|
||||
"Over ^5{{TOTALPLAYTIME}} ^7man hours have been played on this server!",
|
||||
"This server uses ^5IW4M Admin v{{VERSION}} ^7get it at ^5raidmax.org/IW4MAdmin",
|
||||
"^5IW4M Admin ^7sees ^5YOU!",
|
||||
"This server has harvested the information of ^5{{TOTALPLAYERS}} ^7players!",
|
||||
"Cheaters are ^1unwelcome ^7 on this server",
|
||||
"Did you know 8/10 people agree with unverified statistics?",
|
||||
"^5{{TOTALKILLS}} ^7innocent people have been murdered in this server!"
|
||||
],
|
||||
"Rules": [
|
||||
"Cheating/Exploiting is not allowed",
|
||||
"Respect other players",
|
||||
"Administrators have the final say",
|
||||
"No Racism or excessive trolling",
|
||||
"Keep grenade launcher use to a minimum",
|
||||
"Balance teams at ALL times"
|
||||
],
|
||||
"Maps": [
|
||||
{
|
||||
"Game": "IW4",
|
||||
"Maps": [
|
||||
{
|
||||
"Alias": "Rust",
|
||||
"Name": "mp_rust"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Highrise",
|
||||
"Name": "mp_highrise"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Terminal",
|
||||
"Name": "mp_terminal"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Crash",
|
||||
"Name": "mp_crash"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Skidrow",
|
||||
"Name": "mp_nightshift"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Quarry",
|
||||
"Name": "mp_quarry"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Afghan",
|
||||
"Name": "mp_afghan"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Derail",
|
||||
"Name": "mp_derail"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Estate",
|
||||
"Name": "mp_estate"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Favela",
|
||||
"Name": "mp_favela"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Highrise",
|
||||
"Name": "mp_highrise"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Invasion",
|
||||
"Name": "mp_invasion"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Karachi",
|
||||
"Name": "mp_checkpoint"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Quarry",
|
||||
"Name": "mp_quarry"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Rundown",
|
||||
"Name": "mp_rundown"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Scrapyard",
|
||||
"Name": "mp_boneyard"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Skidrow",
|
||||
"Name": "mp_nightshift"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Sub Base",
|
||||
"Name": "mp_subbase"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Underpass",
|
||||
"Name": "mp_underpass"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Wasteland",
|
||||
"Name": "mp_brecourt"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Overgrown",
|
||||
"Name": "mp_overgrown"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Strike",
|
||||
"Name": "mp_strike"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Vacant",
|
||||
"Name": "mp_vacant"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Carnival",
|
||||
"Name": "mp_abandon"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Trailer Park",
|
||||
"Name": "mp_trailerpark"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Fuel",
|
||||
"Name": "mp_fuel2"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Storm",
|
||||
"Name": "mp_storm"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Bailout",
|
||||
"Name": "mp_complex"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Salvage",
|
||||
"Name": "mp_compact"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Nuketown",
|
||||
"Name": "mp_nuked"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "IW4 Credits",
|
||||
"Name": "iw4_credits"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Killhouse",
|
||||
"Name": "mp_killhouse"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Bog",
|
||||
"Name": "mp_bog_sh"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Freighter",
|
||||
"Name": "mp_cargoship_sh"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Shipment",
|
||||
"Name": "mp_shipment"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Shipment - Long",
|
||||
"Name": "mp_shipment_long"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Rust - Long",
|
||||
"Name": "mp_rust_long"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Firing Range",
|
||||
"Name": "mp_firingrange"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Chemical Plant",
|
||||
"Name": "mp_storm_spring"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Favela - Tropical",
|
||||
"Name": "mp_fav_tropical"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Estate - Tropical",
|
||||
"Name": "mp_estate_tropical"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Crash - Tropical",
|
||||
"Name": "mp_crash_tropical"
|
||||
},
|
||||
|
||||
{
|
||||
"Alias": "Forgotten City",
|
||||
"Name": "mp_bloc_sh"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -70,7 +70,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="xcopy /Y "$(SolutionDir)BUILD\Plugins" "$(TargetDir)Plugins\"
xcopy /Y /I /E "$(SolutionDir)BUILD\Lib" "$(TargetDir)" 

xcopy /Y /I /E "$(ProjectDir)Application\Config" "$(TargetDir)Config"" />
|
||||
<Exec Command="xcopy /Y "$(SolutionDir)BUILD\Plugins" "$(TargetDir)Plugins\"
xcopy /Y /I /E "$(SolutionDir)BUILD\Lib" "$(TargetDir)" 
" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user