Fixes SQL not working correctly. and saving
This commit is contained in:
parent
6def12b517
commit
eda5cfc10d
4 changed files with 20 additions and 30 deletions
|
|
@ -74,6 +74,9 @@ namespace TShockAPI.DB
|
||||||
|
|
||||||
public bool GroupExists(string group)
|
public bool GroupExists(string group)
|
||||||
{
|
{
|
||||||
|
if (group == "superadmin")
|
||||||
|
return true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var com = database.CreateCommand())
|
using (var com = database.CreateCommand())
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ namespace TShockAPI.DB
|
||||||
public class ItemManager
|
public class ItemManager
|
||||||
{
|
{
|
||||||
private IDbConnection database;
|
private IDbConnection database;
|
||||||
|
public List<string> ItemBans = new List<string>();
|
||||||
|
|
||||||
public ItemManager(IDbConnection db)
|
public ItemManager(IDbConnection db)
|
||||||
{
|
{
|
||||||
|
|
@ -25,6 +26,16 @@ namespace TShockAPI.DB
|
||||||
com.CommandText =
|
com.CommandText =
|
||||||
"CREATE TABLE IF NOT EXISTS ItemBans (ItemName VARCHAR(255) UNIQUE);";
|
"CREATE TABLE IF NOT EXISTS ItemBans (ItemName VARCHAR(255) UNIQUE);";
|
||||||
com.ExecuteNonQuery();
|
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)
|
public bool ItemIsBanned(string name)
|
||||||
{
|
{
|
||||||
try
|
if (ItemBans.Contains(name))
|
||||||
{
|
|
||||||
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;
|
return true;
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex.ToString());
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,11 +158,12 @@
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<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>
|
</PropertyGroup>
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<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>
|
</VisualStudio>
|
||||||
</ProjectExtensions>
|
</ProjectExtensions>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|
|
||||||
|
|
@ -105,16 +105,8 @@ namespace TShockAPI
|
||||||
/// Saves the map data
|
/// Saves the map data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SaveWorld()
|
public static void SaveWorld()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
WorldGen.RealsaveWorld();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
{
|
||||||
WorldGen.saveWorld();
|
WorldGen.saveWorld();
|
||||||
}
|
|
||||||
|
|
||||||
Broadcast("World saved.", Color.Yellow);
|
Broadcast("World saved.", Color.Yellow);
|
||||||
Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
|
Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue