initial unit testing work and a few tweaks to stuff relating to items
This commit is contained in:
parent
727ae2322b
commit
ffd0471326
4 changed files with 49 additions and 12 deletions
|
|
@ -1945,9 +1945,12 @@ namespace TShockAPI
|
||||||
args.Player.SendMessage("Missing item name/id", Color.Red);
|
args.Player.SendMessage("Missing item name/id", Color.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int itemAmount = 0;
|
|
||||||
int.TryParse( args.Parameters[args.Parameters.Count - 1 ], out itemAmount );
|
|
||||||
var items = Tools.GetItemByIdOrName(args.Parameters[0]);
|
var items = Tools.GetItemByIdOrName(args.Parameters[0]);
|
||||||
|
args.Parameters.RemoveAt(0);
|
||||||
|
int itemAmount = 0;
|
||||||
|
if( args.Parameters.Count > 0 )
|
||||||
|
int.TryParse( args.Parameters[0], out itemAmount );
|
||||||
|
|
||||||
if (items.Count == 0)
|
if (items.Count == 0)
|
||||||
{
|
{
|
||||||
args.Player.SendMessage("Invalid item type!", Color.Red);
|
args.Player.SendMessage("Invalid item type!", Color.Red);
|
||||||
|
|
@ -1998,8 +2001,13 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int itemAmount = 0;
|
int itemAmount = 0;
|
||||||
int.TryParse(args.Parameters[args.Parameters.Count - 1], out itemAmount);
|
|
||||||
var items = Tools.GetItemByIdOrName(args.Parameters[0]);
|
var items = Tools.GetItemByIdOrName(args.Parameters[0]);
|
||||||
|
args.Parameters.RemoveAt(0);
|
||||||
|
string plStr = args.Parameters[0];
|
||||||
|
args.Parameters.RemoveAt(0);
|
||||||
|
if( args.Parameters.Count > 0 )
|
||||||
|
int.TryParse(args.Parameters[args.Parameters.Count - 1], out itemAmount);
|
||||||
|
|
||||||
|
|
||||||
if (items.Count == 0)
|
if (items.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -2014,7 +2022,6 @@ namespace TShockAPI
|
||||||
var item = items[0];
|
var item = items[0];
|
||||||
if (item.type >= 1 && item.type < Main.maxItemTypes)
|
if (item.type >= 1 && item.type < Main.maxItemTypes)
|
||||||
{
|
{
|
||||||
string plStr = args.Parameters[1];
|
|
||||||
var players = Tools.FindPlayer(plStr);
|
var players = Tools.FindPlayer(plStr);
|
||||||
if (players.Count == 0)
|
if (players.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ namespace TShockAPI.DB
|
||||||
String line;
|
String line;
|
||||||
while ((line = sr.ReadLine()) != null)
|
while ((line = sr.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
if (!line.Equals("") && !line.Substring( 0, 1 ).Equals("#") )
|
if (!line.Equals("") && !line.Substring(0, 1).Equals("#"))
|
||||||
{
|
{
|
||||||
if (TShock.Config.StorageType.ToLower() == "sqlite")
|
if (TShock.Config.StorageType.ToLower() == "sqlite")
|
||||||
com.CommandText = "INSERT OR IGNORE INTO 'ItemBans' (ItemName) VALUES (@name);";
|
com.CommandText = "INSERT OR IGNORE INTO 'ItemBans' (ItemName) VALUES (@name);";
|
||||||
|
|
@ -44,8 +44,8 @@ namespace TShockAPI.DB
|
||||||
com.CommandText = "INSERT IGNORE INTO ItemBans SET ItemName=@name;";
|
com.CommandText = "INSERT IGNORE INTO ItemBans SET ItemName=@name;";
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
int.TryParse(line, out id );
|
int.TryParse(line, out id);
|
||||||
com.AddParameter("@name", Tools.GetItemById( id ).name );
|
com.AddParameter("@name", Tools.GetItemById(id).name);
|
||||||
com.ExecuteNonQuery();
|
com.ExecuteNonQuery();
|
||||||
com.Parameters.Clear();
|
com.Parameters.Clear();
|
||||||
}
|
}
|
||||||
|
|
@ -60,19 +60,25 @@ namespace TShockAPI.DB
|
||||||
File.Delete(file2);
|
File.Delete(file2);
|
||||||
File.Move(file, file2);
|
File.Move(file, file2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateItemBans();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateItemBans()
|
||||||
|
{
|
||||||
|
ItemBans.Clear();
|
||||||
|
using (var com = database.CreateCommand())
|
||||||
|
{
|
||||||
com.CommandText = "SELECT * FROM ItemBans";
|
com.CommandText = "SELECT * FROM ItemBans";
|
||||||
|
|
||||||
using (var reader = com.ExecuteReader())
|
using (var reader = com.ExecuteReader())
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader!=null&&reader.Read())
|
||||||
ItemBans.Add(reader.Get<string>("ItemName"));
|
ItemBans.Add(reader.Get<string>("ItemName"));
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddNewBan(string itemname = "")
|
public void AddNewBan(string itemname = "")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -82,6 +88,7 @@ namespace TShockAPI.DB
|
||||||
com.CommandText = "INSERT INTO ItemBans (ItemName) VALUES (@itemname);";
|
com.CommandText = "INSERT INTO ItemBans (ItemName) VALUES (@itemname);";
|
||||||
com.AddParameter("@itemname", Tools.GetItemByName(itemname)[0].name);
|
com.AddParameter("@itemname", Tools.GetItemByName(itemname)[0].name);
|
||||||
com.ExecuteNonQuery();
|
com.ExecuteNonQuery();
|
||||||
|
ItemBans.Add(itemname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -99,6 +106,7 @@ namespace TShockAPI.DB
|
||||||
com.CommandText = "DELETE FROM ItemBans WHERE ItemName=@itemname;";
|
com.CommandText = "DELETE FROM ItemBans WHERE ItemName=@itemname;";
|
||||||
com.AddParameter("@itemname", Tools.GetItemByName(itemname)[0].name);
|
com.AddParameter("@itemname", Tools.GetItemByName(itemname)[0].name);
|
||||||
com.ExecuteNonQuery();
|
com.ExecuteNonQuery();
|
||||||
|
ItemBans.Remove(itemname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<VisualStudio>
|
||||||
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
|
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
|
||||||
</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.
|
||||||
|
|
|
||||||
22
Terraria.sln
22
Terraria.sln
|
|
@ -3,7 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
# Visual Studio 2010
|
# Visual Studio 2010
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockAPI", "TShockAPI\TShockAPI.csproj", "{49606449-072B-4CF5-8088-AA49DA586694}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockAPI", "TShockAPI\TShockAPI.csproj", "{49606449-072B-4CF5-8088-AA49DA586694}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{F3742F51-D7BF-4754-A68A-CD944D2A21FF}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{755F5B05-0924-47E9-9563-26EB20FE3F67}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
Local.testsettings = Local.testsettings
|
||||||
|
Terraria.vsmdi = Terraria.vsmdi
|
||||||
|
TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||||
|
CategoryFile = Terraria.vsmdi
|
||||||
|
EndGlobalSection
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||||
|
|
@ -23,6 +35,16 @@ Global
|
||||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.ActiveCfg = Release|Any CPU
|
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue