Database cleanup and hopefully fixes for multithreaded tasks - SQLite library updated.

This commit is contained in:
RaidMax 2017-05-29 21:25:49 -05:00
parent d86836ae8d
commit 200c4d79fd
18 changed files with 339 additions and 193 deletions

View File

@ -90,6 +90,19 @@
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<WarningLevel>3</WarningLevel>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreGeneratedCode>false</CodeAnalysisIgnoreGeneratedCode>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kayak, Version=0.7.2.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@ -322,7 +335,8 @@ copy /Y "$(ProjectDir)lib\SQLite.Interop.dll" "$(SolutionDir)BUILD\lib"
if $(ConfigurationName) == Release powershell.exe -file "$(SolutionDir)DEPLOY\publish_nightly.ps1" 1.3</PostBuildEvent>
if $(ConfigurationName) == Release powershell.exe -file "$(SolutionDir)DEPLOY\publish_nightly.ps1" 1.3
if $(ConfigurationName) == Release-Stable powershell.exe -file "$(SolutionDir)DEPLOY\publish_stable.ps1" 1.3</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -15,12 +15,12 @@ namespace IW4MAdmin
public void AddPenalty(Penalty P)
{
Manager.GetInstance().GetClientDatabase().addBan(P);
Manager.GetInstance().GetClientDatabase().AddBan(P);
}
public void RemovePenalty(Penalty P)
{
Manager.GetInstance().GetClientDatabase().removeBan(P.npID);
Manager.GetInstance().GetClientDatabase().RemoveBan(P.npID);
}
public List<Penalty> FindPenalties(Player P)

View File

