Refactored the many matches found redundancy by adding a utils method. Changed the csproj to build x86 instead of anycpu which was causing issues for release.
This commit is contained in:
parent
1a1d980186
commit
dea360869b
3 changed files with 42 additions and 67 deletions
|
|
@ -739,19 +739,7 @@ namespace TShockAPI
|
||||||
var players = TShock.Utils.FindPlayer(args.Parameters[0]);
|
var players = TShock.Utils.FindPlayer(args.Parameters[0]);
|
||||||
if (players.Count > 1)
|
if (players.Count > 1)
|
||||||
{
|
{
|
||||||
var plrMatches = "";
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
foreach (TSPlayer plr in players)
|
|
||||||
{
|
|
||||||
if (plrMatches.Length != 0)
|
|
||||||
{
|
|
||||||
plrMatches += ", " + plr.Name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plrMatches += plr.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
args.Player.SendErrorMessage("More than one player matched! Matches: " + plrMatches);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
|
|
@ -785,19 +773,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
{
|
{
|
||||||
var plrMatches = "";
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
foreach (TSPlayer plr in players)
|
|
||||||
{
|
|
||||||
if (plrMatches.Length != 0)
|
|
||||||
{
|
|
||||||
plrMatches += ", " + plr.Name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plrMatches += plr.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
args.Player.SendErrorMessage("More than one player matched! Matches: " + plrMatches);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -960,19 +936,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
{
|
{
|
||||||
var plrMatches = "";
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
foreach (TSPlayer plr in players)
|
|
||||||
{
|
|
||||||
if (plrMatches.Length != 0)
|
|
||||||
{
|
|
||||||
plrMatches += ", " + plr.Name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plrMatches += plr.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
args.Player.SendErrorMessage("More than one player matched! Matches: " + plrMatches);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1142,7 +1106,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if( matchedPlayers.Count > 1 )
|
else if( matchedPlayers.Count > 1 )
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("{0} players matched \"{1}\".", matchedPlayers.Count, playerNameToMatch);
|
TShock.Utils.SendMultipleMatchError(args.Player, matchedPlayers.Select(p => p.Name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1217,8 +1181,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
if (ply.Count > 1)
|
if (ply.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("Found more than one match for {0}.", args.Parameters[0]));
|
TShock.Utils.SendMultipleMatchError(args.Player, ply.Select(p => p.UserAccountName));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!TShock.Groups.GroupExists(args.Parameters[1]))
|
if(!TShock.Groups.GroupExists(args.Parameters[1]))
|
||||||
|
|
@ -1641,7 +1604,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (npcs.Count > 1)
|
else if (npcs.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendMessage(string.Format("More than one ({0}) mob matched!", npcs.Count), Color.Red);
|
TShock.Utils.SendMultipleMatchError(args.Player, npcs.Select(n => n.name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1689,7 +1652,7 @@ namespace TShockAPI
|
||||||
if (players.Count == 0)
|
if (players.Count == 0)
|
||||||
args.Player.SendErrorMessage("Invalid player!");
|
args.Player.SendErrorMessage("Invalid player!");
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
else if (!players[0].TPAllow && !args.Player.Group.HasPermission(Permissions.tpall))
|
else if (!players[0].TPAllow && !args.Player.Group.HasPermission(Permissions.tpall))
|
||||||
{
|
{
|
||||||
var plr = players[0];
|
var plr = players[0];
|
||||||
|
|
@ -1739,7 +1702,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1880,7 +1843,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (foundplr.Count > 1)
|
else if (foundplr.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) player matched!", args.Parameters.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, foundplr.Select(p => p.Name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string warpName = args.Parameters[2];
|
string warpName = args.Parameters[2];
|
||||||
|
|
@ -2206,7 +2169,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (items.Count > 1)
|
else if (items.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) item matched.", items.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, items.Select(i => i.name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2232,7 +2195,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (items.Count > 1)
|
else if (items.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) item matched.", items.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, items.Select(i => i.name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2277,7 +2240,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (items.Count > 1)
|
else if (items.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) item matched.", items.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, items.Select(i => i.name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2303,7 +2266,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (items.Count > 1)
|
else if (items.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) item matched.", items.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, items.Select(i => i.name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2544,7 +2507,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -3304,7 +3267,7 @@ namespace TShockAPI
|
||||||
if (players.Count == 0)
|
if (players.Count == 0)
|
||||||
args.Player.SendErrorMessage("Invalid player!");
|
args.Player.SendErrorMessage("Invalid player!");
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
else if (players[0].Group.HasPermission(Permissions.mute))
|
else if (players[0].Group.HasPermission(Permissions.mute))
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("You cannot mute this player.");
|
args.Player.SendErrorMessage("You cannot mute this player.");
|
||||||
|
|
@ -3351,7 +3314,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
}
|
}
|
||||||
else if (args.Player.mute)
|
else if (args.Player.mute)
|
||||||
args.Player.SendErrorMessage("You are muted.");
|
args.Player.SendErrorMessage("You are muted.");
|
||||||
|
|
@ -3395,7 +3358,7 @@ namespace TShockAPI
|
||||||
if (players.Count == 0)
|
if (players.Count == 0)
|
||||||
args.Player.SendErrorMessage("Invalid player!");
|
args.Player.SendErrorMessage("Invalid player!");
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var ply = players[0];
|
var ply = players[0];
|
||||||
|
|
@ -3459,7 +3422,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -3528,8 +3491,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (matchedItems.Count > 1)
|
else if (matchedItems.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one item matched:");
|
TShock.Utils.SendMultipleMatchError(args.Player, matchedItems.Select(i => i.name));
|
||||||
args.Player.SendErrorMessage(string.Join(", ", matchedItems.Select(i => i.name)));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -3546,10 +3508,10 @@ namespace TShockAPI
|
||||||
if (amountParamIndex != -1 && args.Parameters.Count > amountParamIndex + 1)
|
if (amountParamIndex != -1 && args.Parameters.Count > amountParamIndex + 1)
|
||||||
{
|
{
|
||||||
string prefixidOrName = args.Parameters[amountParamIndex + 1];
|
string prefixidOrName = args.Parameters[amountParamIndex + 1];
|
||||||
List<int> matchedPrefixIds = TShock.Utils.GetPrefixByIdOrName(prefixidOrName);
|
var matchedPrefixIds = TShock.Utils.GetPrefixByIdOrName(prefixidOrName);
|
||||||
if (matchedPrefixIds.Count > 1)
|
if (matchedPrefixIds.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one ({0}) prefixes matched \"{1}\".", matchedPrefixIds.Count, prefixidOrName);
|
TShock.Utils.SendMultipleMatchError(args.Player, matchedPrefixIds.Select(p => p.ToString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (matchedPrefixIds.Count == 0)
|
else if (matchedPrefixIds.Count == 0)
|
||||||
|
|
@ -3624,7 +3586,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (items.Count > 1)
|
else if (items.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) item matched!", items.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, items.Select(i => i.name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -3638,7 +3600,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -3723,7 +3685,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one player matched!");
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -3777,7 +3739,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (found.Count > 1)
|
else if (found.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) buff matched!", found.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, found.Select(f => Main.buffName[f]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
id = found[0];
|
id = found[0];
|
||||||
|
|
@ -3813,7 +3775,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (foundplr.Count > 1)
|
else if (foundplr.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) player matched!", args.Parameters.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, foundplr.Select(p => p.Name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -3828,7 +3790,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (found.Count > 1)
|
else if (found.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) buff matched!", found.Count));
|
TShock.Utils.SendMultipleMatchError(args.Player, found.Select(b => Main.buffName[b]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
id = found[0];
|
id = found[0];
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<DocumentationFile>bin\Release\TShockAPI.XML</DocumentationFile>
|
<DocumentationFile>bin\Release\TShockAPI.XML</DocumentationFile>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="HttpServer">
|
<Reference Include="HttpServer">
|
||||||
|
|
@ -66,7 +67,7 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="TerrariaServer, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
|
<Reference Include="TerrariaServer, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<ExecutableExtension>.exe</ExecutableExtension>
|
<ExecutableExtension>.exe</ExecutableExtension>
|
||||||
<HintPath>..\TerrariaServerBins\TerrariaServer.exe</HintPath>
|
<HintPath>..\TerrariaServerBins\TerrariaServer.exe</HintPath>
|
||||||
|
|
@ -184,7 +185,7 @@
|
||||||
</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.
|
||||||
|
|
|
||||||
|
|
@ -787,6 +787,18 @@ namespace TShockAPI
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the player an error message stating that more than one match was found
|
||||||
|
/// appending a csv list of the matches.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ply">Player to send the message to</param>
|
||||||
|
/// <param name="matches">An enumerable list with the matches</param>
|
||||||
|
public void SendMultipleMatchError(TSPlayer ply, IEnumerable<object> matches)
|
||||||
|
{
|
||||||
|
ply.SendErrorMessage("More than one match found: {0}", string.Join(",", matches));
|
||||||
|
ply.SendErrorMessage("Use \"my query\" for items with spaces");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default hashing algorithm.
|
/// Default hashing algorithm.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue