Fixes SQL not working correctly. and saving

This commit is contained in:
Twitchy 2011-07-12 22:47:36 +12:00
parent 6def12b517
commit eda5cfc10d
4 changed files with 20 additions and 30 deletions

View file

@ -74,6 +74,9 @@ namespace TShockAPI.DB
public bool GroupExists(string group)
{
if (group == "superadmin")
return true;
try
{
using (var com = database.CreateCommand())

View file

@ -11,6 +11,7 @@ namespace TShockAPI.DB
public class ItemManager
{
private IDbConnection database;
public List<string> ItemBans = new List<string>();
public ItemManager(IDbConnection db)
{
@ -25,6 +26,16 @@ namespace TShockAPI.DB
com.CommandText =
"CREATE TABLE IF NOT EXISTS ItemBans (ItemName VARCHAR(255) UNIQUE);";
com.ExecuteNonQuery();
com.CommandText = "SELECT *FROM ItemBans";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
ItemBans.Add(reader.Get<string>("ItemName"));
reader.Close();
}
}
}
@ -64,26 +75,9 @@ namespace TShockAPI.DB
public bool ItemIsBanned(string name)
{
try
{
using (var com = database.CreateCommand())
{
com.CommandText = "SELECT *FROM ItemBans WHERE ItemName=@name";
com.AddParameter("@name", name);
using (var reader = com.ExecuteReader())
{
if (reader.Read())
if (reader.Get<string>("ItemName") == name)
return true;
if (ItemBans.Contains(name))
return true;
reader.Close();
}
}
}
catch (Exception ex)
{
Log.Error(ex.ToString());
}
return false;
}
}

View file

@ -158,11 +158,12 @@
</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>"$(ProjectDir)postbuild.bat"</PostBuildEvent>
<PostBuildEvent>copy "$(TargetDir)$(TargetFileName)" "C:\Users\Public\Documents\C3Mod\TShock Testing Environment\ServerPlugins"
"$(ProjectDir)postbuild.bat"</PostBuildEvent>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -106,15 +106,7 @@ namespace TShockAPI
/// </summary>
public static void SaveWorld()
{
try
{
WorldGen.RealsaveWorld();
}
catch
{
WorldGen.saveWorld();
}
WorldGen.saveWorld();
Broadcast("World saved.", Color.Yellow);
Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
}