resolve some warnings

This commit is contained in:
xuyuwtu 2026-01-29 15:16:53 +08:00
parent 75c8a8ced4
commit 4671a6d7f7
23 changed files with 156 additions and 161 deletions

View file

@ -458,7 +458,7 @@ namespace TShockAPI
} }
args.Player.RequestedSection = true; args.Player.RequestedSection = true;
if (String.IsNullOrEmpty(args.Player.Name)) if (string.IsNullOrEmpty(args.Player.Name))
{ {
TShock.Log.ConsoleDebug(GetString("Bouncer / OnGetSection rejected empty player name.")); TShock.Log.ConsoleDebug(GetString("Bouncer / OnGetSection rejected empty player name."));
args.Player.Kick(GetString("Your client sent a blank character name."), true, true); args.Player.Kick(GetString("Your client sent a blank character name."), true, true);
@ -484,7 +484,7 @@ namespace TShockAPI
var pos = args.Position; var pos = args.Position;
var vel = args.Velocity; var vel = args.Velocity;
if (Single.IsInfinity(vel.X) || Single.IsInfinity(vel.Y)) if (float.IsInfinity(vel.X) || float.IsInfinity(vel.Y))
{ {
TShock.Log.ConsoleInfo(GetString("Bouncer / OnPlayerUpdate force kicked (attempted to set velocity to infinity) from {0}", args.Player.Name)); TShock.Log.ConsoleInfo(GetString("Bouncer / OnPlayerUpdate force kicked (attempted to set velocity to infinity) from {0}", args.Player.Name));
args.Player.Kick(GetString("Detected DOOM set to ON position."), true, true); args.Player.Kick(GetString("Detected DOOM set to ON position."), true, true);
@ -492,7 +492,7 @@ namespace TShockAPI
return; return;
} }
if (Single.IsNaN(vel.X) || Single.IsNaN(vel.Y)) if (float.IsNaN(vel.X) || float.IsNaN(vel.Y))
{ {
TShock.Log.ConsoleInfo(GetString("Bouncer / OnPlayerUpdate force kicked (attempted to set velocity to NaN) from {0}", args.Player.Name)); TShock.Log.ConsoleInfo(GetString("Bouncer / OnPlayerUpdate force kicked (attempted to set velocity to NaN) from {0}", args.Player.Name));
args.Player.Kick(GetString("Detected DOOM set to ON position."), true, true); args.Player.Kick(GetString("Detected DOOM set to ON position."), true, true);
@ -797,17 +797,17 @@ namespace TShockAPI
return; return;
} }
/// Handle placement action if the player is using an Ice Rod but not placing the iceblock. // Handle placement action if the player is using an Ice Rod but not placing the iceblock.
if (selectedItem.type == ItemID.IceRod && editData != TileID.MagicalIceBlock) if (selectedItem.type == ItemID.IceRod && editData != TileID.MagicalIceBlock)
{ {
TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from using ice rod but not placing ice block {0} {1} {2}", args.Player.Name, action, editData)); TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from using ice rod but not placing ice block {0} {1} {2}", args.Player.Name, action, editData));
args.Player.SendTileSquareCentered(tileX, tileY, 4); args.Player.SendTileSquareCentered(tileX, tileY, 4);
args.Handled = true; args.Handled = true;
} }
/// If they aren't selecting the item which creates the tile, they're hacking. // If they aren't selecting the item which creates the tile, they're hacking.
if ((action == EditAction.PlaceTile || action == EditAction.ReplaceTile) && editData != selectedItem.createTile) if ((action == EditAction.PlaceTile || action == EditAction.ReplaceTile) && editData != selectedItem.createTile)
{ {
/// These would get caught up in the below check because Terraria does not set their createTile field. // These would get caught up in the below check because Terraria does not set their createTile field.
if (selectedItem.type != ItemID.IceRod && selectedItem.type != ItemID.DirtBomb && selectedItem.type != ItemID.StickyBomb && (args.Player.TPlayer.mount.Type != MountID.DiggingMoleMinecart || editData != TileID.MinecartTrack)) if (selectedItem.type != ItemID.IceRod && selectedItem.type != ItemID.DirtBomb && selectedItem.type != ItemID.StickyBomb && (args.Player.TPlayer.mount.Type != MountID.DiggingMoleMinecart || editData != TileID.MinecartTrack))
{ {
TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from tile placement not matching selected item createTile {0} {1} {2} selectedItemID:{3} createTile:{4}", args.Player.Name, action, editData, selectedItem.type, selectedItem.createTile)); TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from tile placement not matching selected item createTile {0} {1} {2} selectedItemID:{3} createTile:{4}", args.Player.Name, action, editData, selectedItem.type, selectedItem.createTile));
@ -816,7 +816,7 @@ namespace TShockAPI
return; return;
} }
} }
/// If they aren't selecting the item which creates the wall, they're hacking. // If they aren't selecting the item which creates the wall, they're hacking.
if ((action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && editData != selectedItem.createWall) if ((action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && editData != selectedItem.createWall)
{ {
TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from wall placement not matching selected item createWall {0} {1} {2} selectedItemID:{3} createWall:{4}", args.Player.Name, action, editData, selectedItem.type, selectedItem.createWall)); TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from wall placement not matching selected item createWall {0} {1} {2} selectedItemID:{3} createWall:{4}", args.Player.Name, action, editData, selectedItem.type, selectedItem.createWall));
@ -1263,7 +1263,7 @@ namespace TShockAPI
return; return;
} }
/// If the projectile is a directional projectile, check if the player is holding their respected item to validate the projectile creation. // If the projectile is a directional projectile, check if the player is holding their respected item to validate the projectile creation.
if (directionalProjectiles.ContainsKey(type)) if (directionalProjectiles.ContainsKey(type))
{ {
if (directionalProjectiles[type] == args.Player.TPlayer.HeldItem.type) if (directionalProjectiles[type] == args.Player.TPlayer.HeldItem.type)
@ -1273,14 +1273,14 @@ namespace TShockAPI
} }
} }
/// If the created projectile is a golf club, check if the player is holding one of the golf club items to validate the projectile creation. // If the created projectile is a golf club, check if the player is holding one of the golf club items to validate the projectile creation.
if (type == ProjectileID.GolfClubHelper && Handlers.LandGolfBallInCupHandler.GolfClubItemIDs.Contains(args.Player.TPlayer.HeldItem.type)) if (type == ProjectileID.GolfClubHelper && Handlers.LandGolfBallInCupHandler.GolfClubItemIDs.Contains(args.Player.TPlayer.HeldItem.type))
{ {
args.Handled = false; args.Handled = false;
return; return;
} }
/// If the created projectile is a golf ball and the player is not holding a golf club item and neither a golf ball item and neither they have had a golf club projectile created recently. // If the created projectile is a golf ball and the player is not holding a golf club item and neither a golf ball item and neither they have had a golf club projectile created recently.
if (Handlers.LandGolfBallInCupHandler.GolfBallProjectileIDs.Contains(type) && if (Handlers.LandGolfBallInCupHandler.GolfBallProjectileIDs.Contains(type) &&
!Handlers.LandGolfBallInCupHandler.GolfClubItemIDs.Contains(args.Player.TPlayer.HeldItem.type) && !Handlers.LandGolfBallInCupHandler.GolfClubItemIDs.Contains(args.Player.TPlayer.HeldItem.type) &&
!Handlers.LandGolfBallInCupHandler.GolfBallItemIDs.Contains(args.Player.TPlayer.HeldItem.type) && !Handlers.LandGolfBallInCupHandler.GolfBallItemIDs.Contains(args.Player.TPlayer.HeldItem.type) &&
@ -2820,7 +2820,7 @@ namespace TShockAPI
/// <param name="args"></param> /// <param name="args"></param>
internal void OnFishOutNPC(object sender, GetDataHandlers.FishOutNPCEventArgs args) internal void OnFishOutNPC(object sender, GetDataHandlers.FishOutNPCEventArgs args)
{ {
/// Getting recent projectiles of the player and selecting the first that is a bobber. // Getting recent projectiles of the player and selecting the first that is a bobber.
var projectile = args.Player.RecentlyCreatedProjectiles.FirstOrDefault(p => Main.projectile[p.Index].bobber); var projectile = args.Player.RecentlyCreatedProjectiles.FirstOrDefault(p => Main.projectile[p.Index].bobber);
if (!FishingRodItemIDs.Contains(args.Player.SelectedItem.type)) if (!FishingRodItemIDs.Contains(args.Player.SelectedItem.type))
@ -2829,7 +2829,7 @@ namespace TShockAPI
args.Handled = true; args.Handled = true;
return; return;
} }
if (projectile.Type == 0 || projectile.Killed) /// The bobber projectile is never killed when the NPC spawns. Type can only be 0 if no recent projectile is found that is named Bobber. if (projectile.Type == 0 || projectile.Killed) // The bobber projectile is never killed when the NPC spawns. Type can only be 0 if no recent projectile is found that is named Bobber.
{ {
TShock.Log.ConsoleDebug(GetString("Bouncer / OnFishOutNPC rejected for not finding active bobber projectile! - From {0}", args.Player.Name)); TShock.Log.ConsoleDebug(GetString("Bouncer / OnFishOutNPC rejected for not finding active bobber projectile! - From {0}", args.Player.Name));
args.Handled = true; args.Handled = true;
@ -3062,7 +3062,7 @@ namespace TShockAPI
/// </summary> /// </summary>
private static Dictionary<int, int> directionalProjectiles = new Dictionary<int, int>() private static Dictionary<int, int> directionalProjectiles = new Dictionary<int, int>()
{ {
///Spears //Spears
{ ProjectileID.DarkLance, ItemID.DarkLance}, { ProjectileID.DarkLance, ItemID.DarkLance},
{ ProjectileID.Trident, ItemID.Trident}, { ProjectileID.Trident, ItemID.Trident},
{ ProjectileID.Spear, ItemID.Spear}, { ProjectileID.Spear, ItemID.Spear},
@ -3082,7 +3082,7 @@ namespace TShockAPI
{ ProjectileID.MonkStaffT2, ItemID.MonkStaffT2}, { ProjectileID.MonkStaffT2, ItemID.MonkStaffT2},
{ ProjectileID.ThunderSpear, ItemID.ThunderSpear}, { ProjectileID.ThunderSpear, ItemID.ThunderSpear},
{ ProjectileID.GladiusStab, ItemID.Gladius}, { ProjectileID.GladiusStab, ItemID.Gladius},
/// ShortSwords // ShortSwords
{ ProjectileID.RulerStab, ItemID.Ruler }, { ProjectileID.RulerStab, ItemID.Ruler },
{ ProjectileID.CopperShortswordStab, ItemID.CopperShortsword }, { ProjectileID.CopperShortswordStab, ItemID.CopperShortsword },
{ ProjectileID.TinShortswordStab, ItemID.TinShortsword }, { ProjectileID.TinShortswordStab, ItemID.TinShortsword },

View file

@ -740,7 +740,7 @@ namespace TShockAPI
/// </summary> /// </summary>
/// <param name="str"></param> /// <param name="str"></param>
/// <returns></returns> /// <returns></returns>
private static List<String> ParseParameters(string str) private static List<string> ParseParameters(string str)
{ {
var ret = new List<string>(); var ret = new List<string>();
var sb = new StringBuilder(); var sb = new StringBuilder();
@ -857,7 +857,7 @@ namespace TShockAPI
} }
else if (args.Parameters.Count == 2 && TShock.Config.Settings.AllowLoginAnyUsername) else if (args.Parameters.Count == 2 && TShock.Config.Settings.AllowLoginAnyUsername)
{ {
if (String.IsNullOrEmpty(args.Parameters[0])) if (string.IsNullOrEmpty(args.Parameters[0]))
{ {
args.Player.SendErrorMessage(GetString("Bad login attempt.")); args.Player.SendErrorMessage(GetString("Bad login attempt."));
return; return;
@ -890,7 +890,7 @@ namespace TShockAPI
} }
else if (account.VerifyPassword(password) || else if (account.VerifyPassword(password) ||
(usingUUID && account.UUID == args.Player.UUID && !TShock.Config.Settings.DisableUUIDLogin && (usingUUID && account.UUID == args.Player.UUID && !TShock.Config.Settings.DisableUUIDLogin &&
!String.IsNullOrWhiteSpace(args.Player.UUID))) !string.IsNullOrWhiteSpace(args.Player.UUID)))
{ {
var group = TShock.Groups.GetGroupByName(account.Group); var group = TShock.Groups.GetGroupByName(account.Group);
@ -1300,14 +1300,14 @@ namespace TShockAPI
return; return;
} }
string username = String.Join(" ", args.Parameters); string username = string.Join(" ", args.Parameters);
if (!string.IsNullOrWhiteSpace(username)) if (!string.IsNullOrWhiteSpace(username))
{ {
var account = TShock.UserAccounts.GetUserAccountByName(username); var account = TShock.UserAccounts.GetUserAccountByName(username);
if (account != null) if (account != null)
{ {
DateTime LastSeen; DateTime LastSeen;
string Timezone = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours.ToString("+#;-#"); string Timezone = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).Hours.ToString("+#;-#");
if (DateTime.TryParse(account.LastAccessed, out LastSeen)) if (DateTime.TryParse(account.LastAccessed, out LastSeen))
{ {
@ -1359,7 +1359,7 @@ namespace TShockAPI
else else
{ {
string reason = args.Parameters.Count > 1 string reason = args.Parameters.Count > 1
? String.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1)) ? string.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1))
: GetString("Misbehaviour."); : GetString("Misbehaviour.");
if (!players[0].Kick(reason, !args.Player.RealPlayer, false, args.Player.Name)) if (!players[0].Kick(reason, !args.Player.RealPlayer, false, args.Player.Name))
{ {
@ -2066,13 +2066,13 @@ namespace TShockAPI
} }
} }
string reason = ((args.Parameters.Count > 0) ? GetString("Server shutting down: ") + String.Join(" ", args.Parameters) : GetString("Server shutting down!")); string reason = ((args.Parameters.Count > 0) ? GetString("Server shutting down: ") + string.Join(" ", args.Parameters) : GetString("Server shutting down!"));
TShock.Utils.StopServer(true, reason); TShock.Utils.StopServer(true, reason);
} }
private static void OffNoSave(CommandArgs args) private static void OffNoSave(CommandArgs args)
{ {
string reason = ((args.Parameters.Count > 0) ? GetString("Server shutting down: ") + String.Join(" ", args.Parameters) : GetString("Server shutting down.")); string reason = ((args.Parameters.Count > 0) ? GetString("Server shutting down: ") + string.Join(" ", args.Parameters) : GetString("Server shutting down."));
Netplay.SaveOnServerExit = false; Netplay.SaveOnServerExit = false;
TShock.Utils.StopServer(false, reason); TShock.Utils.StopServer(false, reason);
} }
@ -2082,7 +2082,7 @@ namespace TShockAPI
args.Player.SendInfoMessage(GetString("An update check has been queued. If an update is available, you will be notified shortly.")); args.Player.SendInfoMessage(GetString("An update check has been queued. If an update is available, you will be notified shortly."));
try try
{ {
TShock.UpdateManager.UpdateCheckAsync(null); _ = TShock.UpdateManager.UpdateCheckAsync(null);
} }
catch (Exception) catch (Exception)
{ {
@ -2174,8 +2174,8 @@ namespace TShockAPI
if (args.Parameters.Count < 1) if (args.Parameters.Count < 1)
{ {
args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}worldevent <event type>.", Specifier)); args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}worldevent <event type>.", Specifier));
args.Player.SendErrorMessage(GetString("Valid event types: {0}.", String.Join(", ", _validEvents))); args.Player.SendErrorMessage(GetString("Valid event types: {0}.", string.Join(", ", _validEvents)));
args.Player.SendErrorMessage(GetString("Valid invasion types if spawning an invasion: {0}.", String.Join(", ", _validInvasions))); args.Player.SendErrorMessage(GetString("Valid invasion types if spawning an invasion: {0}.", string.Join(", ", _validInvasions)));
return; return;
} }
@ -2267,7 +2267,7 @@ namespace TShockAPI
return; return;
default: default:
args.Player.SendErrorMessage(GetString("Invalid event type. Valid event types: {0}.", String.Join(", ", _validEvents))); args.Player.SendErrorMessage(GetString("Invalid event type. Valid event types: {0}.", string.Join(", ", _validEvents)));
return; return;
} }
} }
@ -2360,7 +2360,7 @@ namespace TShockAPI
if (args.Parameters.Count < 2) if (args.Parameters.Count < 2)
{ {
args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}worldevent invasion [invasion type] [invasion wave].", Specifier)); args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}worldevent invasion [invasion type] [invasion wave].", Specifier));
args.Player.SendErrorMessage(GetString("Valid invasion types: {0}.", String.Join(", ", _validInvasions))); args.Player.SendErrorMessage(GetString("Valid invasion types: {0}.", string.Join(", ", _validInvasions)));
return; return;
} }
@ -2428,7 +2428,7 @@ namespace TShockAPI
break; break;
default: default:
args.Player.SendErrorMessage(GetString("Invalid invasion type. Valid invasion types: {0}.", String.Join(", ", _validInvasions))); args.Player.SendErrorMessage(GetString("Invalid invasion type. Valid invasion types: {0}.", string.Join(", ", _validInvasions)));
break; break;
} }
} }
@ -2576,7 +2576,7 @@ namespace TShockAPI
if (args.Parameters.Count < 1) if (args.Parameters.Count < 1)
{ {
args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}worldmode <mode>.", Specifier)); args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}worldmode <mode>.", Specifier));
args.Player.SendErrorMessage(GetString("Valid world modes: {0}", String.Join(", ", _worldModes.Keys))); args.Player.SendErrorMessage(GetString("Valid world modes: {0}", string.Join(", ", _worldModes.Keys)));
return; return;
} }
@ -2586,7 +2586,7 @@ namespace TShockAPI
{ {
if (mode < 0 || mode > 3) if (mode < 0 || mode > 3)
{ {
args.Player.SendErrorMessage(GetString("Invalid world mode. Valid world modes: {0}", String.Join(", ", _worldModes.Keys))); args.Player.SendErrorMessage(GetString("Invalid world mode. Valid world modes: {0}", string.Join(", ", _worldModes.Keys)));
return; return;
} }
} }
@ -2596,7 +2596,7 @@ namespace TShockAPI
} }
else else
{ {
args.Player.SendErrorMessage(GetString("Invalid mode world mode. Valid modes: {0}", String.Join(", ", _worldModes.Keys))); args.Player.SendErrorMessage(GetString("Invalid mode world mode. Valid modes: {0}", string.Join(", ", _worldModes.Keys)));
return; return;
} }
@ -3089,7 +3089,7 @@ namespace TShockAPI
return; return;
} }
string playerName = String.Join(" ", args.Parameters); string playerName = string.Join(" ", args.Parameters);
var players = TSPlayer.FindByNameOrID(playerName); var players = TSPlayer.FindByNameOrID(playerName);
if (players.Count == 0) if (players.Count == 0)
{ {
@ -3172,7 +3172,7 @@ namespace TShockAPI
var player = args.Player.Name; var player = args.Player.Name;
if (args.Parameters.Count > 0) if (args.Parameters.Count > 0)
{ {
player = String.Join(" ", args.Parameters); player = string.Join(" ", args.Parameters);
} }
var players = TSPlayer.FindByNameOrID(player); var players = TSPlayer.FindByNameOrID(player);
@ -3308,7 +3308,7 @@ namespace TShockAPI
{ {
string warpName = args.Parameters[1]; string warpName = args.Parameters[1];
bool state = false; bool state = false;
if (Boolean.TryParse(args.Parameters[2], out state)) if (bool.TryParse(args.Parameters[2], out state))
{ {
if (TShock.Warps.Hide(args.Parameters[1], state)) if (TShock.Warps.Hide(args.Parameters[1], state))
{ {
@ -3367,7 +3367,7 @@ namespace TShockAPI
} }
else else
{ {
string warpName = String.Join(" ", args.Parameters); string warpName = string.Join(" ", args.Parameters);
var warp = TShock.Warps.Find(warpName); var warp = TShock.Warps.Find(warpName);
if (warp != null) if (warp != null)
{ {
@ -3402,7 +3402,7 @@ namespace TShockAPI
string groupName = args.Parameters[1]; string groupName = args.Parameters[1];
args.Parameters.RemoveRange(0, 2); args.Parameters.RemoveRange(0, 2);
string permissions = String.Join(",", args.Parameters); string permissions = string.Join(",", args.Parameters);
try try
{ {
@ -3649,7 +3649,7 @@ namespace TShockAPI
{ {
string newColor = args.Parameters[2]; string newColor = args.Parameters[2];
String[] parts = newColor.Split(','); string[] parts = newColor.Split(',');
byte r; byte r;
byte g; byte g;
byte b; byte b;
@ -4061,7 +4061,7 @@ namespace TShockAPI
return; return;
} }
short id; short id;
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count) if (short.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count)
{ {
TShock.ProjectileBans.AddNewBan(id); TShock.ProjectileBans.AddNewBan(id);
args.Player.SendSuccessMessage(GetString("Banned projectile {0}.", id)); args.Player.SendSuccessMessage(GetString("Banned projectile {0}.", id));
@ -4081,7 +4081,7 @@ namespace TShockAPI
} }
short id; short id;
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count) if (short.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count)
{ {
if (!TShock.Groups.GroupExists(args.Parameters[2])) if (!TShock.Groups.GroupExists(args.Parameters[2]))
{ {
@ -4118,7 +4118,7 @@ namespace TShockAPI
} }
short id; short id;
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count) if (short.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count)
{ {
TShock.ProjectileBans.RemoveBan(id); TShock.ProjectileBans.RemoveBan(id);
args.Player.SendSuccessMessage(GetString("Unbanned projectile {0}.", id)); args.Player.SendSuccessMessage(GetString("Unbanned projectile {0}.", id));
@ -4139,7 +4139,7 @@ namespace TShockAPI
} }
short id; short id;
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count) if (short.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count)
{ {
if (!TShock.Groups.GroupExists(args.Parameters[2])) if (!TShock.Groups.GroupExists(args.Parameters[2]))
{ {
@ -4199,7 +4199,7 @@ namespace TShockAPI
int pageNumber; int pageNumber;
if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out pageNumber)) if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out pageNumber))
return; return;
IEnumerable<Int16> projectileIds = from projectileBan in TShock.ProjectileBans.ProjectileBans IEnumerable<short> projectileIds = from projectileBan in TShock.ProjectileBans.ProjectileBans
select projectileBan.ID; select projectileBan.ID;
PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(projectileIds), PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(projectileIds),
new PaginationTools.Settings new PaginationTools.Settings
@ -4237,7 +4237,7 @@ namespace TShockAPI
return; return;
} }
short id; short id;
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count) if (short.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count)
{ {
TShock.TileBans.AddNewBan(id); TShock.TileBans.AddNewBan(id);
args.Player.SendSuccessMessage(GetString("Banned tile {0}.", id)); args.Player.SendSuccessMessage(GetString("Banned tile {0}.", id));
@ -4257,7 +4257,7 @@ namespace TShockAPI
} }
short id; short id;
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count) if (short.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count)
{ {
if (!TShock.Groups.GroupExists(args.Parameters[2])) if (!TShock.Groups.GroupExists(args.Parameters[2]))
{ {
@ -4294,7 +4294,7 @@ namespace TShockAPI
} }
short id; short id;
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count) if (short.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count)
{ {
TShock.TileBans.RemoveBan(id); TShock.TileBans.RemoveBan(id);
args.Player.SendSuccessMessage(GetString("Unbanned tile {0}.", id)); args.Player.SendSuccessMessage(GetString("Unbanned tile {0}.", id));
@ -4315,7 +4315,7 @@ namespace TShockAPI
} }
short id; short id;
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count) if (short.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count)
{ {
if (!TShock.Groups.GroupExists(args.Parameters[2])) if (!TShock.Groups.GroupExists(args.Parameters[2]))
{ {
@ -4375,7 +4375,7 @@ namespace TShockAPI
int pageNumber; int pageNumber;
if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out pageNumber)) if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out pageNumber))
return; return;
IEnumerable<Int16> tileIds = from tileBan in TShock.TileBans.TileBans IEnumerable<short> tileIds = from tileBan in TShock.TileBans.TileBans
select tileBan.ID; select tileBan.ID;
PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(tileIds), PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(tileIds),
new PaginationTools.Settings new PaginationTools.Settings
@ -4465,7 +4465,7 @@ namespace TShockAPI
return; return;
} }
if (String.Equals(args.Parameters[0], "default", StringComparison.CurrentCultureIgnoreCase)) if (string.Equals(args.Parameters[0], "default", StringComparison.CurrentCultureIgnoreCase))
{ {
TShock.Config.Settings.DefaultMaximumSpawns = NPC.defaultMaxSpawns = 5; TShock.Config.Settings.DefaultMaximumSpawns = NPC.defaultMaxSpawns = 5;
if (args.Silent) if (args.Silent)
@ -4505,7 +4505,7 @@ namespace TShockAPI
return; return;
} }
if (String.Equals(args.Parameters[0], "default", StringComparison.CurrentCultureIgnoreCase)) if (string.Equals(args.Parameters[0], "default", StringComparison.CurrentCultureIgnoreCase))
{ {
TShock.Config.Settings.DefaultSpawnRate = NPC.defaultSpawnRate = 600; TShock.Config.Settings.DefaultSpawnRate = NPC.defaultSpawnRate = 600;
if (args.Silent) if (args.Silent)
@ -4714,7 +4714,7 @@ namespace TShockAPI
{ {
if (!args.Player.TempPoints.Any(p => p == Point.Zero)) if (!args.Player.TempPoints.Any(p => p == Point.Zero))
{ {
string regionName = String.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1)); string regionName = string.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1));
var x = Math.Min(args.Player.TempPoints[0].X, args.Player.TempPoints[1].X); var x = Math.Min(args.Player.TempPoints[0].X, args.Player.TempPoints[1].X);
var y = Math.Min(args.Player.TempPoints[0].Y, args.Player.TempPoints[1].Y); var y = Math.Min(args.Player.TempPoints[0].Y, args.Player.TempPoints[1].Y);
var width = Math.Abs(args.Player.TempPoints[0].X - args.Player.TempPoints[1].X); var width = Math.Abs(args.Player.TempPoints[0].X - args.Player.TempPoints[1].X);
@ -4771,7 +4771,7 @@ namespace TShockAPI
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
{ {
string regionName = String.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1)); string regionName = string.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1));
if (TShock.Regions.DeleteRegion(regionName)) if (TShock.Regions.DeleteRegion(regionName))
{ {
args.Player.SendInfoMessage(GetString("Deleted region \"{0}\".", regionName)); args.Player.SendInfoMessage(GetString("Deleted region \"{0}\".", regionName));
@ -5429,7 +5429,7 @@ namespace TShockAPI
} }
int givenCode; int givenCode;
if (!Int32.TryParse(args.Parameters[0], out givenCode) || givenCode != TShock.SetupToken) if (!int.TryParse(args.Parameters[0], out givenCode) || givenCode != TShock.SetupToken)
{ {
args.Player.SendErrorMessage(GetString("Incorrect setup code. This incident has been logged.")); args.Player.SendErrorMessage(GetString("Incorrect setup code. This incident has been logged."));
TShock.Log.Warn(args.Player.IP + " attempted to use an incorrect setup code."); TShock.Log.Warn(args.Player.IP + " attempted to use an incorrect setup code.");
@ -5458,7 +5458,7 @@ namespace TShockAPI
if (args.Player.mute) if (args.Player.mute)
args.Player.SendErrorMessage(GetString("You are muted.")); args.Player.SendErrorMessage(GetString("You are muted."));
else else
TSPlayer.All.SendMessage(GetString("*{0} {1}", args.Player.Name, String.Join(" ", args.Parameters)), 205, 133, 63); TSPlayer.All.SendMessage(GetString("*{0} {1}", args.Player.Name, string.Join(" ", args.Parameters)), 205, 133, 63);
} }
private static void PartyChat(CommandArgs args) private static void PartyChat(CommandArgs args)
@ -5474,7 +5474,7 @@ namespace TShockAPI
args.Player.SendErrorMessage(GetString("You are muted.")); args.Player.SendErrorMessage(GetString("You are muted."));
else if (playerTeam != 0) else if (playerTeam != 0)
{ {
string msg = GetString("<{0}> {1}", args.Player.Name, String.Join(" ", args.Parameters)); string msg = GetString("<{0}> {1}", args.Player.Name, string.Join(" ", args.Parameters));
foreach (TSPlayer player in TShock.Players) foreach (TSPlayer player in TShock.Players)
{ {
if (player != null && player.Active && player.Team == playerTeam) if (player != null && player.Active && player.Team == playerTeam)
@ -5522,7 +5522,7 @@ namespace TShockAPI
{ {
string reason = GetString("No reason specified."); string reason = GetString("No reason specified.");
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
reason = String.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1); reason = string.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1);
var plr = players[0]; var plr = players[0];
plr.mute = true; plr.mute = true;
if (args.Silent) if (args.Silent)
@ -5995,7 +5995,7 @@ namespace TShockAPI
return; return;
} }
string targetName = String.Join(" ", args.Parameters); string targetName = string.Join(" ", args.Parameters);
var players = TSPlayer.FindByNameOrID(targetName); var players = TSPlayer.FindByNameOrID(targetName);
if (players.Count == 0) if (players.Count == 0)
@ -6039,7 +6039,7 @@ namespace TShockAPI
args.Player.SendErrorMessage(GetString("You do not have permission to respawn another player.")); args.Player.SendErrorMessage(GetString("You do not have permission to respawn another player."));
return; return;
} }
string plStr = String.Join(" ", args.Parameters); string plStr = string.Join(" ", args.Parameters);
var players = TSPlayer.FindByNameOrID(plStr); var players = TSPlayer.FindByNameOrID(plStr);
if (players.Count == 0) if (players.Count == 0)
{ {
@ -6785,7 +6785,7 @@ namespace TShockAPI
args.Player.SendErrorMessage(GetString("You do not have permission to god mode another player.")); args.Player.SendErrorMessage(GetString("You do not have permission to god mode another player."));
return; return;
} }
string plStr = String.Join(" ", args.Parameters); string plStr = string.Join(" ", args.Parameters);
var players = TSPlayer.FindByNameOrID(plStr); var players = TSPlayer.FindByNameOrID(plStr);
if (players.Count == 0) if (players.Count == 0)
{ {

View file

@ -107,6 +107,7 @@ namespace TShockAPI.DB
SqlType.Mysql => database.QueryScalar<int>("SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema = @0 and table_name = 'Bans'", TShock.Config.Settings.MySqlDbName), SqlType.Mysql => database.QueryScalar<int>("SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema = @0 and table_name = 'Bans'", TShock.Config.Settings.MySqlDbName),
SqlType.Sqlite => database.QueryScalar<int>("SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name = 'Bans'"), SqlType.Sqlite => database.QueryScalar<int>("SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name = 'Bans'"),
SqlType.Postgres => database.QueryScalar<int>("SELECT COUNT(table_name) FROM information_schema.tables WHERE table_name = 'Bans'"), SqlType.Postgres => database.QueryScalar<int>("SELECT COUNT(table_name) FROM information_schema.tables WHERE table_name = 'Bans'"),
_ => 0,
}; };
if (res != 0) if (res != 0)

View file

@ -186,6 +186,7 @@ namespace TShockAPI.DB
/// Inserts player data to the tsCharacter database table /// Inserts player data to the tsCharacter database table
/// </summary> /// </summary>
/// <param name="player">player to take data from</param> /// <param name="player">player to take data from</param>
/// <param name="fromCommand">If <see langword="false"/>, the <see cref="Permissions.bypassssc"/> permission will be checked</param>
/// <returns>true if inserted successfully</returns> /// <returns>true if inserted successfully</returns>
public bool InsertPlayerData(TSPlayer player, bool fromCommand = false) public bool InsertPlayerData(TSPlayer player, bool fromCommand = false)
{ {

View file

@ -35,7 +35,6 @@ public sealed class DbBuilder
/// <summary> /// <summary>
/// Builds a DB connection based on the provided configuration. /// Builds a DB connection based on the provided configuration.
/// </summary> /// </summary>
/// <param name="config">The TShock configuration.</param>
/// <remarks> /// <remarks>
/// Default settings will result in a local sqlite database file named "tshock.db" in the current directory to be used as server DB. /// Default settings will result in a local sqlite database file named "tshock.db" in the current directory to be used as server DB.
/// </remarks> /// </remarks>

View file

@ -172,7 +172,6 @@ namespace TShockAPI.DB
Permissions.item, Permissions.item,
Permissions.give, Permissions.give,
Permissions.heal, Permissions.heal,
Permissions.immunetoban,
Permissions.usebanneditem, Permissions.usebanneditem,
Permissions.allowclientsideworldedit, Permissions.allowclientsideworldedit,
Permissions.buff, Permissions.buff,

View file

@ -347,10 +347,10 @@ namespace TShockAPI.DB
} }
/// <summary> /// <summary>
/// Gets all user accounts from the database with a username that starts with or contains <see cref="username"/> /// Gets all user accounts from the database with a username that starts with or contains <paramref name="username"/>
/// </summary> /// </summary>
/// <param name="username">Rough username search. "n" will match "n", "na", "nam", "name", etc</param> /// <param name="username">Rough username search. "n" will match "n", "na", "nam", "name", etc</param>
/// <param name="notAtStart">If <see cref="username"/> is not the first part of the username. If true then "name" would match "name", "username", "wordsnamewords", etc</param> /// <param name="notAtStart">If <see href="username"/> is not the first part of the username. If true then "name" would match "name", "username", "wordsnamewords", etc</param>
/// <returns>Matching users or null if exception is thrown</returns> /// <returns>Matching users or null if exception is thrown</returns>
public List<UserAccount> GetUserAccountsByName(string username, bool notAtStart = false) public List<UserAccount> GetUserAccountsByName(string username, bool notAtStart = false)
{ {

View file

@ -184,27 +184,27 @@ namespace TShockAPI.DB
(s, i) => s.IsDBNull(i) ? null : (object)s.GetByte(i) (s, i) => s.IsDBNull(i) ? null : (object)s.GetByte(i)
}, },
{ {
typeof (Int16), typeof (short),
(s, i) => s.GetInt16(i) (s, i) => s.GetInt16(i)
}, },
{ {
typeof (Int16?), typeof (short?),
(s, i) => s.IsDBNull(i) ? null : (object)s.GetInt16(i) (s, i) => s.IsDBNull(i) ? null : (object)s.GetInt16(i)
}, },
{ {
typeof (Int32), typeof (int),
(s, i) => s.GetInt32(i) (s, i) => s.GetInt32(i)
}, },
{ {
typeof (Int32?), typeof (int?),
(s, i) => s.IsDBNull(i) ? null : (object)s.GetInt32(i) (s, i) => s.IsDBNull(i) ? null : (object)s.GetInt32(i)
}, },
{ {
typeof (Int64), typeof (long),
(s, i) => s.GetInt64(i) (s, i) => s.GetInt64(i)
}, },
{ {
typeof (Int64?), typeof (long?),
(s, i) => s.IsDBNull(i) ? null : (object)s.GetInt64(i) (s, i) => s.IsDBNull(i) ? null : (object)s.GetInt64(i)
}, },
{ {

View file

@ -1556,11 +1556,11 @@ namespace TShockAPI
/// <summary> /// <summary>
/// X Location /// X Location
/// </summary> /// </summary>
public Int32 X { get; set; } public int X { get; set; }
/// <summary> /// <summary>
/// Y Location /// Y Location
/// </summary> /// </summary>
public Int32 Y { get; set; } public int Y { get; set; }
/// <summary> /// <summary>
/// Type /// Type
/// </summary> /// </summary>
@ -1574,7 +1574,7 @@ namespace TShockAPI
/// NPCStrike - Called when an NPC is attacked /// NPCStrike - Called when an NPC is attacked
/// </summary> /// </summary>
public static HandlerList<PaintTileEventArgs> PaintTile = new HandlerList<PaintTileEventArgs>(); public static HandlerList<PaintTileEventArgs> PaintTile = new HandlerList<PaintTileEventArgs>();
private static bool OnPaintTile(TSPlayer player, MemoryStream data, Int32 x, Int32 y, byte t, byte ct) private static bool OnPaintTile(TSPlayer player, MemoryStream data, int x, int y, byte t, byte ct)
{ {
if (PaintTile == null) if (PaintTile == null)
return false; return false;
@ -1600,11 +1600,11 @@ namespace TShockAPI
/// <summary> /// <summary>
/// X Location /// X Location
/// </summary> /// </summary>
public Int32 X { get; set; } public int X { get; set; }
/// <summary> /// <summary>
/// Y Location /// Y Location
/// </summary> /// </summary>
public Int32 Y { get; set; } public int Y { get; set; }
/// <summary> /// <summary>
/// Type /// Type
/// </summary> /// </summary>
@ -1618,7 +1618,7 @@ namespace TShockAPI
/// Called When a wall is painted /// Called When a wall is painted
/// </summary> /// </summary>
public static HandlerList<PaintWallEventArgs> PaintWall = new HandlerList<PaintWallEventArgs>(); public static HandlerList<PaintWallEventArgs> PaintWall = new HandlerList<PaintWallEventArgs>();
private static bool OnPaintWall(TSPlayer player, MemoryStream data, Int32 x, Int32 y, byte t, byte cw) private static bool OnPaintWall(TSPlayer player, MemoryStream data, int x, int y, byte t, byte cw)
{ {
if (PaintWall == null) if (PaintWall == null)
return false; return false;
@ -1644,7 +1644,7 @@ namespace TShockAPI
/// <summary> /// <summary>
/// ??? /// ???
/// </summary> /// </summary>
public Int16 ID { get; set; } public short ID { get; set; }
/// <summary> /// <summary>
/// Flag is a bit field /// Flag is a bit field
/// if the first bit is set -> 0 = player, 1 = NPC /// if the first bit is set -> 0 = player, 1 = NPC
@ -1674,7 +1674,7 @@ namespace TShockAPI
/// NPCStrike - Called when an NPC is attacked /// NPCStrike - Called when an NPC is attacked
/// </summary> /// </summary>
public static HandlerList<TeleportEventArgs> Teleport = new HandlerList<TeleportEventArgs>(); public static HandlerList<TeleportEventArgs> Teleport = new HandlerList<TeleportEventArgs>();
private static bool OnTeleport(TSPlayer player, MemoryStream data, Int16 id, byte f, float x, float y, byte style, int extraInfo) private static bool OnTeleport(TSPlayer player, MemoryStream data, short id, byte f, float x, float y, byte style, int extraInfo)
{ {
if (Teleport == null) if (Teleport == null)
return false; return false;
@ -4625,7 +4625,8 @@ namespace TShockAPI
{ {
0 => NetItem.Loadout1Armor, 0 => NetItem.Loadout1Armor,
1 => NetItem.Loadout2Armor, 1 => NetItem.Loadout2Armor,
2 => NetItem.Loadout3Armor 2 => NetItem.Loadout3Armor,
_ => throw new NotImplementedException($"invalid lodout index {index}")
}; };
} }
@ -4635,7 +4636,8 @@ namespace TShockAPI
{ {
0 => NetItem.Loadout1Dye, 0 => NetItem.Loadout1Dye,
1 => NetItem.Loadout2Dye, 1 => NetItem.Loadout2Dye,
2 => NetItem.Loadout3Dye 2 => NetItem.Loadout3Dye,
_ => throw new NotImplementedException($"invalid lodout index {index}")
}; };
} }

View file

@ -208,7 +208,7 @@ namespace TShockAPI
public virtual bool HasPermission(string permission) public virtual bool HasPermission(string permission)
{ {
bool negated = false; bool negated = false;
if (String.IsNullOrEmpty(permission) || (RealHasPermission(permission, ref negated) && !negated)) if (string.IsNullOrEmpty(permission) || (RealHasPermission(permission, ref negated) && !negated))
{ {
return true; return true;
} }
@ -220,7 +220,7 @@ namespace TShockAPI
for (int i = nodes.Length - 1; i >= 0; i--) for (int i = nodes.Length - 1; i >= 0; i--)
{ {
nodes[i] = "*"; nodes[i] = "*";
if (RealHasPermission(String.Join(".", nodes, 0, i + 1), ref negated)) if (RealHasPermission(string.Join(".", nodes, 0, i + 1), ref negated))
{ {
return !negated; return !negated;
} }

View file

@ -14,8 +14,8 @@ namespace TShockAPI.Handlers
{ {
public void OnReceive(object sender, DisplayDollItemSyncEventArgs args) public void OnReceive(object sender, DisplayDollItemSyncEventArgs args)
{ {
/// If the player has no building permissions means that they couldn't even see the content of the doll in the first place. // If the player has no building permissions means that they couldn't even see the content of the doll in the first place.
/// Thus, they would not be able to modify its content. This means that a hacker attempted to send this packet directly, or through raw bytes to tamper with the DisplayDoll. This is why I do not bother with making sure the player gets their item back. // Thus, they would not be able to modify its content. This means that a hacker attempted to send this packet directly, or through raw bytes to tamper with the DisplayDoll. This is why I do not bother with making sure the player gets their item back.
if (!args.Player.HasBuildPermission(args.DisplayDollEntity.Position.X, args.DisplayDollEntity.Position.Y, false)) if (!args.Player.HasBuildPermission(args.DisplayDollEntity.Position.X, args.DisplayDollEntity.Position.Y, false))
{ {
args.Player.SendErrorMessage(GetString("You do not have permission to modify a Mannequin in a protected area!")); args.Player.SendErrorMessage(GetString("You do not have permission to modify a Mannequin in a protected area!"));

View file

@ -145,6 +145,7 @@ namespace TShockAPI
/// Writes a debug string to the log file. Only works if the DebugLogs config option is set to true. /// Writes a debug string to the log file. Only works if the DebugLogs config option is set to true.
/// </summary> /// </summary>
/// <param name="message">The message to be written.</param> /// <param name="message">The message to be written.</param>
/// <param name="args">format args</param>
void ConsoleDebug(string message, params object[] args); void ConsoleDebug(string message, params object[] args);
/// <summary> /// <summary>

View file

@ -241,7 +241,7 @@ namespace TShockAPI
/// <returns></returns> /// <returns></returns>
public override string ToString() public override string ToString()
{ {
return String.Format("{0},{1},{2},{3}", _netId, _stack, _prefixId, _favorited ? 1 : 0); return string.Format("{0},{1},{2},{3}", _netId, _stack, _prefixId, _favorited ? 1 : 0);
} }
/// <summary> /// <summary>
@ -259,10 +259,10 @@ namespace TShockAPI
if (comp.Length != 4) if (comp.Length != 4)
throw new FormatException("String does not contain 4 sections."); throw new FormatException("String does not contain 4 sections.");
int netId = Int32.Parse(comp[0]); int netId = int.Parse(comp[0]);
int stack = Int32.Parse(comp[1]); int stack = int.Parse(comp[1]);
byte prefixId = Byte.Parse(comp[2]); byte prefixId = byte.Parse(comp[2]);
bool favorited = Int32.Parse(comp[3]) == 1; bool favorited = int.Parse(comp[3]) == 1;
return new NetItem(netId, stack, prefixId, favorited); return new NetItem(netId, stack, prefixId, favorited);
} }

View file

@ -24,7 +24,6 @@ using System.Linq;
using System.Text; using System.Text;
// Since the permission nodes have annotations that say what they are, we don't need XML comments. // Since the permission nodes have annotations that say what they are, we don't need XML comments.
#pragma warning disable 1591
namespace TShockAPI namespace TShockAPI
{ {

View file

@ -221,7 +221,7 @@ namespace Rests
Ip = ip; Ip = ip;
Port = port; Port = port;
AssemblyName assembly = this.GetType().Assembly.GetName(); AssemblyName assembly = this.GetType().Assembly.GetName();
serverHeader = new StringHeader("Server", String.Format("{0}/{1}", assembly.Name, assembly.Version)); serverHeader = new StringHeader("Server", string.Format("{0}/{1}", assembly.Name, assembly.Version));
} }
/// <summary> /// <summary>

View file

@ -155,7 +155,7 @@ namespace TShockAPI
/// <summary> /// <summary>
/// Creates a new instance of <see cref="Token"/> /// Creates a new instance of <see cref="Token"/>
/// </summary> /// </summary>
public Token() : base("token", true, GetString("The REST authentication token."), typeof(String)) { } public Token() : base("token", true, GetString("The REST authentication token."), typeof(string)) { }
} }
/// <summary> /// <summary>
@ -300,7 +300,7 @@ namespace TShockAPI
[Description("Executes a remote command on the server, and returns the output of the command.")] [Description("Executes a remote command on the server, and returns the output of the command.")]
[RouteAttribute("/v3/server/rawcmd")] [RouteAttribute("/v3/server/rawcmd")]
[Permission(RestPermissions.restrawcommand)] [Permission(RestPermissions.restrawcommand)]
[Noun("cmd", true, "The command and arguments to execute.", typeof(String))] [Noun("cmd", true, "The command and arguments to execute.", typeof(string))]
[Token] [Token]
private object ServerCommandV3(RestRequestArgs args) private object ServerCommandV3(RestRequestArgs args)
{ {
@ -321,7 +321,7 @@ namespace TShockAPI
[Route("/v2/server/off")] [Route("/v2/server/off")]
[Permission(RestPermissions.restmaintenance)] [Permission(RestPermissions.restmaintenance)]
[Noun("confirm", true, "Required to confirm that actually want to turn the server off.", typeof(bool))] [Noun("confirm", true, "Required to confirm that actually want to turn the server off.", typeof(bool))]
[Noun("message", false, "The shutdown message.", typeof(String))] [Noun("message", false, "The shutdown message.", typeof(string))]
[Noun("nosave", false, "Shutdown without saving.", typeof(bool))] [Noun("nosave", false, "Shutdown without saving.", typeof(bool))]
[Token] [Token]
private object ServerOff(RestRequestArgs args) private object ServerOff(RestRequestArgs args)
@ -350,7 +350,7 @@ namespace TShockAPI
[Description("Broadcast a server wide message.")] [Description("Broadcast a server wide message.")]
[Route("/v2/server/broadcast")] [Route("/v2/server/broadcast")]
[Noun("msg", true, "The message to broadcast.", typeof(String))] [Noun("msg", true, "The message to broadcast.", typeof(string))]
[Token] [Token]
private object ServerBroadcast(RestRequestArgs args) private object ServerBroadcast(RestRequestArgs args)
{ {
@ -484,9 +484,9 @@ namespace TShockAPI
[Description("Create a new TShock user account.")] [Description("Create a new TShock user account.")]
[Route("/v2/users/create")] [Route("/v2/users/create")]
[Permission(RestPermissions.restmanageusers)] [Permission(RestPermissions.restmanageusers)]
[Noun("user", true, "The user account name for the new account.", typeof(String))] [Noun("user", true, "The user account name for the new account.", typeof(string))]
[Noun("group", false, "The group the new account should be assigned.", typeof(String))] [Noun("group", false, "The group the new account should be assigned.", typeof(string))]
[Noun("password", true, "The password for the new account.", typeof(String))] [Noun("password", true, "The password for the new account.", typeof(string))]
[Token] [Token]
private object UserCreateV2(RestRequestArgs args) private object UserCreateV2(RestRequestArgs args)
{ {
@ -520,10 +520,10 @@ namespace TShockAPI
[Description("Update a users information.")] [Description("Update a users information.")]
[Route("/v2/users/update")] [Route("/v2/users/update")]
[Permission(RestPermissions.restmanageusers)] [Permission(RestPermissions.restmanageusers)]
[Noun("user", true, "The search criteria (name or id of account to lookup).", typeof(String))] [Noun("user", true, "The search criteria (name or id of account to lookup).", typeof(string))]
[Noun("type", true, "The search criteria type (name for name lookup, id for id lookup).", typeof(String))] [Noun("type", true, "The search criteria type (name for name lookup, id for id lookup).", typeof(string))]
[Noun("password", false, "The users new password, and at least this or group must be defined.", typeof(String))] [Noun("password", false, "The users new password, and at least this or group must be defined.", typeof(string))]
[Noun("group", false, "The new group for the user, at least this or password must be defined.", typeof(String))] [Noun("group", false, "The new group for the user, at least this or password must be defined.", typeof(string))]
[Token] [Token]
private object UserUpdateV2(RestRequestArgs args) private object UserUpdateV2(RestRequestArgs args)
{ {
@ -571,8 +571,8 @@ namespace TShockAPI
[Description("Destroy a TShock user account.")] [Description("Destroy a TShock user account.")]
[Route("/v2/users/destroy")] [Route("/v2/users/destroy")]
[Permission(RestPermissions.restmanageusers)] [Permission(RestPermissions.restmanageusers)]
[Noun("user", true, "The search criteria (name or id of account to lookup).", typeof(String))] [Noun("user", true, "The search criteria (name or id of account to lookup).", typeof(string))]
[Noun("type", true, "The search criteria type (name for name lookup, id for id lookup).", typeof(String))] [Noun("type", true, "The search criteria type (name for name lookup, id for id lookup).", typeof(string))]
[Token] [Token]
private object UserDestroyV2(RestRequestArgs args) private object UserDestroyV2(RestRequestArgs args)
{ {
@ -595,8 +595,8 @@ namespace TShockAPI
[Description("List detailed information for a user account.")] [Description("List detailed information for a user account.")]
[Route("/v2/users/read")] [Route("/v2/users/read")]
[Permission(RestPermissions.restviewusers)] [Permission(RestPermissions.restviewusers)]
[Noun("user", true, "The search criteria (name or id of account to lookup).", typeof(String))] [Noun("user", true, "The search criteria (name or id of account to lookup).", typeof(string))]
[Noun("type", true, "The search criteria type (name for name lookup, id for id lookup).", typeof(String))] [Noun("type", true, "The search criteria type (name for name lookup, id for id lookup).", typeof(string))]
[Token] [Token]
private object UserInfoV2(RestRequestArgs args) private object UserInfoV2(RestRequestArgs args)
{ {
@ -615,10 +615,10 @@ namespace TShockAPI
[Description("Create a new ban entry.")] [Description("Create a new ban entry.")]
[Route("/v3/bans/create")] [Route("/v3/bans/create")]
[Permission(RestPermissions.restmanagebans)] [Permission(RestPermissions.restmanagebans)]
[Noun("identifier", true, "The identifier to ban.", typeof(String))] [Noun("identifier", true, "The identifier to ban.", typeof(string))]
[Noun("reason", false, "The reason to assign to the ban.", typeof(String))] [Noun("reason", false, "The reason to assign to the ban.", typeof(string))]
[Noun("start", false, "The datetime at which the ban should start.", typeof(String))] [Noun("start", false, "The datetime at which the ban should start.", typeof(string))]
[Noun("end", false, "The datetime at which the ban should end.", typeof(String))] [Noun("end", false, "The datetime at which the ban should end.", typeof(string))]
[Token] [Token]
private object BanCreateV3(RestRequestArgs args) private object BanCreateV3(RestRequestArgs args)
{ {
@ -675,7 +675,7 @@ namespace TShockAPI
[Description("Delete an existing ban entry.")] [Description("Delete an existing ban entry.")]
[Route("/v3/bans/destroy")] [Route("/v3/bans/destroy")]
[Permission(RestPermissions.restmanagebans)] [Permission(RestPermissions.restmanagebans)]
[Noun("ticketNumber", true, "The ticket number of the ban to delete.", typeof(String))] [Noun("ticketNumber", true, "The ticket number of the ban to delete.", typeof(string))]
[Noun("fullDelete", false, "Whether or not to completely remove the ban from the system.", typeof(bool))] [Noun("fullDelete", false, "Whether or not to completely remove the ban from the system.", typeof(bool))]
[Token] [Token]
private object BanDestroyV3(RestRequestArgs args) private object BanDestroyV3(RestRequestArgs args)
@ -702,7 +702,7 @@ namespace TShockAPI
[Description("View the details of a specific ban.")] [Description("View the details of a specific ban.")]
[Route("/v3/bans/read")] [Route("/v3/bans/read")]
[Permission(RestPermissions.restviewbans)] [Permission(RestPermissions.restviewbans)]
[Noun("ticketNumber", true, "The ticket number to search for.", typeof(String))] [Noun("ticketNumber", true, "The ticket number to search for.", typeof(string))]
[Token] [Token]
private object BanInfoV3(RestRequestArgs args) private object BanInfoV3(RestRequestArgs args)
{ {
@ -923,7 +923,7 @@ namespace TShockAPI
[Description("Unmute a player.")] [Description("Unmute a player.")]
[Route("/v2/players/unmute")] [Route("/v2/players/unmute")]
[Permission(RestPermissions.restmute)] [Permission(RestPermissions.restmute)]
[Noun("player", true, "The player to mute.", typeof(String))] [Noun("player", true, "The player to mute.", typeof(string))]
[Token] [Token]
private object PlayerUnMute(RestRequestArgs args) private object PlayerUnMute(RestRequestArgs args)
{ {
@ -933,7 +933,7 @@ namespace TShockAPI
[Description("Mute a player.")] [Description("Mute a player.")]
[Route("/v2/players/mute")] [Route("/v2/players/mute")]
[Permission(RestPermissions.restmute)] [Permission(RestPermissions.restmute)]
[Noun("player", true, "The player to mute.", typeof(String))] [Noun("player", true, "The player to mute.", typeof(string))]
[Token] [Token]
private object PlayerMute(RestRequestArgs args) private object PlayerMute(RestRequestArgs args)
{ {
@ -967,7 +967,7 @@ namespace TShockAPI
[Description("Get information for a user.")] [Description("Get information for a user.")]
[Route("/v3/players/read")] [Route("/v3/players/read")]
[Permission(RestPermissions.restuserinfo)] [Permission(RestPermissions.restuserinfo)]
[Noun("player", true, "The player to lookup", typeof(String))] [Noun("player", true, "The player to lookup", typeof(string))]
[Token] [Token]
private object PlayerReadV3(RestRequestArgs args) private object PlayerReadV3(RestRequestArgs args)
{ {
@ -998,7 +998,7 @@ namespace TShockAPI
[Description("Get information for a user.")] [Description("Get information for a user.")]
[Route("/v4/players/read")] [Route("/v4/players/read")]
[Permission(RestPermissions.restuserinfo)] [Permission(RestPermissions.restuserinfo)]
[Noun("player", true, "The player to lookup", typeof(String))] [Noun("player", true, "The player to lookup", typeof(string))]
[Token] [Token]
private object PlayerReadV4(RestRequestArgs args) private object PlayerReadV4(RestRequestArgs args)
{ {
@ -1037,8 +1037,8 @@ namespace TShockAPI
[Description("Kick a player off the server.")] [Description("Kick a player off the server.")]
[Route("/v2/players/kick")] [Route("/v2/players/kick")]
[Permission(RestPermissions.restkick)] [Permission(RestPermissions.restkick)]
[Noun("player", true, "The player to kick.", typeof(String))] [Noun("player", true, "The player to kick.", typeof(string))]
[Noun("reason", false, "The reason the player was kicked.", typeof(String))] [Noun("reason", false, "The reason the player was kicked.", typeof(string))]
[Token] [Token]
private object PlayerKickV2(RestRequestArgs args) private object PlayerKickV2(RestRequestArgs args)
{ {
@ -1054,8 +1054,8 @@ namespace TShockAPI
[Description("Kill a player.")] [Description("Kill a player.")]
[Route("/v2/players/kill")] [Route("/v2/players/kill")]
[Permission(RestPermissions.restkill)] [Permission(RestPermissions.restkill)]
[Noun("player", true, "The player to kick.", typeof(String))] [Noun("player", true, "The player to kick.", typeof(string))]
[Noun("from", false, "Who killed the player.", typeof(String))] [Noun("from", false, "Who killed the player.", typeof(string))]
[Token] [Token]
private object PlayerKill(RestRequestArgs args) private object PlayerKill(RestRequestArgs args)
{ {
@ -1091,7 +1091,7 @@ namespace TShockAPI
[Description("Display information of a group.")] [Description("Display information of a group.")]
[Route("/v2/groups/read")] [Route("/v2/groups/read")]
[Permission(RestPermissions.restviewgroups)] [Permission(RestPermissions.restviewgroups)]
[Noun("group", true, "The group name to get information on.", typeof(String))] [Noun("group", true, "The group name to get information on.", typeof(string))]
[Token] [Token]
private object GroupInfo(RestRequestArgs args) private object GroupInfo(RestRequestArgs args)
{ {
@ -1113,7 +1113,7 @@ namespace TShockAPI
[Description("Delete a group.")] [Description("Delete a group.")]
[Route("/v2/groups/destroy")] [Route("/v2/groups/destroy")]
[Permission(RestPermissions.restmanagegroups)] [Permission(RestPermissions.restmanagegroups)]
[Noun("group", true, "The group name to delete.", typeof(String))] [Noun("group", true, "The group name to delete.", typeof(string))]
[Token] [Token]
private object GroupDestroy(RestRequestArgs args) private object GroupDestroy(RestRequestArgs args)
{ {
@ -1137,10 +1137,10 @@ namespace TShockAPI
[Description("Create a new group.")] [Description("Create a new group.")]
[Route("/v2/groups/create")] [Route("/v2/groups/create")]
[Permission(RestPermissions.restmanagegroups)] [Permission(RestPermissions.restmanagegroups)]
[Noun("group", true, "The name of the new group.", typeof(String))] [Noun("group", true, "The name of the new group.", typeof(string))]
[Noun("parent", false, "The name of the parent group.", typeof(String))] [Noun("parent", false, "The name of the parent group.", typeof(string))]
[Noun("permissions", false, "A comma separated list of permissions for the new group.", typeof(String))] [Noun("permissions", false, "A comma separated list of permissions for the new group.", typeof(string))]
[Noun("chatcolor", false, "A r,g,b string representing the color for this groups chat.", typeof(String))] [Noun("chatcolor", false, "A r,g,b string representing the color for this groups chat.", typeof(string))]
[Token] [Token]
private object GroupCreate(RestRequestArgs args) private object GroupCreate(RestRequestArgs args)
{ {
@ -1161,10 +1161,10 @@ namespace TShockAPI
[Route("/v2/groups/update")] [Route("/v2/groups/update")]
[Permission(RestPermissions.restmanagegroups)] [Permission(RestPermissions.restmanagegroups)]
[Noun("group", true, "The name of the group to modify.", typeof(String))] [Noun("group", true, "The name of the group to modify.", typeof(string))]
[Noun("parent", false, "The name of the new parent for this group.", typeof(String))] [Noun("parent", false, "The name of the new parent for this group.", typeof(string))]
[Noun("chatcolor", false, "The new chat color r,g,b.", typeof(String))] [Noun("chatcolor", false, "The new chat color r,g,b.", typeof(string))]
[Noun("permissions", false, "The new comma separated list of permissions.", typeof(String))] [Noun("permissions", false, "The new comma separated list of permissions.", typeof(string))]
[Token] [Token]
private object GroupUpdate(RestRequestArgs args) private object GroupUpdate(RestRequestArgs args)
{ {
@ -1218,7 +1218,7 @@ namespace TShockAPI
var permission = method.GetCustomAttributes(false).Where(o => o is Permission); var permission = method.GetCustomAttributes(false).Where(o => o is Permission);
if (permission.Any()) if (permission.Any())
{ {
sb.AppendLine(GetString("* **Permissions**: `{0}`", String.Join(", ", permission.Select(p => ((Permission)p).Name)))); sb.AppendLine(GetString("* **Permissions**: `{0}`", string.Join(", ", permission.Select(p => ((Permission)p).Name))));
} }
else else
{ {
@ -1252,7 +1252,7 @@ namespace TShockAPI
} }
sb.AppendLine(); sb.AppendLine();
sb.AppendLine(GetString("**Example Usage**: `{0}?{1}`", routeattr.Route, sb.AppendLine(GetString("**Example Usage**: `{0}?{1}`", routeattr.Route,
string.Join("&", nouns.Select(n => String.Format("{0}={0}", ((Noun)n).Name))))); string.Join("&", nouns.Select(n => string.Format("{0}={0}", ((Noun)n).Name)))));
sb.AppendLine(); sb.AppendLine();
} }
} }

View file

@ -42,7 +42,7 @@ namespace Rests
public Dictionary<string, TokenData> Tokens { get; protected set; } public Dictionary<string, TokenData> Tokens { get; protected set; }
public Dictionary<string, TokenData> AppTokens { get; protected set; } public Dictionary<string, TokenData> AppTokens { get; protected set; }
private RNGCryptoServiceProvider _rng = new RNGCryptoServiceProvider(); private RandomNumberGenerator _rng = RandomNumberGenerator.Create();
public SecureRest(IPAddress ip, int port) public SecureRest(IPAddress ip, int port)
: base(ip, port) : base(ip, port)

View file

@ -38,7 +38,7 @@ using Terraria.GameContent.Creative;
namespace TShockAPI namespace TShockAPI
{ {
/// <summary> /// <summary>
/// Bitflags used with the <see cref="Disable(string, DisableFlags)"></see> method /// Bitflags used with the <see cref="TSPlayer.Disable(string, DisableFlags)"></see> method
/// </summary> /// </summary>
[Flags] [Flags]
public enum DisableFlags public enum DisableFlags
@ -121,7 +121,7 @@ namespace TShockAPI
/// If the string comes with tsi: or tsn:, we'll only return a list with one element, /// If the string comes with tsi: or tsn:, we'll only return a list with one element,
/// either the player with the matching ID or name, respectively. /// either the player with the matching ID or name, respectively.
/// </summary> /// </summary>
/// <param name="plr">Player name or ID</param> /// <param name="search">Player name or ID</param>
/// <returns>A list of matching players</returns> /// <returns>A list of matching players</returns>
public static List<TSPlayer> FindByNameOrID(string search) public static List<TSPlayer> FindByNameOrID(string search)
{ {
@ -1404,7 +1404,7 @@ namespace TShockAPI
/// Initializes a new instance of the <see cref="TSPlayer"/> class. /// Initializes a new instance of the <see cref="TSPlayer"/> class.
/// </summary> /// </summary>
/// <param name="playerName">The player's name.</param> /// <param name="playerName">The player's name.</param>
protected TSPlayer(String playerName) protected TSPlayer(string playerName)
{ {
TilesDestroyed = new Dictionary<Vector2, ITile>(); TilesDestroyed = new Dictionary<Vector2, ITile>();
TilesCreated = new Dictionary<Vector2, ITile>(); TilesCreated = new Dictionary<Vector2, ITile>();
@ -1943,7 +1943,6 @@ namespace TShockAPI
public void SendFileTextAsMessage(string file) public void SendFileTextAsMessage(string file)
{ {
string foo = ""; string foo = "";
bool containsOldFormat = false;
using (var tr = new StreamReader(file)) using (var tr = new StreamReader(file))
{ {
Color lineColor; Color lineColor;
@ -1966,7 +1965,7 @@ namespace TShockAPI
} }
foo = foo.Replace("%map%", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName)); foo = foo.Replace("%map%", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName));
foo = foo.Replace("%players%", String.Join(", ", players)); foo = foo.Replace("%players%", string.Join(", ", players));
foo = foo.Replace("%specifier%", TShock.Config.Settings.CommandSpecifier); foo = foo.Replace("%specifier%", TShock.Config.Settings.CommandSpecifier);
foo = foo.Replace("%onlineplayers%", TShock.Utils.GetActivePlayerCount().ToString()); foo = foo.Replace("%onlineplayers%", TShock.Utils.GetActivePlayerCount().ToString());
foo = foo.Replace("%serverslots%", TShock.Config.Settings.MaxSlots.ToString()); foo = foo.Replace("%serverslots%", TShock.Config.Settings.MaxSlots.ToString());

View file

@ -75,15 +75,8 @@ namespace TShockAPI
var snippets = Terraria.UI.Chat.ChatManager.ParseMessage(msg, new Color(red, green, blue)); var snippets = Terraria.UI.Chat.ChatManager.ParseMessage(msg, new Color(red, green, blue));
foreach (var snippet in snippets) foreach (var snippet in snippets)
{
if (snippet.Color != null)
{ {
Console.ForegroundColor = PickNearbyConsoleColor(snippet.Color); Console.ForegroundColor = PickNearbyConsoleColor(snippet.Color);
}
else
{
Console.ForegroundColor = ConsoleColor.Gray;
}
Console.Write(snippet.Text); Console.Write(snippet.Text);
} }

View file

@ -537,10 +537,10 @@ namespace TShockAPI
/// <param name="args">args - The PlayerPostLoginEventArgs object.</param> /// <param name="args">args - The PlayerPostLoginEventArgs object.</param>
private void OnPlayerLogin(PlayerPostLoginEventArgs args) private void OnPlayerLogin(PlayerPostLoginEventArgs args)
{ {
List<String> KnownIps = new List<string>(); List<string> KnownIps = new List<string>();
if (!string.IsNullOrWhiteSpace(args.Player.Account.KnownIps)) if (!string.IsNullOrWhiteSpace(args.Player.Account.KnownIps))
{ {
KnownIps = JsonConvert.DeserializeObject<List<String>>(args.Player.Account.KnownIps); KnownIps = JsonConvert.DeserializeObject<List<string>>(args.Player.Account.KnownIps);
} }
if (KnownIps.Count == 0) if (KnownIps.Count == 0)
@ -1358,7 +1358,7 @@ namespace TShockAPI
return; return;
} }
if (Config.Settings.KickEmptyUUID && String.IsNullOrWhiteSpace(player.UUID)) if (Config.Settings.KickEmptyUUID && string.IsNullOrWhiteSpace(player.UUID))
{ {
player.Kick(GetString("Your client sent a blank UUID. Configure it to send one or use a different client."), true, true, null, false); player.Kick(GetString("Your client sent a blank UUID. Configure it to send one or use a different client."), true, true, null, false);
args.Handled = true; args.Handled = true;
@ -1481,7 +1481,7 @@ namespace TShockAPI
{ {
if (item.Value._name == args.CommandId._name) if (item.Value._name == args.CommandId._name)
{ {
if (!String.IsNullOrEmpty(text)) if (!string.IsNullOrEmpty(text))
{ {
text = EnglishLanguage.GetCommandPrefixByName(item.Value._name) + ' ' + text; text = EnglishLanguage.GetCommandPrefixByName(item.Value._name) + ' ' + text;
} }
@ -1525,7 +1525,7 @@ namespace TShockAPI
} }
else if (!TShock.Config.Settings.EnableChatAboveHeads) else if (!TShock.Config.Settings.EnableChatAboveHeads)
{ {
text = String.Format(Config.Settings.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, text = string.Format(Config.Settings.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix,
args.Text); args.Text);
//Invoke the PlayerChat hook. If this hook event is handled then we need to prevent sending the chat message //Invoke the PlayerChat hook. If this hook event is handled then we need to prevent sending the chat message
@ -1543,7 +1543,7 @@ namespace TShockAPI
{ {
Player ply = Main.player[args.Who]; Player ply = Main.player[args.Who];
string name = ply.name; string name = ply.name;
ply.name = String.Format(Config.Settings.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix); ply.name = string.Format(Config.Settings.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix);
//Update the player's name to format text nicely. This needs to be done because Terraria automatically formats messages against our will //Update the player's name to format text nicely. This needs to be done because Terraria automatically formats messages against our will
NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, NetworkText.FromLiteral(ply.name), args.Who, 0, 0, 0, 0); NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, NetworkText.FromLiteral(ply.name), args.Who, 0, 0, 0, 0);
@ -1568,8 +1568,8 @@ namespace TShockAPI
//Reset their name //Reset their name
NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, NetworkText.FromLiteral(name), args.Who, 0, 0, 0, 0); NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, NetworkText.FromLiteral(name), args.Who, 0, 0, 0, 0);
string msg = String.Format("<{0}> {1}", string msg = string.Format("<{0}> {1}",
String.Format(Config.Settings.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix), string.Format(Config.Settings.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix),
text text
); );

View file

@ -29,6 +29,7 @@
<Authors>Pryaxis &amp; TShock Contributors</Authors> <Authors>Pryaxis &amp; TShock Contributors</Authors>
<Description>TShock is a toolbox for Terraria servers and communities.</Description> <Description>TShock is a toolbox for Terraria servers and communities.</Description>
<PackageId>TShock</PackageId> <!-- package name for nuget, instead of TShockAPI --> <PackageId>TShock</PackageId> <!-- package name for nuget, instead of TShockAPI -->
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

@ -249,7 +249,7 @@ namespace TShockAPI
public List<Item> GetItemByIdOrName(string text) public List<Item> GetItemByIdOrName(string text)
{ {
int type = -1; int type = -1;
if (Int32.TryParse(text, out type)) if (int.TryParse(text, out type))
{ {
if (type >= Terraria.ID.ItemID.Count) if (type >= Terraria.ID.ItemID.Count)
return new List<Item>(); return new List<Item>();
@ -335,11 +335,11 @@ namespace TShockAPI
if (!match.Success) if (!match.Success)
return null; return null;
Item item = new Item(); Item item = new Item();
item.netDefaults(Int32.Parse(match.Groups["NetID"].Value)); item.netDefaults(int.Parse(match.Groups["NetID"].Value));
if (!String.IsNullOrWhiteSpace(match.Groups["Stack"].Value)) if (!string.IsNullOrWhiteSpace(match.Groups["Stack"].Value))
item.stack = Int32.Parse(match.Groups["Stack"].Value); item.stack = int.Parse(match.Groups["Stack"].Value);
if (!String.IsNullOrWhiteSpace(match.Groups["Prefix"].Value)) if (!string.IsNullOrWhiteSpace(match.Groups["Prefix"].Value))
item.prefix = Byte.Parse(match.Groups["Prefix"].Value); item.prefix = byte.Parse(match.Groups["Prefix"].Value);
return item; return item;
} }
@ -921,7 +921,7 @@ namespace TShockAPI
/// <returns>The <paramref name="text"/>, surrounded by the color tag with the appropriated hex code.</returns> /// <returns>The <paramref name="text"/>, surrounded by the color tag with the appropriated hex code.</returns>
public string ColorTag(string text, Color color) public string ColorTag(string text, Color color)
{ {
return String.Format("[c/{0}:{1}]", color.Hex3(), text); return string.Format("[c/{0}:{1}]", color.Hex3(), text);
} }
/// <summary> /// <summary>
@ -935,7 +935,7 @@ namespace TShockAPI
int stack = item.stack; int stack = item.stack;
int prefix = item.prefix; int prefix = item.prefix;
string options = stack > 1 ? "/s" + stack : prefix != 0 ? "/p" + prefix : ""; string options = stack > 1 ? "/s" + stack : prefix != 0 ? "/p" + prefix : "";
return String.Format("[i{0}:{1}]", options, netID); return string.Format("[i{0}:{1}]", options, netID);
} }
/// <summary> /// <summary>

View file

@ -181,7 +181,7 @@ namespace TShockPluginManager
} }
static public void DumpGraph(SourcePackageDependencyInfo from, IEnumerable<SourcePackageDependencyInfo> data, IEnumerable<SourcePackageDependencyInfo> builtins, int level) static public void DumpGraph(SourcePackageDependencyInfo from, IEnumerable<SourcePackageDependencyInfo> data, IEnumerable<SourcePackageDependencyInfo> builtins, int level)
{ {
var indent = new String('\t', level); var indent = new string('\t', level);
Console.Write(indent); Console.Write(indent);
CLIHelpers.WriteLine(C.GetString($"<green>{from.Id} <black>from <blue>{from.Source.PackageSource.Name} <black>[{from.Source.PackageSource.Source}]")); CLIHelpers.WriteLine(C.GetString($"<green>{from.Id} <black>from <blue>{from.Source.PackageSource.Name} <black>[{from.Source.PackageSource.Source}]"));