@ -21,7 +21,7 @@ namespace IW4MAdmin
{
foreach(String IP in currentAlias.IPS)
{
List<Aliases> Matching = Manager.GetAliasesDatabase().getPlayer(IP);
List<Aliases> Matching = Manager.GetAliasesDatabase().GetPlayerAliases(IP);
foreach(Aliases I in Matching)
{
if (!returnAliases.Contains(I) && returnAliases.Find(x => x.Number == I.Number) == null)
@ -40,7 +40,7 @@ namespace IW4MAdmin
if (Origin == null)
return allAliases;
Aliases currentIdentityAliases = Manager.GetAliasesDatabase().getPlayer(Origin.databaseID);
Aliases currentIdentityAliases = Manager.GetAliasesDatabase().GetPlayerAliases(Origin.databaseID);
if (currentIdentityAliases == null)
return allAliases;
@ -65,18 +65,18 @@ namespace IW4MAdmin
try
{
Player NewPlayer = Manager.GetClientDatabase().getPlayer(P.npID, P.clientID);
Player NewPlayer = Manager.GetClientDatabase().GetPlayer(P.npID, P.clientID);
if (NewPlayer == null) // first time connecting
{
Logger.WriteDebug($"Client slot #{P.clientID} first time connecting");
Manager.GetClientDatabase().addPlayer(P);
NewPlayer = Manager.GetClientDatabase().getPlayer(P.npID, P.clientID);
Manager.GetAliasesDatabase().addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
Manager.GetClientDatabase().AddPlayer(P);
NewPlayer = Manager.GetClientDatabase().GetPlayer(P.npID, P.clientID);
Manager.GetAliasesDatabase().AddPlayerAliases(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
}
List<Player> Admins = Manager.GetClientDatabase().getAdmins();
List<Player> Admins = Manager.GetClientDatabase().GetAdmins();
if (Admins.Find(x => x.Name == P.Name) != null)
{
if ((Admins.Find(x => x.Name == P.Name).npID != P.npID) && NewPlayer.Level < Player.Permission.Moderator)
@ -85,12 +85,12 @@ namespace IW4MAdmin
// below this needs to be optimized ~ 425ms runtime
NewPlayer.updateName(P.Name.Trim());
NewPlayer.Alias = Manager.GetAliasesDatabase().getPlayer(NewPlayer.databaseID);
NewPlayer.Alias = Manager.GetAliasesDatabase().GetPlayerAliases(NewPlayer.databaseID);
if (NewPlayer.Alias == null)
{
Manager.GetAliasesDatabase().addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
NewPlayer.Alias = Manager.GetAliasesDatabase().getPlayer(NewPlayer.databaseID);
Manager.GetAliasesDatabase().AddPlayerAliases(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
NewPlayer.Alias = Manager.GetAliasesDatabase().GetPlayerAliases(NewPlayer.databaseID);
}
if (P.lastEvent == null || P.lastEvent.Owner == null)
@ -113,8 +113,8 @@ namespace IW4MAdmin
NewPlayer.updateIP(P.IP);
Manager.GetAliasesDatabase().updatePlayer(NewPlayer.Alias);
Manager.GetClientDatabase().updatePlayer(NewPlayer);
Manager.GetAliasesDatabase().UpdatePlayerAliases(NewPlayer.Alias);
Manager.GetClientDatabase().UpdatePlayer(NewPlayer);
await ExecuteEvent(new Event(Event.GType.Connect, "", NewPlayer, null, this));
@ -152,9 +152,6 @@ namespace IW4MAdmin
Players[NewPlayer.clientID] = null;
Players[NewPlayer.clientID] = NewPlayer;
#if DEBUG == FALSE
await NewPlayer.Tell($"Welcome ^5{NewPlayer.Name} ^7this is your ^5{NewPlayer.TimesConnected()} ^7time connecting!");
#endif
Logger.WriteInfo($"Client {NewPlayer.Name}::{NewPlayer.npID} connecting..."); // they're clean
// todo: get this out of here
@ -184,7 +181,7 @@ namespace IW4MAdmin
{
Player Leaving = Players[cNum];
Leaving.Connections++;
Manager.GetClientDatabase().updatePlayer(Leaving);
Manager.GetClientDatabase().UpdatePlayer(Leaving);
Logger.WriteInfo($"Client {Leaving.Name}::{Leaving.npID} disconnecting...");
await ExecuteEvent(new Event(Event.GType.Disconnect, "", Leaving, null, this));
@ -277,7 +274,7 @@ namespace IW4MAdmin
int.TryParse(Args[0].Substring(1, Args[0].Length-1), out dbID);
IW4MServer castServer = (IW4MServer)(E.Owner);
Player found = Manager.GetClientDatabase().getPlayer(dbID);
Player found = Manager.GetClientDatabase().GetPlayer(dbID);
if (found != null)
{
E.Target = found;
@ -715,7 +712,7 @@ namespace IW4MAdmin
await Task.Run(() =>
{
Manager.GetClientPenalties().AddPenalty(newBan);
Manager.GetClientDatabase().updatePlayer(Target);
Manager.GetClientDatabase().UpdatePlayer(Target);
});
lock (Reports) // threading seems to do something weird here
@ -749,9 +746,9 @@ namespace IW4MAdmin
Manager.GetClientPenalties().RemovePenalty(PenaltyToRemove);
Player P = Manager.GetClientDatabase().getPlayer(Target.npID, -1);
Player P = Manager.GetClientDatabase().GetPlayer(Target.npID, -1);
P.setLevel(Player.Permission.User);
Manager.GetClientDatabase().updatePlayer(P);
Manager.GetClientDatabase().UpdatePlayer(P);
});
}
@ -786,7 +783,7 @@ namespace IW4MAdmin
override public void initMacros()
{
Macros = new Dictionary<String, Object>();
Macros.Add("TOTALPLAYERS", Manager.GetClientDatabase().totalPlayers());
Macros.Add("TOTALPLAYERS", Manager.GetClientDatabase().TotalPlayers());
Macros.Add("TOTALKILLS", totalKills);
Macros.Add("VERSION", IW4MAdmin.Program.Version);
}

View File

@ -287,7 +287,7 @@ namespace IW4MAdmin
if (S != null)
{
Player admin = Manager.GetInstance().GetClientDatabase().getPlayer(querySet["IP"]);
Player admin = Manager.GetInstance().GetClientDatabase().GetPlayer(querySet["IP"]);
if (admin == null)
admin = new Player("RestUser", "-1", -1, (int)Player.Permission.User);
@ -366,8 +366,8 @@ namespace IW4MAdmin
foreach (var p in selectedPenalties)
{
Player admin = Manager.GetInstance().GetClientDatabase().getPlayer(p.bannedByID, 0);
Player penalized = Manager.GetInstance().GetClientDatabase().getPlayer(p.npID, 0);
Player admin = Manager.GetInstance().GetClientDatabase().GetPlayer(p.bannedByID, 0);
Player penalized = Manager.GetInstance().GetClientDatabase().GetPlayer(p.npID, 0);
if (admin == null && penalized == null)
continue;
if (admin == null)
@ -591,26 +591,26 @@ namespace IW4MAdmin
resp.contentType = getContentType();
resp.additionalHeaders = new Dictionary<string, string>();
bool authed = Manager.GetInstance().GetClientDatabase().getAdmins().FindAll(x => x.IP == querySet["IP"]).Count > 0;
bool authed = Manager.GetInstance().GetClientDatabase().GetAdmins().FindAll(x => x.IP == querySet["IP"]).Count > 0;
if (querySet["id"] != null)
{
matchedPlayers.Add(Manager.GetInstance().GetClientDatabase().getPlayer(Convert.ToInt32(querySet["id"])));
matchedPlayers.Add(Manager.GetInstance().GetClientDatabase().GetPlayer(Convert.ToInt32(querySet["id"])));
}
else if (querySet["npID"] != null)
{
matchedPlayers.Add(Manager.GetInstance().GetClientDatabase().getPlayers(new List<string> { querySet["npID"] }).First());
matchedPlayers.Add(Manager.GetInstance().GetClientDatabase().GetPlayers(new List<string> { querySet["npID"] }).First());
}
else if (querySet["name"] != null)
{
matchedPlayers = Manager.GetInstance().GetClientDatabase().findPlayers(querySet["name"]);
matchedPlayers = Manager.GetInstance().GetClientDatabase().FindPlayers(querySet["name"]);
}
else if (querySet["recent"] != null)
{
matchedPlayers = Manager.GetInstance().GetClientDatabase().getRecentPlayers();
matchedPlayers = Manager.GetInstance().GetClientDatabase().GetRecentPlayers();
}
if (matchedPlayers != null && matchedPlayers.Count > 0)

Binary file not shown.

Binary file not shown.

View File

@ -32,6 +32,15 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />

View File

@ -37,6 +37,15 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>

View File

@ -46,6 +46,10 @@ Global
Release|Mixed Platforms = Release|Mixed Platforms
Release|x64 = Release|x64
Release|x86 = Release|x86
Release-Stable|Any CPU = Release-Stable|Any CPU
Release-Stable|Mixed Platforms = Release-Stable|Mixed Platforms
Release-Stable|x64 = Release-Stable|x64
Release-Stable|x86 = Release-Stable|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@ -64,6 +68,14 @@ Global
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x64.Build.0 = Release|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x86.ActiveCfg = Release|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x86.Build.0 = Release|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -80,6 +92,14 @@ Global
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x64.Build.0 = Release|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x86.ActiveCfg = Release|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x86.Build.0 = Release|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -96,6 +116,14 @@ Global
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x64.Build.0 = Release|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x86.ActiveCfg = Release|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x86.Build.0 = Release|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -112,6 +140,14 @@ Global
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x64.Build.0 = Release|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x86.ActiveCfg = Release|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x86.Build.0 = Release|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -128,6 +164,14 @@ Global
{2321A25F-7871-47C3-8440-02551918D6A1}.Release|x64.Build.0 = Release|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release|x86.ActiveCfg = Release|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release|x86.Build.0 = Release|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -144,6 +188,14 @@ Global
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|x64.Build.0 = Release|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|x86.ActiveCfg = Release|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|x86.Build.0 = Release|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -156,6 +208,14 @@ Global
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|x64.ActiveCfg = Release|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|x86.ActiveCfg = Release|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -172,6 +232,14 @@ Global
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x64.Build.0 = Release|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x86.ActiveCfg = Release|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x86.Build.0 = Release|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -37,6 +37,15 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Compile Include="Encryption.cs" />
<Compile Include="Events.cs" />
@ -68,8 +77,7 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite">
<HintPath>..\SharedLibrary\bin\Release\System.Data.SQLite.dll</HintPath>
<Private>False</Private>
<HintPath>..\Admin\lib\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.Web" />

View File

@ -24,12 +24,12 @@ namespace SharedLibrary.Commands
public override async Task ExecuteAsync(Event E)
{
if (E.Owner.Manager.GetClientDatabase().getOwner() == null)
if (E.Owner.Manager.GetClientDatabase().GetOwner() == null)
{
E.Origin.setLevel(Player.Permission.Owner);
await E.Origin.Tell("Congratulations, you have claimed ownership of this server!");
E.Owner.owner = E.Origin;
E.Owner.Manager.GetClientDatabase().updatePlayer(E.Origin);
E.Owner.Manager.GetClientDatabase().UpdatePlayer(E.Origin);
}
else
await E.Origin.Tell("This server already has an owner!");
@ -302,7 +302,7 @@ namespace SharedLibrary.Commands
await E.Origin.Tell(E.Target.Name + " was successfully promoted!");
//NEEED TO MOVE
E.Owner.Manager.GetClientDatabase().updatePlayer(E.Target);
E.Owner.Manager.GetClientDatabase().UpdatePlayer(E.Target);
}
else
@ -376,7 +376,7 @@ namespace SharedLibrary.Commands
public override async Task ExecuteAsync(Event E)
{
var db_players = E.Owner.Manager.GetClientDatabase().findPlayers(E.Data.Trim());
var db_players = E.Owner.Manager.GetClientDatabase().FindPlayers(E.Data.Trim());
if (db_players == null)
{
@ -406,7 +406,7 @@ namespace SharedLibrary.Commands
return;
}
var db_aliases = E.Owner.Manager.GetAliasesDatabase().findPlayers(E.Data);
var db_aliases = E.Owner.Manager.GetAliasesDatabase().FindPlayerAliases(E.Data);
if (db_aliases == null)
{
@ -427,7 +427,7 @@ namespace SharedLibrary.Commands
lookingFor = S;
}
Player Current = E.Owner.Manager.GetClientDatabase().getPlayer(P.Number);
Player Current = E.Owner.Manager.GetClientDatabase().GetPlayer(P.Number);
if (Current != null)
{
@ -503,7 +503,7 @@ namespace SharedLibrary.Commands
await E.Origin.Tell("You have ^5flagged ^7" + E.Target.Name);
}
E.Owner.Manager.GetClientDatabase().updatePlayer(E.Target);
E.Owner.Manager.GetClientDatabase().UpdatePlayer(E.Target);
}
}
@ -606,7 +606,7 @@ namespace SharedLibrary.Commands
return;
}
Player Banner = E.Owner.Manager.GetClientDatabase().getPlayer(BannedPenalty.bannedByID, -1);
Player Banner = E.Owner.Manager.GetClientDatabase().GetPlayer(BannedPenalty.bannedByID, -1);
if (Banner == null)
{
@ -624,7 +624,7 @@ namespace SharedLibrary.Commands
public override async Task ExecuteAsync(Event E)
{
E.Target.Alias = E.Owner.Manager.GetAliasesDatabase().getPlayer(E.Target.databaseID);
E.Target.Alias = E.Owner.Manager.GetAliasesDatabase().GetPlayerAliases(E.Target.databaseID);
if (E.Target.Alias == null)
{

View File

@ -12,12 +12,14 @@ namespace SharedLibrary
public Database(String FN)
{
FileName = FN;
DBCon = String.Format("Data Source={0}", FN);
Con = new SQLiteConnection(DBCon);
Open = false;
Init();
}
protected SQLiteConnection GetNewConnection()
{
return new SQLiteConnection($"Data Source={FileName}");
}
abstract public void Init();
protected bool Insert(String tableName, Dictionary<String, object> data)
@ -32,10 +34,13 @@ namespace SharedLibrary
names = names.Substring(0, names.Length - 1);
parameters = parameters.Substring(0, parameters.Length - 1);
SQLiteCommand insertcmd = new SQLiteCommand();
insertcmd.Connection = this.Con;
insertcmd.CommandText = String.Format("INSERT INTO `{0}` ({1}) VALUES ({2});", tableName, names, parameters);
var Con = GetNewConnection();
SQLiteCommand insertcmd = new SQLiteCommand()
{
Connection = Con,
CommandText = String.Format("INSERT INTO `{0}` ({1}) VALUES ({2});", tableName, names, parameters)
};
foreach (string key in data.Keys)
{
insertcmd.Parameters.AddWithValue('@' + key, data[key]);
@ -49,9 +54,9 @@ namespace SharedLibrary
return true;
}
catch (Exception)
catch (Exception E)
{
//LOGME
Console.WriteLine($"Line 58: {E.Message}");
return false;
}
@ -66,11 +71,13 @@ namespace SharedLibrary
}
parameters = parameters.Substring(0, parameters.Length - 1);
var Con = GetNewConnection();
SQLiteCommand updatecmd = new SQLiteCommand();
updatecmd.Connection = this.Con;
updatecmd.CommandText = String.Format("UPDATE `{0}` SET {1} WHERE {2}=@{2}", tableName, parameters, where.Key);
SQLiteCommand updatecmd = new SQLiteCommand()
{
Connection = Con,
CommandText = String.Format("UPDATE `{0}` SET {1} WHERE {2}=@{2}", tableName, parameters, where.Key)
};
foreach (string key in data.Keys)
{
updatecmd.Parameters.AddWithValue('@' + key, data[key]);
@ -86,14 +93,14 @@ namespace SharedLibrary
return true;
}
catch (Exception e)
catch (Exception E)
{
//LOGME
Console.WriteLine($"Line 96: {E.Message}");
return false;
}
}
protected DataRow getDataRow(String Q)
protected DataRow GetDataRow(String Q)
{
DataRow Result = GetDataTable(Q).Rows[0];
return Result;
@ -101,19 +108,19 @@ namespace SharedLibrary
protected int ExecuteNonQuery(String Request)
{
waitForClose();
int rowsUpdated = 0;
Request = Request.Replace("!'", "").Replace("!", "");
var Con = GetNewConnection();
try
{
lock (Con)
{
Con.Open();
SQLiteCommand CMD = new SQLiteCommand(Con);
CMD.CommandText = Request;
rowsUpdated = CMD.ExecuteNonQuery();
SQLiteCommand CMD = new SQLiteCommand(Con)
{
CommandText = Request
};
rowsUpdated = CMD.ExecuteNonQuery();
Con.Close();
}
return rowsUpdated;
}
@ -130,10 +137,12 @@ namespace SharedLibrary
protected DataTable GetDataTable(string tableName, KeyValuePair<string, object> where)
{
DataTable dt = new DataTable();
SQLiteCommand updatecmd = new SQLiteCommand();
updatecmd.Connection = this.Con;
updatecmd.CommandText = String.Format("SELECT * FROM {0} WHERE `{1}`=@{1};", tableName, where.Key);
SQLiteCommand updatecmd = new SQLiteCommand()
{
CommandText = String.Format("SELECT * FROM {0} WHERE `{1}`=@{1};", tableName, where.Key)
};
updatecmd.Parameters.AddWithValue('@' + where.Key, where.Value);
var Con = GetNewConnection();
try
{
@ -156,6 +165,7 @@ namespace SharedLibrary
protected DataTable GetDataTable(SQLiteCommand cmd)
{
DataTable dt = new DataTable();
var Con = GetNewConnection();
try
{
Con.Open();
@ -177,20 +187,20 @@ namespace SharedLibrary
protected DataTable GetDataTable(String sql)
{
DataTable dt = new DataTable();
var Con = GetNewConnection();
try
{
waitForClose();
lock (Con)
{
Con.Open();
SQLiteCommand mycommand = new SQLiteCommand(Con);
mycommand.CommandText = sql;
SQLiteDataReader reader = mycommand.ExecuteReader();
SQLiteCommand mycommand = new SQLiteCommand(Con)
{
CommandText = sql
};
SQLiteDataReader reader = mycommand.ExecuteReader();
dt.Load(reader);
reader.Close();
Con.Close();
}
}
catch (Exception e)
@ -201,20 +211,7 @@ namespace SharedLibrary
return dt;
}
protected void waitForClose()
{
while (Con.State == ConnectionState.Open)
{
Utilities.Wait(0.01);
}
return;
}
protected String FileName;
protected String DBCon;
protected SQLiteConnection Con;
protected bool Open;
}
public class ClientsDB : Database
@ -232,25 +229,8 @@ namespace SharedLibrary
}
}
//Returns a single player object with matching GUID, false if no matches
public Player getPlayer(String ID, int cNum)
{
DataTable Result = GetDataTable("CLIENTS", new KeyValuePair<string, object>("npID", ID));
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
DateTime lastCon = DateTime.MinValue;
DateTime.TryParse(ResponseRow["LastConnection"].ToString(), out lastCon);
return new Player(ResponseRow["Name"].ToString(), ResponseRow["npID"].ToString(), cNum, (Player.Permission)(ResponseRow["Level"]), Convert.ToInt32(ResponseRow["Number"]), ResponseRow["LastOffense"].ToString(), (int)ResponseRow["Connections"], ResponseRow["IP"].ToString(), lastCon, ResponseRow["UID"].ToString(), ResponseRow["Masked"].ToString() == "1");
}
else
return null;
}
public List<Player> getRecentPlayers()
public List<Player> GetRecentPlayers()
{
List<Player> returnssss = new List<Player>();
String Query = String.Format($"SELECT * FROM CLIENTS LIMIT 15 OFFSET (SELECT COUNT(*) FROM CLIENTS)-15");
@ -270,7 +250,7 @@ namespace SharedLibrary
return returnssss.OrderByDescending(p => p.LastConnection).ToList(); ;
}
public List<Player> getPlayers(List<String> npIDs)
public List<Player> GetPlayers(List<String> npIDs)
{
List<Player> returnssss = new List<Player>();
String test = String.Join("' OR npID = '", npIDs);
@ -292,12 +272,12 @@ namespace SharedLibrary
return returnssss;
}
public List<Player> getPlayers(List<int> databaseIDs)
public List<Player> GetPlayers(List<int> databaseIDs)
{
List<Player> returnssss = new List<Player>();
String test = String.Join("' OR Number = '", databaseIDs);
String Condition = String.Join("' OR Number = '", databaseIDs);
String Query = String.Format("SELECT * FROM CLIENTS WHERE Number = '{0}'", test);
String Query = String.Format("SELECT * FROM CLIENTS WHERE Number = '{0}'", Condition);
DataTable Result = GetDataTable(Query);
if (Result != null && Result.Rows.Count > 0)
@ -315,7 +295,7 @@ namespace SharedLibrary
}
//Overloaded method for getPlayer, returns Client with matching DBIndex, null if none found
public Player getPlayer(int dbIndex)
public Player GetPlayer(int dbIndex)
{
DataTable Result = GetDataTable("CLIENTS", new KeyValuePair<string, object>("Number", dbIndex));
@ -340,7 +320,7 @@ namespace SharedLibrary
}
//get player by ip, (used for webfront)
public Player getPlayer(String IP)
public Player GetPlayer(String IP)
{
DataTable Result = GetDataTable("CLIENTS", new KeyValuePair<string, object>("IP", IP));
@ -376,11 +356,32 @@ namespace SharedLibrary
return null;
}
//Returns a list of players matching name parameter, null if no players found matching
public List<Player> findPlayers(String name)
//Returns a single player object with matching GUID, false if no matches
public Player GetPlayer(String ID, int cNum)
{
SQLiteCommand cmd = new SQLiteCommand(Con);
cmd.CommandText = "SELECT * FROM CLIENTS WHERE Name LIKE @Name LIMIT 32";
DataTable Result = GetDataTable("CLIENTS", new KeyValuePair<string, object>("npID", ID));
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
DateTime lastCon = DateTime.MinValue;
DateTime.TryParse(ResponseRow["LastConnection"].ToString(), out lastCon);
return new Player(ResponseRow["Name"].ToString(), ResponseRow["npID"].ToString(), cNum, (Player.Permission)(ResponseRow["Level"]), Convert.ToInt32(ResponseRow["Number"]), ResponseRow["LastOffense"].ToString(), (int)ResponseRow["Connections"], ResponseRow["IP"].ToString(), lastCon, ResponseRow["UID"].ToString(), ResponseRow["Masked"].ToString() == "1");
}
else
return null;
}
//Returns a list of players matching name parameter, null if no players found matching
public List<Player> FindPlayers(String name)
{
var Con = GetNewConnection();
SQLiteCommand cmd = new SQLiteCommand(Con)
{
CommandText = "SELECT * FROM CLIENTS WHERE Name LIKE @Name LIMIT 32"
};
cmd.Parameters.AddWithValue("@Name", '%' + name + '%');
var Result = GetDataTable(cmd);
@ -416,7 +417,7 @@ namespace SharedLibrary
}
//Returns any player with level 4 permissions, null if no owner found
public Player getOwner()
public Player GetOwner()
{
String Query = String.Format("SELECT * FROM CLIENTS WHERE Level > '{0}'", 4);
DataTable Result = GetDataTable(Query);
@ -444,7 +445,7 @@ namespace SharedLibrary
if (Row["TIME"].ToString().Length < 2) //compatibility with my old database
Row["TIME"] = DateTime.Now.ToString();
SharedLibrary.Penalty.Type BanType = Penalty.Type.Ban;
Penalty.Type BanType = Penalty.Type.Ban;
if (Row["TYPE"].ToString().Length != 0)
BanType = (Penalty.Type)Enum.Parse(typeof(Penalty.Type), Row["TYPE"].ToString());
@ -465,7 +466,7 @@ namespace SharedLibrary
if (Row["TIME"].ToString().Length < 2) //compatibility with my old database
Row["TIME"] = DateTime.Now.ToString();
SharedLibrary.Penalty.Type BanType = Penalty.Type.Ban;
Penalty.Type BanType = Penalty.Type.Ban;
if (Row["TYPE"].ToString().Length != 0)
BanType = (Penalty.Type)Enum.Parse(typeof(Penalty.Type), Row["TYPE"].ToString());
@ -477,7 +478,7 @@ namespace SharedLibrary
}
//Returns all players with level > Flagged
public List<Player> getAdmins()
public List<Player> GetAdmins()
{
List<Player> Admins = new List<Player>();
String Query = String.Format("SELECT * FROM CLIENTS WHERE Level >= '{0}'", (int)Player.Permission.Moderator);
@ -490,7 +491,7 @@ namespace SharedLibrary
}
//Returns total number of player entries in database
public int totalPlayers()
public int TotalPlayers()
{
DataTable Result = GetDataTable("SELECT * from CLIENTS ORDER BY Number DESC LIMIT 1");
if (Result.Rows.Count > 0)
@ -500,66 +501,66 @@ namespace SharedLibrary
}
//Add specified player to database
public void addPlayer(Player P)
public void AddPlayer(Player P)
{
Dictionary<String, object> newPlayer = new Dictionary<String, object>();
newPlayer.Add("Name", Utilities.removeNastyChars(P.Name));
newPlayer.Add("npID", P.npID);
newPlayer.Add("Level", (int)P.Level);
newPlayer.Add("LastOffense", "");
newPlayer.Add("Connections", 1);
newPlayer.Add("IP", P.IP);
newPlayer.Add("LastConnection", Utilities.DateTimeSQLite(DateTime.Now));
newPlayer.Add("UID", P.UID);
newPlayer.Add("Masked", Convert.ToInt32(P.Masked));
Dictionary<String, object> newPlayer = new Dictionary<String, object>
{
{ "Name", Utilities.removeNastyChars(P.Name) },
{ "npID", P.npID },
{ "Level", (int)P.Level },
{ "LastOffense", "" },
{ "Connections", 1 },
{ "IP", P.IP },
{ "LastConnection", Utilities.DateTimeSQLite(DateTime.Now) },
{ "UID", P.UID },
{ "Masked", Convert.ToInt32(P.Masked) }
};
Insert("CLIENTS", newPlayer);
}
///Update information of specified player
public void updatePlayer(Player P)
public void UpdatePlayer(Player P)
{
Dictionary<String, Object> updatedPlayer = new Dictionary<String, Object>();
updatedPlayer.Add("Name", P.Name);
updatedPlayer.Add("npID", P.npID);
updatedPlayer.Add("Level", (int)P.Level);
updatedPlayer.Add("LastOffense", P.lastOffense);
updatedPlayer.Add("Connections", P.Connections);
updatedPlayer.Add("IP", P.IP);
updatedPlayer.Add("LastConnection", Utilities.DateTimeSQLite(DateTime.Now));
updatedPlayer.Add("UID", P.UID);
updatedPlayer.Add("Masked", Convert.ToInt32(P.Masked));
Dictionary<String, Object> updatedPlayer = new Dictionary<String, Object>
{
{ "Name", P.Name },
{ "npID", P.npID },
{ "Level", (int)P.Level },
{ "LastOffense", P.lastOffense },
{ "Connections", P.Connections },
{ "IP", P.IP },
{ "LastConnection", Utilities.DateTimeSQLite(DateTime.Now) },
{ "UID", P.UID },
{ "Masked", Convert.ToInt32(P.Masked) }
};
Update("CLIENTS", updatedPlayer, new KeyValuePair<string, object>("npID", P.npID));
}
//Add specified ban to database
public void addBan(Penalty B)
public void AddBan(Penalty B)
{
Dictionary<String, object> newBan = new Dictionary<String, object>();
newBan.Add("Reason", Utilities.removeNastyChars(B.Reason));
newBan.Add("npID", B.npID);
newBan.Add("bannedByID", B.bannedByID);
newBan.Add("IP", B.IP);
newBan.Add("TIME", Utilities.DateTimeSQLite(DateTime.Now));
newBan.Add("TYPE", B.BType);
Dictionary<String, object> newBan = new Dictionary<String, object>
{
{ "Reason", Utilities.removeNastyChars(B.Reason) },
{ "npID", B.npID },
{ "bannedByID", B.bannedByID },
{ "IP", B.IP },
{ "TIME", Utilities.DateTimeSQLite(DateTime.Now) },
{ "TYPE", B.BType }
};
Insert("BANS", newBan);
}
//Deletes ban with matching GUID
public void removeBan(String GUID)
public void RemoveBan(String GUID)
{
String Query = String.Format("DELETE FROM BANS WHERE npID = '{0}'", GUID);
ExecuteNonQuery(Query);
}
public void removeBan(String GUID, String IP)
public void RemoveBan(String GUID, String IP)
{
String Query = String.Format("DELETE FROM BANS WHERE npID = '{0}' or IP = '{1}'", GUID, IP);
ExecuteNonQuery(Query);
@ -579,7 +580,7 @@ namespace SharedLibrary
}
}
public Aliases getPlayer(int dbIndex)
public Aliases GetPlayerAliases(int dbIndex)
{
String Query = String.Format("SELECT * FROM ALIASES WHERE Number = '{0}' LIMIT 1", dbIndex);
DataTable Result = GetDataTable(Query);
@ -594,10 +595,13 @@ namespace SharedLibrary
return null;
}
public List<Aliases> getPlayer(String IP)
public List<Aliases> GetPlayerAliases(String IP)
{
SQLiteCommand cmd = new SQLiteCommand(Con);
cmd.CommandText = "SELECT * FROM ALIASES WHERE IPS LIKE @IP";
var Con = GetNewConnection();
SQLiteCommand cmd = new SQLiteCommand(Con)
{
CommandText = "SELECT * FROM ALIASES WHERE IPS LIKE @IP"
};
cmd.Parameters.AddWithValue("@IP", IP);
var Result = GetDataTable(cmd);
@ -613,18 +617,21 @@ namespace SharedLibrary
return players;
}
public List<Aliases> findPlayers(String name)
public List<Aliases> FindPlayerAliases(String name)
{
name = name.Replace("'", "");
String[] EyePee = name.Split('.');
String Penor = "THISISNOTANIP";
if (EyePee.Length > 1)
Penor = (EyePee[0] + '.' + EyePee[1] + '.');
String[] IP = name.Split('.');
String DefaultIP = "LEGACY_INVALID_IP";
if (IP.Length > 1)
DefaultIP = (IP[0] + '.' + IP[1] + '.');
var Con = GetNewConnection();
SQLiteCommand cmd = new SQLiteCommand(Con);
cmd.CommandText = "SELECT * FROM ALIASES WHERE NAMES LIKE @name OR IPS LIKE @ip LIMIT 15";
SQLiteCommand cmd = new SQLiteCommand(Con)
{
CommandText = "SELECT * FROM ALIASES WHERE NAMES LIKE @name OR IPS LIKE @ip LIMIT 15"
};
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@ip", Penor);
cmd.Parameters.AddWithValue("@ip", DefaultIP);
var Result = GetDataTable(cmd);
@ -640,25 +647,25 @@ namespace SharedLibrary
return players;
}
public void addPlayer(Aliases Alias)
public void AddPlayerAliases(Aliases Alias)
{
Dictionary<String, object> newPlayer = new Dictionary<String, object>();
newPlayer.Add("Number", Alias.Number);
newPlayer.Add("NAMES", Utilities.removeNastyChars(String.Join(";", Alias.Names)));
newPlayer.Add("IPS", String.Join(";", Alias.IPS));
Dictionary<String, object> newPlayer = new Dictionary<String, object>
{
{ "Number", Alias.Number },
{ "NAMES", Utilities.removeNastyChars(String.Join(";", Alias.Names)) },
{ "IPS", String.Join(";", Alias.IPS) }
};
Insert("ALIASES", newPlayer);
}
public void updatePlayer(Aliases Alias)
public void UpdatePlayerAliases(Aliases Alias)
{
Dictionary<String, object> updatedPlayer = new Dictionary<String, object>();
updatedPlayer.Add("Number", Alias.Number);
updatedPlayer.Add("NAMES", String.Join(";", Alias.Names));
updatedPlayer.Add("IPS", String.Join(";", Alias.IPS));
Dictionary<String, object> updatedPlayer = new Dictionary<String, object>
{
{ "Number", Alias.Number },
{ "NAMES", String.Join(";", Alias.Names) },
{ "IPS", String.Join(";", Alias.IPS) }
};
Update("ALIASES", updatedPlayer, new KeyValuePair<string, object>("Number", Alias.Number));
}
}

View File

@ -39,7 +39,7 @@ namespace SharedLibrary
var commands = mgr.GetCommands();
owner = Manager.GetClientDatabase().getOwner();
owner = Manager.GetClientDatabase().GetOwner();
if (owner == null)
commands.Add(new Owner("owner", "claim ownership of the server", "owner", Player.Permission.User, 0, false));
@ -129,7 +129,7 @@ namespace SharedLibrary
foreach (Aliases A in GetAliases(Origin))
databaseIDs.Add(A.Number);
return Manager.GetClientDatabase().getPlayers(databaseIDs);
return Manager.GetClientDatabase().GetPlayers(databaseIDs);
}
/// <summary>
@ -220,7 +220,6 @@ namespace SharedLibrary
/// <param name="Message">Message to be sent to all players</param>
public async Task Broadcast(String Message)
{
return;
await this.ExecuteCommandAsync($"sayraw {Message}");
}
@ -231,7 +230,6 @@ namespace SharedLibrary
/// <param name="Target">Player to send message to</param>
public async Task Tell(String Message, Player Target)
{
return;
if (Target.clientID > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console && !Target.lastEvent.Remote)
await this.ExecuteCommandAsync($"tellraw {Target.clientID} {Message}^7");

View File

@ -38,6 +38,15 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
@ -45,7 +54,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
<HintPath>D:\SOURCE\Admin\lib\System.Data.SQLite.dll</HintPath>
<HintPath>..\Admin\lib\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />

View File

@ -46,7 +46,7 @@ namespace StatsPlugin
await E.Origin.Tell("^5--Top Players--");
foreach (KeyValuePair<String, PlayerStats> pStat in pStats)
{
Player P = E.Owner.Manager.GetClientDatabase().getPlayer(pStat.Key, -1);
Player P = E.Owner.Manager.GetClientDatabase().GetPlayer(pStat.Key, -1);
if (P == null)
continue;
await E.Origin.Tell(String.Format("^3{0}^7 - ^5{1} ^7KDR | ^5{2} ^7SKILL", P.Name, pStat.Value.KDR, pStat.Value.Skill));
@ -132,7 +132,7 @@ namespace StatsPlugin
if (checkForTrusted.playTime >= 4320 && E.Origin.Level < Player.Permission.Trusted)
{
E.Origin.setLevel(Player.Permission.Trusted);
E.Owner.Manager.GetClientDatabase().updatePlayer(E.Origin);
E.Owner.Manager.GetClientDatabase().UpdatePlayer(E.Origin);
await E.Origin.Tell("Congratulations, you are now a ^5trusted ^7player! Type ^5!help ^7to view new commands.");
await E.Origin.Tell("You earned this by playing for ^53 ^7full days!");
}

View File

@ -32,11 +32,20 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
<HintPath>..\SharedLibrary\bin\Release\System.Data.SQLite.dll</HintPath>
<HintPath>..\Admin\lib\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />

View File

@ -37,6 +37,15 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>

View File

@ -32,6 +32,15 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>