Added localhost API server

This commit is contained in:
Hetal728 2015-09-06 15:28:42 -04:00
parent d19efd05cc
commit aced40948d
25 changed files with 566 additions and 228 deletions

14
API.cs Normal file
View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MCGalaxy
{
public class API
{
public string[] players { get; set; }
public int max_players { get; set; }
public ChatMessage[] chat { get; set; }
}
}

14
ChatMessage.cs Normal file
View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MCGalaxy
{
public class ChatMessage
{
public string text { get; set; }
public string time { get; set; }
public string username { get; set; }
}
}

View File

@ -195,6 +195,14 @@ namespace MCGalaxy
public static void MinecraftToIrcColors(StringBuilder sb)
{
if (sb == null) throw new ArgumentNullException("sb");
for (int i = 0; i < 10; i++)
{
sb.Replace("%" + i, "&" + i);
}
for (char ch = 'a'; ch <= 'f'; ch++)
{
sb.Replace("%" + ch, "&" + ch);
}
foreach (var codePair in MinecraftToIRCColors)
{
sb.Replace(codePair.Key, codePair.Value);

View File

@ -500,8 +500,8 @@ namespace MCGalaxy.Commands
case "horizon":
case "edge":
case "water":
byte block = Block.water;
if (Block.Byte(valueText) != Block.Zero && !(valueText.Equals("normal", StringComparison.OrdinalIgnoreCase) || valueText.Equals("default", StringComparison.OrdinalIgnoreCase)))
byte block = Block.Byte(valueText);
if (block == Block.Zero && !(valueText.Equals("normal", StringComparison.OrdinalIgnoreCase) || valueText.Equals("default", StringComparison.OrdinalIgnoreCase)))
{
Help(p);
return;
@ -536,8 +536,8 @@ namespace MCGalaxy.Commands
case "side":
case "border":
case "bedrock":
byte blockhorizon = Block.blackrock;
if (Block.Byte(valueText) == Block.Zero && !(valueText.Equals("normal", StringComparison.OrdinalIgnoreCase) || valueText.Equals("default", StringComparison.OrdinalIgnoreCase)))
byte blockhorizon = Block.Byte(valueText);
if (blockhorizon == Block.Zero && !(valueText.Equals("normal", StringComparison.OrdinalIgnoreCase) || valueText.Equals("default", StringComparison.OrdinalIgnoreCase)))
{
Help(p);
return;

View File

@ -144,7 +144,7 @@ namespace MCGalaxy.Commands
return true;
}
return false;
return true;
}
}
}

View File

@ -16,6 +16,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message)
{
p.totalKicked = p.totalKicked - 1;
if (message != "")
{
p.Kick("Left the game: " + message);

View File

@ -26,6 +26,7 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override void Use(Player p, string message)
{
p.totalKicked = p.totalKicked - 1;
p.Kick("RAGEQUIT!!");
}

View File

@ -44,7 +44,7 @@ namespace MCGalaxy.Commands
string FoundRank = Group.findPlayer(message.ToLower());
Database.AddParams("@Name", message);
DataTable playerDb = Database.fillData("SELECT * FROM Players WHERE Name=@Name");
DataTable playerDb = Database.fillData("SELECT * FROM Players WHERE Name=@Name COLLATE NOCASE");
if (playerDb.Rows.Count == 0) { Player.SendMessage(p, Group.Find(FoundRank).color + message + Server.DefaultColor + " has the rank of " + Group.Find(FoundRank).color + FoundRank); return; }
string title = playerDb.Rows[0]["Title"].ToString();
string color = c.Parse(playerDb.Rows[0]["color"].ToString().Trim());

View File

@ -85,26 +85,15 @@ namespace MCGalaxy {
}
public void Say(string message, bool opchat = false, bool color = true) {
if (!Server.irc || !IsConnected()) return;
StringBuilder sb = new StringBuilder(message);
if(String.IsNullOrEmpty(message.Trim()))
message = ".";
if (color) {
for (int i = 0; i < 10; i++)
{
sb.Replace("%" + i, ColorSignal + c.MCtoIRC("&" + i));
sb.Replace("&" + i, ColorSignal + c.MCtoIRC("&" + i));
}
for (char ch = 'a'; ch <= 'f'; ch++)
{
sb.Replace("%" + ch, ColorSignal + c.MCtoIRC("&" + ch));
sb.Replace("&" + ch, ColorSignal + c.MCtoIRC("&" + ch));
}
message = c.MinecraftToIrcColors(message).Replace("%r", ResetSignal);
}
sb.Replace("%r", ResetSignal);
connection.Sender.PublicMessage(opchat ? opchannel : channel, sb.ToString());
connection.Sender.PublicMessage(opchat ? opchannel : channel, message);
}
public void Pm(string user, string message) {
if (Server.irc && IsConnected())
@ -211,10 +200,6 @@ namespace MCGalaxy {
Server.IRC.Say("Unknown command!");
}
}
for (byte i = 10; i < 16; i++)
message = message.Replace(ColorSignal + i, c.IRCtoMC(i).Replace('&', '%'));
for (byte i = 0; i < 10; i++)
message = message.Replace(ColorSignal + i, c.IRCtoMC(i).Replace('&', '%'));
message = c.IrcToMinecraftColors(message);
if(String.IsNullOrEmpty(message.Trim()))

View File

@ -48,7 +48,6 @@ namespace MCGalaxy
public void OnResponse(string line)
{
// Only run the code below if we receive a response
if (!String.IsNullOrEmpty(line.Trim()))
{

View File

@ -481,6 +481,7 @@ namespace MCGalaxy
}
public void SetTile(ushort x, ushort y, ushort z, byte type, Player p = null)
{
byte oldType = GetTile(x, y, z);
if (blocks == null) return;
if (!InBound(x, y, z)) return;
blocks[PosToInt(x, y, z)] = type;
@ -496,6 +497,15 @@ namespace MCGalaxy
else
bP.deleted = false;
blockCache.Add(bP);
Player.UndoPos Pos;
Pos.x = x;
Pos.y = y;
Pos.z = z;
Pos.mapName = this.name;
Pos.type = oldType;
Pos.newtype = type;
Pos.timePlaced = DateTime.Now;
p.UndoBuffer.Add(Pos);
}
}

View File

@ -374,48 +374,6 @@ namespace MCGalaxy.Levels.Textures
var match = HttpFirstLine.Match(firstLine);
if (match.Success)
{
string worldName = match.Groups[1].Value;
bool firstTime = match.Groups[2].Success;
Level l = Level.Find(worldName);
if (l != null)
{
string cfg = "";
if (cachecfg == "" || update)
{
if (!File.Exists("extra/cfg/" + l.name + ".cfg"))
l.textures.CreateCFG();
cfg = GetCFG();
cachecfg = cfg;
update = false;
}
else
cfg = cachecfg;
byte[] content = Encoding.UTF8.GetBytes(cfg);
textWriter.Write("HTTP/1.1 200 OK");
textWriter.WriteLine("Date: " + DateTime.UtcNow.ToString("R"));
textWriter.WriteLine("Server: Apache/2.2.21 (CentOS)");
textWriter.WriteLine("Last-Modified: " + DateTime.UtcNow.ToString("R"));
textWriter.WriteLine("Accept-Ranges: bytes");
textWriter.WriteLine("Content-Length: " + content.Length);
textWriter.WriteLine("Connection: close");
textWriter.WriteLine("Content-Type: text/plain");
textWriter.WriteLine();
textWriter.WriteLine(cfg);
}
else if (isMusic(worldName, p)) {
byte[] data = getData(worldName);
textWriter.WriteLine("Date: " + DateTime.UtcNow.ToString("R"));
textWriter.WriteLine("Server: Apache/2.2.21 (CentOS)");
textWriter.WriteLine("Last-Modified: " + DateTime.UtcNow.ToString("R"));
textWriter.WriteLine("Accept-Ranges: bytes");
textWriter.WriteLine("Content-Length: " + data.Length);
textWriter.WriteLine("Connection: close");
textWriter.WriteLine("Content-Type: application/octet-stream");
textWriter.WriteLine();
textWriter.WriteLine(data);
}
else
textWriter.WriteLine("HTTP/1.1 404 Not Found");
}
else
textWriter.WriteLine("HTTP/1.1 400 Bad Request");

View File

@ -31,8 +31,9 @@
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>88b3a93f</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
@ -62,6 +63,7 @@
<Prefer32Bit>False</Prefer32Bit>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Galaxy.ico</ApplicationIcon>
@ -80,12 +82,29 @@
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework">
<HintPath>packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>Newtonsoft.Json\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.98.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>packages\System.Data.SQLite.Core.1.0.98.1\lib\net45\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.EF6">
<HintPath>packages\System.Data.SQLite.EF6.1.0.98.1\lib\net45\System.Data.SQLite.EF6.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq">
<HintPath>packages\System.Data.SQLite.Linq.1.0.98.1\lib\net45\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Design" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
@ -103,18 +122,17 @@
<HintPath>MySql.Data.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="System.Data.SQLite">
<HintPath>System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms.Ribbon">
<HintPath>System.Windows.Forms.Ribbon.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Alias.cs" />
<Compile Include="API.cs" />
<Compile Include="AutoSaver.cs" />
<Compile Include="Ban.cs" />
<Compile Include="Block.cs" />
<Compile Include="ChatMessage.cs" />
<Compile Include="Commands\CmdBack.cs" />
<Compile Include="Commands\CmdC4.cs" />
<Compile Include="Commands\CmdEnvironment.cs" />
@ -554,6 +572,8 @@
<Compile Include="VIP.cs" />
<Compile Include="Warp.cs" />
<Compile Include="Games\ZombieGame.cs" />
<Compile Include="WebServer.cs" />
<Compile Include="WhoWas.cs" />
<EmbeddedResource Include="GUI\Eco\EcoLevelWindow.resx">
<DependentUpon>EcoLevelWindow.cs</DependentUpon>
</EmbeddedResource>
@ -667,6 +687,7 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Service References\TranslateService\MCForge.TranslateService.GetTranslationsResponse.datasource">
<DependentUpon>Reference.svcmap</DependentUpon>
</None>
@ -746,4 +767,11 @@
</Properties>
</MonoDevelop>
</ProjectExtensions>
<Import Project="packages\System.Data.SQLite.Core.1.0.98.1\build\net45\System.Data.SQLite.Core.targets" Condition="Exists('packages\System.Data.SQLite.Core.1.0.98.1\build\net45\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\System.Data.SQLite.Core.1.0.98.1\build\net45\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\System.Data.SQLite.Core.1.0.98.1\build\net45\System.Data.SQLite.Core.targets'))" />
</Target>
</Project>

View File

@ -21,12 +21,14 @@ using System.Globalization;
using System.IO;
using System.Linq;
namespace MCGalaxy {
namespace MCGalaxy
{
/// <summary>
/// This is the group object
/// Where ranks and there data are stored
/// </summary>
public sealed class Group {
public sealed class Group
{
public delegate void RankSet(Player p, Group newrank);
[Obsolete("Please use OnPlayerRankSetEvent.Register()")]
public static event RankSet OnPlayerRankSet;
@ -57,7 +59,8 @@ namespace MCGalaxy {
/// <summary>
/// Create a new group object
/// </summary>
public Group() {
public Group()
{
Permission = LevelPermission.Null;
}
@ -71,7 +74,8 @@ namespace MCGalaxy {
/// <param name="newColor">The color of the group (Not including the &)</param>
/// <param name="motd">the custom MOTD for the group</param>
/// <param name="file">The file path where the current players of this group are stored</param>
public Group(LevelPermission Perm, int maxB, long maxUn, string fullName, char newColor, string motd, string file, byte maps = 2) {
public Group(LevelPermission Perm, int maxB, long maxUn, string fullName, char newColor, string motd, string file, byte maps = 2)
{
Permission = Perm;
maxBlocks = maxB;
maxUndo = maxUn;
@ -88,7 +92,8 @@ namespace MCGalaxy {
/// <summary>
/// Fill the commands that this group can use
/// </summary>
public void fillCommands() {
public void fillCommands()
{
CommandList _commands = new CommandList();
GrpCommands.AddCommands(out _commands, Permission);
commands = _commands;
@ -105,29 +110,40 @@ namespace MCGalaxy {
/// <summary>
/// Load up all server groups
/// </summary>
public static void InitAll() {
public static void InitAll()
{
GroupList = new List<Group>();
if (File.Exists("properties/ranks.properties")) {
if (File.Exists("properties/ranks.properties"))
{
string[] lines = File.ReadAllLines("properties/ranks.properties");
Group thisGroup = new Group();
int gots = 0, version = 1;
if (lines.Length > 0 && lines[0].StartsWith("#Version ")) {
try { version = int.Parse(lines[0].Remove(0, 9)); } catch { Server.s.Log("The ranks.properties version header is invalid! Ranks may fail to load!"); }
if (lines.Length > 0 && lines[0].StartsWith("#Version "))
{
try { version = int.Parse(lines[0].Remove(0, 9)); }
catch { Server.s.Log("The ranks.properties version header is invalid! Ranks may fail to load!"); }
}
foreach (string s in lines) {
try {
foreach (string s in lines)
{
try
{
if (s == "" || s[0] == '#') continue;
if (s.Split('=').Length == 2) {
if (s.Split('=').Length == 2)
{
string property = s.Split('=')[0].Trim();
string value = s.Split('=')[1].Trim();
if (thisGroup.name == "" && property.ToLower() != "rankname") {
if (thisGroup.name == "" && property.ToLower() != "rankname")
{
Server.s.Log("Hitting an error at " + s + " of ranks.properties");
} else {
switch (property.ToLower()) {
}
else
{
switch (property.ToLower())
{
case "rankname":
gots = 0;
thisGroup = new Group();
@ -142,35 +158,44 @@ namespace MCGalaxy {
case "permission":
int foundPermission;
try {
try
{
foundPermission = int.Parse(value);
} catch { Server.s.Log("Invalid permission on " + s); break; }
}
catch { Server.s.Log("Invalid permission on " + s); break; }
if (thisGroup.Permission != LevelPermission.Null) {
if (thisGroup.Permission != LevelPermission.Null)
{
Server.s.Log("Setting permission again on " + s);
gots--;
}
bool allowed = GroupList.Find(grp => grp.Permission == (LevelPermission)foundPermission) == null;
if (foundPermission > 119 || foundPermission < -50) {
if (foundPermission > 119 || foundPermission < -50)
{
Server.s.Log("Permission must be between -50 and 119 for ranks");
break;
}
if (allowed) {
if (allowed)
{
gots++;
thisGroup.Permission = (LevelPermission)foundPermission;
} else {
}
else
{
Server.s.Log("Cannot have 2 ranks set at permission level " + value);
}
break;
case "limit":
int foundLimit;
try {
try
{
foundLimit = int.Parse(value);
} catch { Server.s.Log("Invalid limit on " + s); break; }
}
catch { Server.s.Log("Invalid limit on " + s); break; }
gots++;
thisGroup.maxBlocks = foundLimit;
@ -178,9 +203,11 @@ namespace MCGalaxy {
case "maxundo":
int foundMax;
try {
try
{
foundMax = int.Parse(value);
} catch { Server.s.Log("Invalid maximum on " + s); break; }
}
catch { Server.s.Log("Invalid maximum on " + s); break; }
gots++;
thisGroup.maxUndo = foundMax;
@ -188,19 +215,25 @@ namespace MCGalaxy {
case "color":
char foundChar;
try {
try
{
foundChar = char.Parse(value);
} catch { Server.s.Log("Incorrect color on " + s); break; }
}
catch { Server.s.Log("Incorrect color on " + s); break; }
if ((foundChar >= '0' && foundChar <= '9') || (foundChar >= 'a' && foundChar <= 'f')) {
if ((foundChar >= '0' && foundChar <= '9') || (foundChar >= 'a' && foundChar <= 'f'))
{
gots++;
thisGroup.color = foundChar.ToString(CultureInfo.InvariantCulture);
} else {
}
else
{
Server.s.Log("Invalid color code at " + s);
}
break;
case "filename":
if (value.Contains("\\") || value.Contains("/")) {
if (value.Contains("\\") || value.Contains("/"))
{
Server.s.Log("Invalid filename on " + s);
break;
}
@ -215,7 +248,7 @@ namespace MCGalaxy {
break;
case "osmaps":
byte osmaps;
if(byte.TryParse(value, out osmaps) == false)
if (byte.TryParse(value, out osmaps) == false)
{ osmaps = 2; }
gots++;
@ -223,28 +256,33 @@ namespace MCGalaxy {
break;
}
if ((gots >= 4 && version < 2) || (gots >= 5 && version < 3) || gots >= 6) {
if (version < 2) {
if ((gots >= 4 && version < 2) || (gots >= 5 && version < 3) || gots >= 6)
{
if (version < 2)
{
if ((int)thisGroup.Permission >= 100)
thisGroup.maxUndo = int.MaxValue;
else if ((int)thisGroup.Permission >= 80)
thisGroup.maxUndo = 5400;
}
GroupList.Add(new Group(thisGroup.Permission,
thisGroup.maxBlocks,
thisGroup.maxUndo,
thisGroup.trueName,
thisGroup.color[0],
thisGroup.MOTD,
thisGroup.fileName,
GroupList.Add(new Group(thisGroup.Permission,
thisGroup.maxBlocks,
thisGroup.maxUndo,
thisGroup.trueName,
thisGroup.color[0],
thisGroup.MOTD,
thisGroup.fileName,
thisGroup.OverseerMaps));
}
}
} else {
}
else
{
Server.s.Log("In ranks.properties, the line " + s + " is wrongly formatted");
}
} catch (Exception e) { Server.s.Log("Encountered an error at line \"" + s + "\" in ranks.properties"); Server.ErrorLog(e); }
}
catch (Exception e) { Server.s.Log("Encountered an error at line \"" + s + "\" in ranks.properties"); Server.ErrorLog(e); }
}
}
@ -257,10 +295,12 @@ namespace MCGalaxy {
GroupList.Add(new Group(LevelPermission.Nobody, 65536, -1, "Nobody", '0', String.Empty, "nobody.txt"));
bool swap = true; Group storedGroup;
while (swap) {
while (swap)
{
swap = false;
for (int i = 0; i < GroupList.Count - 1; i++)
if (GroupList[i].Permission > GroupList[i + 1].Permission) {
if (GroupList[i].Permission > GroupList[i + 1].Permission)
{
swap = true;
storedGroup = GroupList[i];
GroupList[i] = GroupList[i + 1];
@ -271,7 +311,8 @@ namespace MCGalaxy {
if (Group.Find(Server.defaultRank) != null) standard = Group.Find(Server.defaultRank);
else standard = Group.findPerm(LevelPermission.Guest);
foreach (Player pl in Player.players) {
foreach (Player pl in Player.players)
{
pl.group = GroupList.Find(g => g.name == pl.group.name);
}
if (OnGroupLoad != null)
@ -283,9 +324,11 @@ namespace MCGalaxy {
/// Save givenList group
/// </summary>
/// <param name="givenList">The list of groups to save</param>
public static void saveGroups(List<Group> givenList) {
public static void saveGroups(List<Group> givenList)
{
File.Create("properties/ranks.properties").Dispose();
using (StreamWriter SW = File.CreateText("properties/ranks.properties")) {
using (StreamWriter SW = File.CreateText("properties/ranks.properties"))
{
SW.WriteLine("#Version 3");
SW.WriteLine("#RankName = string");
SW.WriteLine("# The name of the rank, use capitalization.");
@ -319,8 +362,10 @@ namespace MCGalaxy {
SW.WriteLine("# Defaults to 2 if invalid number (number has to be between 0-128");
SW.WriteLine();
SW.WriteLine();
foreach (Group grp in givenList) {
if (grp.name != "nobody") {
foreach (Group grp in givenList)
{
if (grp.name != "nobody")
{
SW.WriteLine("RankName = " + grp.trueName);
SW.WriteLine("Permission = " + (int)grp.Permission);
SW.WriteLine("Limit = " + grp.maxBlocks);
@ -342,7 +387,8 @@ namespace MCGalaxy {
/// </summary>
/// <param name="name">The name of the group to search for</param>
/// <returns>Return true if it does exists, returns false if it doesnt</returns>
public static bool Exists(string name) {
public static bool Exists(string name)
{
name = name.ToLower();
return GroupList.Any(gr => gr.name == name);
}
@ -351,7 +397,8 @@ namespace MCGalaxy {
/// </summary>
/// <param name="name">The name of the group</param>
/// <returns>The group object with that name</returns>
public static Group Find(string name) {
public static Group Find(string name)
{
name = name.ToLower();
if (name == "adv") name = "advbuilder";
@ -366,7 +413,8 @@ namespace MCGalaxy {
/// </summary>
/// <param name="Perm">The level permission to search for</param>
/// <returns>The group object with that level permission</returns>
public static Group findPerm(LevelPermission Perm) {
public static Group findPerm(LevelPermission Perm)
{
return GroupList.FirstOrDefault(grp => grp.Permission == Perm);
}
@ -375,7 +423,8 @@ namespace MCGalaxy {
/// </summary>
/// <param name="Perm">The level permission to search for</param>
/// <returns>The group object with that level permission</returns>
public static Group findPermInt(int Perm) {
public static Group findPermInt(int Perm)
{
return GroupList.FirstOrDefault(grp => (int)grp.Permission == Perm);
}
@ -384,8 +433,10 @@ namespace MCGalaxy {
/// </summary>
/// <param name="playerName">The player Name</param>
/// <returns>The group name</returns>
public static string findPlayer(string playerName) {
foreach (Group grp in Group.GroupList.Where(grp => grp.playerList.Contains(playerName))) {
public static string findPlayer(string playerName)
{
foreach (Group grp in Group.GroupList.Where(grp => grp.playerList.Contains(playerName)))
{
return grp.name;
}
return Group.standard.name;
@ -396,21 +447,29 @@ namespace MCGalaxy {
/// </summary>
/// <param name="playerName">The player name</param>
/// <returns>The group object that the player is in</returns>
public static Group findPlayerGroup(string playerName) {
foreach (Group grp in Group.GroupList.Where(grp => grp.playerList.Contains(playerName))) {
public static Group findPlayerGroup(string playerName)
{
foreach (Group grp in Group.GroupList.Where(grp => grp.playerList.Contains(playerName)))
{
return grp;
}
return Group.standard;
}
public static string concatList(bool includeColor = true, bool skipExtra = false, bool permissions = false) {
public static string concatList(bool includeColor = true, bool skipExtra = false, bool permissions = false)
{
string returnString = "";
foreach (Group grp in Group.GroupList.Where(grp => !skipExtra || (grp.Permission > LevelPermission.Guest && grp.Permission < LevelPermission.Nobody))) {
if (includeColor) {
foreach (Group grp in Group.GroupList.Where(grp => !skipExtra || (grp.Permission > LevelPermission.Guest && grp.Permission < LevelPermission.Nobody)))
{
if (includeColor)
{
returnString += ", " + grp.color + grp.name + Server.DefaultColor;
} else if (permissions) {
}
else if (permissions)
{
returnString += ", " + ((int)grp.Permission).ToString(CultureInfo.InvariantCulture);
} else
}
else
returnString += ", " + grp.name;
}
@ -420,8 +479,10 @@ namespace MCGalaxy {
}
}
public class GrpCommands {
public class rankAllowance {
public class GrpCommands
{
public class rankAllowance
{
public string commandName;
public LevelPermission lowestRank;
public List<LevelPermission> disallow = new List<LevelPermission>();
@ -430,39 +491,46 @@ namespace MCGalaxy {
public static List<rankAllowance> allowedCommands;
public static List<string> foundCommands = new List<string>();
public static LevelPermission defaultRanks(string command) {
public static LevelPermission defaultRanks(string command)
{
Command cmd = Command.all.Find(command);
return cmd != null ? cmd.defaultRank : LevelPermission.Null;
}
public static void fillRanks() {
public static void fillRanks()
{
foundCommands = Command.all.commandNames();
allowedCommands = new List<rankAllowance>();
rankAllowance allowVar;
foreach (Command cmd in Command.all.All()) {
foreach (Command cmd in Command.all.All())
{
allowVar = new rankAllowance();
allowVar.commandName = cmd.name;
allowVar.lowestRank = cmd.defaultRank;
allowedCommands.Add(allowVar);
}
if (File.Exists("properties/command.properties")) {
if (File.Exists("properties/command.properties"))
{
string[] lines = File.ReadAllLines("properties/command.properties");
//if (lines.Length == 0) ; // this is useless?
/*else */
if (lines[0] == "#Version 2") {
if (lines[0] == "#Version 2")
{
string[] colon = new[] { " : " };
foreach (string line in lines) {
foreach (string line in lines)
{
allowVar = new rankAllowance();
if (line == "" || line[0] == '#') continue;
//Name : Lowest : Disallow : Allow
string[] command = line.Split(colon, StringSplitOptions.None);
if (!foundCommands.Contains(command[0])) {
if (!foundCommands.Contains(command[0]))
{
Server.s.Log("Incorrect command name: " + command[0]);
continue;
}
@ -475,41 +543,56 @@ namespace MCGalaxy {
if (command[3] != "")
allow = command[3].Split(',');
try {
try
{
allowVar.lowestRank = (LevelPermission)int.Parse(command[1]);
foreach (string s in disallow) { allowVar.disallow.Add((LevelPermission)int.Parse(s)); }
foreach (string s in allow) { allowVar.allow.Add((LevelPermission)int.Parse(s)); }
} catch {
}
catch
{
Server.s.Log("Hit an error on the command " + line);
continue;
}
int current = 0;
foreach (rankAllowance aV in allowedCommands) {
if (command[0] == aV.commandName) {
foreach (rankAllowance aV in allowedCommands)
{
if (command[0] == aV.commandName)
{
allowedCommands[current] = allowVar;
break;
}
current++;
}
}
} else {
foreach (string line in lines.Where(line => line != "" && line[0] != '#')) {
}
else
{
foreach (string line in lines.Where(line => line != "" && line[0] != '#'))
{
allowVar = new rankAllowance();
string key = line.Split('=')[0].Trim().ToLower();
string value = line.Split('=')[1].Trim().ToLower();
if (!foundCommands.Contains(key)) {
if (!foundCommands.Contains(key))
{
Server.s.Log("Incorrect command name: " + key);
} else if (Level.PermissionFromName(value) == LevelPermission.Null) {
}
else if (Level.PermissionFromName(value) == LevelPermission.Null)
{
Server.s.Log("Incorrect value given for " + key + ", using default value.");
} else {
}
else
{
allowVar.commandName = key;
allowVar.lowestRank = Level.PermissionFromName(value);
int current = 0;
foreach (rankAllowance aV in allowedCommands) {
if (key == aV.commandName) {
foreach (rankAllowance aV in allowedCommands)
{
if (key == aV.commandName)
{
allowedCommands[current] = allowVar;
break;
}
@ -519,17 +602,22 @@ namespace MCGalaxy {
}
}
Save(allowedCommands);
} else Save(allowedCommands);
}
else Save(allowedCommands);
foreach (Group grp in Group.GroupList) {
foreach (Group grp in Group.GroupList)
{
grp.fillCommands();
}
}
public static void Save(List<rankAllowance> givenList) {
try {
public static void Save(List<rankAllowance> givenList)
{
try
{
File.Create("properties/command.properties").Dispose();
using (StreamWriter w = File.CreateText("properties/command.properties")) {
using (StreamWriter w = File.CreateText("properties/command.properties"))
{
w.WriteLine("#Version 2");
w.WriteLine("# This file contains a reference to every command found in the server software");
w.WriteLine("# Use this file to specify which ranks get which commands");
@ -539,28 +627,34 @@ namespace MCGalaxy {
w.WriteLine("# CommandName : LowestRank : Disallow : Allow");
w.WriteLine("# gun : 60 : 80,67 : 40,41,55");
w.WriteLine("");
foreach (rankAllowance aV in givenList) {
foreach (rankAllowance aV in givenList)
{
w.WriteLine(aV.commandName + " : " + (int)aV.lowestRank + " : " + getInts(aV.disallow) + " : " + getInts(aV.allow));
}
}
} catch {
}
catch
{
Server.s.Log("SAVE FAILED! command.properties");
}
}
public static string getInts(List<LevelPermission> givenList) {
public static string getInts(List<LevelPermission> givenList)
{
string returnString = ""; bool foundOne = false;
foreach (LevelPermission Perm in givenList) {
foreach (LevelPermission Perm in givenList)
{
foundOne = true;
returnString += "," + (int)Perm;
}
if (foundOne) returnString = returnString.Remove(0, 1);
return returnString;
}
public static void AddCommands(out CommandList commands, LevelPermission perm) {
public static void AddCommands(out CommandList commands, LevelPermission perm)
{
commands = new CommandList();
foreach (rankAllowance aV in allowedCommands.Where(aV => (aV.lowestRank <= perm && !aV.disallow.Contains(perm)) || aV.allow.Contains(perm)))
commands.Add(Command.all.Find(aV.commandName));
}
}
}
}

View File

@ -1207,7 +1207,9 @@ namespace MCGalaxy {
buffer = null;
}
else
{
Player.SendMessage(p1, joinm);
}
});
}
}
@ -2914,17 +2916,6 @@ return;
}
public void SendMap() {
if (HasExtension("EnvMapAppearance"))
{
if (level.textureUrl == "")
{
SendSetMapAppearance(Server.defaultTextureUrl, level.EdgeBlock, level.HorizonBlock, level.EdgeLevel);
}
else
{
SendSetMapAppearance(level.textureUrl, level.EdgeBlock, level.HorizonBlock, level.EdgeLevel);
}
}
if ( level.blocks == null ) return;
try {
byte[] buffer = new byte[level.blocks.Length + 4];
@ -2986,31 +2977,6 @@ return;
{
SendSetMapWeather(level.weather);
}
}
public void SendSpawn(byte id, string name, ushort x, ushort y, ushort z, byte rotx, byte roty)
{
byte[] buffer = new byte[73]; buffer[0] = id;
StringFormat(name.TrimEnd('+'), 64).CopyTo(buffer, 1);
HTNO(x).CopyTo(buffer, 65);
HTNO(y).CopyTo(buffer, 67);
HTNO(z).CopyTo(buffer, 69);
buffer[71] = rotx; buffer[72] = roty;
SendRaw(7, buffer);
if (HasExtension("ChangeModel"))
{
Player.players.ForEach(p =>
{
if (p.level == this.level)
if (p == this) unchecked { SendChangeModel((byte)-1, model); }
else
{
SendChangeModel(p.id, p.model);
if (p.HasExtension("ChangeModel"))
p.SendChangeModel(this.id, model);
}
});
}
if (HasExtension("EnvSetColor"))
{
SendEnvSetColor(0, -1, -1, -1);
@ -3050,6 +3016,42 @@ return;
}
catch { }
}
if (HasExtension("EnvMapAppearance"))
{
if (level.textureUrl == "")
{
SendSetMapAppearance(Server.defaultTextureUrl, level.EdgeBlock, level.HorizonBlock, level.EdgeLevel);
}
else
{
SendSetMapAppearance(level.textureUrl, level.EdgeBlock, level.HorizonBlock, level.EdgeLevel);
}
}
}
public void SendSpawn(byte id, string name, ushort x, ushort y, ushort z, byte rotx, byte roty)
{
byte[] buffer = new byte[73]; buffer[0] = id;
StringFormat(name.TrimEnd('+'), 64).CopyTo(buffer, 1);
HTNO(x).CopyTo(buffer, 65);
HTNO(y).CopyTo(buffer, 67);
HTNO(z).CopyTo(buffer, 69);
buffer[71] = rotx; buffer[72] = roty;
SendRaw(7, buffer);
if (HasExtension("ChangeModel"))
{
Player.players.ForEach(p =>
{
if (p.level == this.level)
if (p == this) unchecked { SendChangeModel((byte)-1, model); }
else
{
SendChangeModel(p.id, p.model);
if (p.HasExtension("ChangeModel"))
p.SendChangeModel(this.id, model);
}
});
}
}
public void SendPos(byte id, ushort x, ushort y, ushort z, byte rotx, byte roty) {
if ( x < 0 ) x = 32;
@ -3439,7 +3441,15 @@ changed |= 4;*/
return;
}
}
if (Last50Chat.Count() == 50)
Last50Chat.RemoveAt(0);
var chatmessage = new ChatMessage();
chatmessage.text = message;
chatmessage.username = from.color + from.name;
chatmessage.time = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
Last50Chat.Add(chatmessage);
if ( showname ) {
String referee = "";
if ( from.referee ) {
@ -3718,6 +3728,7 @@ changed |= 4;*/
}
});
}
public static List<ChatMessage> Last50Chat = new List<ChatMessage>();
public static void GlobalMessage(string message) {
GlobalMessage(message, false);
}
@ -3960,7 +3971,7 @@ changed |= 4;*/
string leavem = "&c- " + color + prefix + name + Server.DefaultColor + " " + File.ReadAllText("text/logout/" + name + ".txt");
if ((Server.guestLeaveNotify && this.group.Permission <= LevelPermission.Guest) || this.group.Permission > LevelPermission.Guest)
{
Player.players.ForEach(delegate(Player p1)
Player.players.ForEach(delegate(Player p1)
{
if (p1.UsingWom)
{

View File

@ -27,6 +27,7 @@ using System.Threading;
using System.Windows.Forms;
using MCGalaxy.SQL;
using MonoTorrent.Client;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace MCGalaxy
@ -70,7 +71,8 @@ namespace MCGalaxy
public static Thread blockThread;
public static bool IgnoreOmnibans = false;
//public static List<MySql.Data.MySqlClient.MySqlCommand> mySQLCommands = new List<MySql.Data.MySqlClient.MySqlCommand>();
public static WebServer APIServer;
public static WebServer InfoServer;
public static int speedPhysics = 250;
public static Version Version { get { return System.Reflection.Assembly.GetAssembly(typeof(Server)).GetName().Version; } }
@ -903,7 +905,17 @@ namespace MCGalaxy
}
else File.Create("text/messages.txt").Close();
// We always construct this to prevent errors...
try
{
APIServer = new WebServer(SendResponse, "http://localhost:8080/api/");
APIServer.Run();
InfoServer = new WebServer(WhoIsResponse, "http://localhost:8080/whois/");
InfoServer.Run();
}
catch
{
Server.s.Log("Failed to start local API server");
}
IRC = new ForgeBot(Server.ircChannel, Server.ircOpChannel, Server.ircNick, Server.ircServer);
GlobalChat = new GlobalChatBot(GlobalChatNick());
@ -1030,7 +1042,52 @@ namespace MCGalaxy
BlockQueue.Start();
});
}
public static string SendResponse(HttpListenerRequest request)
{
try {
string api = "";
API API = new API();
API.max_players = (int)Server.players;
API.players = Player.players.Select(mc => mc.name).ToArray();
API.chat = Player.Last50Chat.ToArray();
api = JsonConvert.SerializeObject(API, Formatting.Indented);
return api;
}
catch(Exception e)
{
Logger.WriteError(e);
}
return "Error";
}
public static string WhoIsResponse(HttpListenerRequest request)
{
try
{
string p = request.QueryString.Get("name");
if (p == null || p == "")
return "Error";
var whois = new WhoWas(p);
if (whois.rank.Contains("banned"))
whois.banned = true;
else
whois.banned = Ban.Isbanned(p);
string[] bandata;
if (whois.banned)
{
bandata = Ban.Getbandata(p);
whois.banned_by = bandata[0];
whois.ban_reason = bandata[1].Replace("%20", " ");
whois.banned_time = bandata[2].Replace("%20", " ");
}
return JsonConvert.SerializeObject(whois, Formatting.Indented);
}
catch(Exception e)
{
Logger.WriteError(e);
}
return "Error";
}
public static void LoadAllSettings()
{
SrvProperties.Load("properties/server.properties");
@ -1103,7 +1160,8 @@ namespace MCGalaxy
else
Player.Find(p).Kick("Server restarted! Rejoin!");
}
APIServer.Stop();
InfoServer.Stop();
//Player.players.ForEach(delegate(Player p) { p.Kick("Server shutdown. Rejoin in 10 seconds."); });
Player.connections.ForEach(
delegate(Player p)

View File

@ -6,5 +6,5 @@
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="GetTranslationsResponse" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>MCGalaxy.TranslateService.GetTranslationsResponse, Service References.TranslateService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
<TypeInfo>MCGalaxy.TranslateService.GetTranslationsResponse, Service References.TranslateService.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -6,5 +6,5 @@
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="TranslateArrayResponse" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>MCGalaxy.TranslateService.TranslateArrayResponse, Service References.TranslateService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
<TypeInfo>MCGalaxy.TranslateService.TranslateArrayResponse, Service References.TranslateService.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.

View File

@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Starter</RootNamespace>
<AssemblyName>MCGalaxy</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
@ -24,9 +24,10 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
@ -34,6 +35,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Starter.Program</StartupObject>

80
WebServer.cs Normal file
View File

@ -0,0 +1,80 @@
using System;
using System.Net;
using System.Threading;
using System.Linq;
using System.Text;
using System.Net.Mime;
namespace MCGalaxy
{
public class WebServer
{
private readonly HttpListener _listener = new HttpListener();
private readonly Func<HttpListenerRequest, string> _responderMethod;
public WebServer(string[] prefixes, Func<HttpListenerRequest, string> method)
{
if (!HttpListener.IsSupported)
throw new NotSupportedException(
"Needs Windows XP SP2, Server 2003 or later.");
// URI prefixes are required, for example
// "http://localhost:8080/index/".
if (prefixes == null || prefixes.Length == 0)
throw new ArgumentException("prefixes");
// A responder method is required
if (method == null)
throw new ArgumentException("method");
foreach (string s in prefixes)
_listener.Prefixes.Add(s);
_responderMethod = method;
_listener.Start();
}
public WebServer(Func<HttpListenerRequest, string> method, params string[] prefixes)
: this(prefixes, method)
{ }
public void Run()
{
ThreadPool.QueueUserWorkItem((o) =>
{
Console.WriteLine("Webserver running...");
try
{
while (_listener.IsListening)
{
ThreadPool.QueueUserWorkItem((c) =>
{
var ctx = c as HttpListenerContext;
try
{
string rstr = _responderMethod(ctx.Request);
byte[] buf = Encoding.UTF8.GetBytes(rstr);
ctx.Response.ContentType = "application/json";
ctx.Response.ContentLength64 = buf.Length;
ctx.Response.OutputStream.Write(buf, 0, buf.Length);
}
catch { } // suppress any exceptions
finally
{
// always close the stream
ctx.Response.OutputStream.Close();
}
}, _listener.GetContext());
}
}
catch { } // suppress any exceptions
});
}
public void Stop()
{
_listener.Stop();
_listener.Close();
}
}
}

40
WhoWas.cs Normal file
View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using MCGalaxy.SQL;
namespace MCGalaxy
{
public class WhoWas
{
public string rank { get; set; }
public int modified_blocks { get; set; }
public string time { get; set; }
public string first_login { get; set; }
public string last_login { get; set; }
public int total_logins { get; set; }
public bool banned { get; set; }
public string ban_reason { get; set; }
public string banned_by { get; set; }
public string banned_time { get; set; }
public int kicks { get; set; }
public WhoWas(string p)
{
Server.s.Log(p);
rank = Group.findPlayer(p);
Database.AddParams("@Name", p.ToLower());
DataTable playerDb = Database.fillData("SELECT * FROM Players WHERE Name=@Name COLLATE NOCASE");
if (playerDb.Rows.Count == 0)
return;
modified_blocks = int.Parse(playerDb.Rows[0]["totalBlocks"].ToString());
time = playerDb.Rows[0]["TimeSpent"].ToString();
first_login = playerDb.Rows[0]["FirstLogin"].ToString();
last_login = playerDb.Rows[0]["LastLogin"].ToString();
total_logins = int.Parse(playerDb.Rows[0]["totalLogin"].ToString());
kicks = int.Parse(playerDb.Rows[0]["totalKicked"].ToString());
}
}
}

View File

@ -1,19 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_LanguageService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://api.microsofttranslator.com/V2/soap.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_LanguageService" contract="TranslateService.LanguageService" name="BasicHttpBinding_LanguageService"/>
</client>
</system.serviceModel>
</configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_LanguageService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://api.microsofttranslator.com/V2/soap.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_LanguageService" contract="TranslateService.LanguageService" name="BasicHttpBinding_LanguageService" />
</client>
</system.serviceModel>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
</DbProviderFactories>
</system.data>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
</configuration>

8
packages.config Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.0.0" targetFramework="net45" />
<package id="System.Data.SQLite" version="1.0.98.1" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.98.1" targetFramework="net45" />
<package id="System.Data.SQLite.EF6" version="1.0.98.1" targetFramework="net45" />
<package id="System.Data.SQLite.Linq" version="1.0.98.1" targetFramework="net45" />
</packages>

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.