diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index a2d7ac0e..76e63e21 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -452,7 +452,7 @@ namespace TShockAPI byte plr = args.PlayerId; ControlSet control = args.Control; MiscDataSet1 miscData1 = args.MiscData1; - byte item = args.SelectedItem ; + byte item = args.SelectedItem; var pos = args.Position; var vel = args.Velocity; @@ -699,11 +699,11 @@ namespace TShockAPI // also add an exception for snake coils, they can be removed when the player places a new one or after x amount of time // If the tile is part of the breakable when placing set, it might be getting broken by a placement. else if (tile.type != TileID.ItemFrame && tile.type != TileID.MysticSnakeRope - && !Main.tileAxe[tile.type] && !Main.tileHammer[tile.type] && tile.wall == 0 && - args.Player.TPlayer.mount.Type != MountID.Drill && selectedItem.pick == 0 && - selectedItem.type != ItemID.GravediggerShovel && - !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0 - && !TileID.Sets.BreakableWhenPlacing[tile.type]) + && !Main.tileAxe[tile.type] && !Main.tileHammer[tile.type] && tile.wall == 0 && + args.Player.TPlayer.mount.Type != MountID.Drill && selectedItem.pick == 0 && + selectedItem.type != ItemID.GravediggerShovel && + !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0 + && !TileID.Sets.BreakableWhenPlacing[tile.type]) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from (pick) {0} {1} {2}", args.Player.Name, action, editData)); @@ -932,7 +932,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { - TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from throttled from {0} {1} {2}"), args.Player.Name, action, editData); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from throttled from {0} {1} {2}", args.Player.Name, action, editData)); args.Player.SendTileSquareCentered(tileX, tileY, 4); args.Handled = true; return; @@ -1665,7 +1665,7 @@ namespace TShockAPI { if (TShock.Config.Settings.KickOnTileLiquidThresholdBroken) { - args.Player.Kick(string.Format("Reached TileLiquid threshold {0}.", TShock.Config.Settings.TileLiquidThreshold)); + args.Player.Kick(GetString("Reached TileLiquid threshold {0}.", TShock.Config.Settings.TileLiquidThreshold)); } else { @@ -1822,7 +1822,7 @@ namespace TShockAPI } if (!wasThereABombNearby && type == LiquidType.Shimmer && - TShock.ItemBans.DataModel.ItemIsBanned("Bottomless Shimmer Bucket", args.Player)) + TShock.ItemBans.DataModel.ItemIsBanned("Bottomless Shimmer Bucket", args.Player)) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnLiquidSet rejected bucket check 7 from {0}", args.Player.Name)); args.Player.SendErrorMessage(GetString("You do not have permission to perform this action.")); @@ -2269,7 +2269,7 @@ namespace TShockAPI if (args.Player.SelectedItem.type is ItemID.RubblemakerSmall or ItemID.RubblemakerMedium or ItemID.RubblemakerLarge) { if (type != TileID.LargePilesEcho && type != TileID.LargePiles2Echo && type != TileID.SmallPiles2x1Echo && - type != TileID.SmallPiles1x1Echo && type != TileID.PlantDetritus3x2Echo && type != TileID.PlantDetritus2x2Echo) + type != TileID.SmallPiles1x1Echo && type != TileID.PlantDetritus3x2Echo && type != TileID.PlantDetritus2x2Echo) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlaceObject rejected rubblemaker I can't believe it's not rubble! from {0}", args.Player.Name)); @@ -2278,7 +2278,7 @@ namespace TShockAPI return; } } - else if(args.Player.SelectedItem.type == ItemID.AcornAxe) + else if (args.Player.SelectedItem.type == ItemID.AcornAxe) { if (type != TileID.Saplings) { @@ -2457,7 +2457,7 @@ namespace TShockAPI if (args.NewPosition.X > Main.maxTilesX || args.NewPosition.X < 0 || args.NewPosition.Y > Main.maxTilesY || args.NewPosition.Y < 0) { - TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerPortalTeleport rejected teleport out of bounds from {0}"), args.Player.Name); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerPortalTeleport rejected teleport out of bounds from {0}", args.Player.Name)); args.Handled = true; return; } @@ -2465,7 +2465,7 @@ namespace TShockAPI //May as well reject teleport attempts if the player is being throttled if (args.Player.IsBeingDisabled() || args.Player.IsBouncerThrottled()) { - TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerPortalTeleport rejected disabled/throttled from {0}"), args.Player.Name); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerPortalTeleport rejected disabled/throttled from {0}", args.Player.Name)); args.Handled = true; return; } diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 08f30faa..f7319d24 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -677,7 +677,7 @@ namespace TShockAPI call(new CommandArgs(cmdText, player, args)); return true; } - player.SendErrorMessage(GetString($"Invalid command entered. Type {0}help for a list of valid commands.", Specifier)); + player.SendErrorMessage(GetString("Invalid command entered. Type {0}help for a list of valid commands.", Specifier)); return true; } foreach (Command cmd in cmds) @@ -1052,7 +1052,7 @@ namespace TShockAPI { args.Player.SendErrorMessage(GetString("Sorry, {0} was already taken by another person.", account.Name)); args.Player.SendErrorMessage(GetString("Please try a different username.")); - TShock.Log.ConsoleInfo(GetString("{0} attempted to register for the account {1} but it was already taken."), args.Player.Name, account.Name); + TShock.Log.ConsoleInfo(GetString("{0} attempted to register for the account {1} but it was already taken.", args.Player.Name, account.Name)); } } catch (UserAccountManagerException ex) @@ -1355,14 +1355,14 @@ namespace TShockAPI } //TODO: Translate. The string interpolation here will break the text extractor. - args.Player.SendMessage("TShock Ban Help", Color.White); - args.Player.SendMessage("Available Ban commands:", Color.White); - args.Player.SendMessage($"ban {"add".Color(Utils.RedHighlight)} [Flags]", Color.White); - args.Player.SendMessage($"ban {"del".Color(Utils.RedHighlight)} ", Color.White); - args.Player.SendMessage($"ban {"list".Color(Utils.RedHighlight)}", Color.White); - args.Player.SendMessage($"ban {"details".Color(Utils.RedHighlight)} ", Color.White); - args.Player.SendMessage($"Quick usage: {"ban add".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)} \"Griefing\"", Color.White); - args.Player.SendMessage($"For more info, use {"ban help".Color(Utils.BoldHighlight)} {"command".Color(Utils.RedHighlight)} or {"ban help".Color(Utils.BoldHighlight)} {"examples".Color(Utils.RedHighlight)}", Color.White); + args.Player.SendMessage(GetString("TShock Ban Help"), Color.White); + args.Player.SendMessage(GetString("Available Ban commands:"), Color.White); + args.Player.SendMessage(GetString($"ban {"add".Color(Utils.RedHighlight)} [Flags]"), Color.White); + args.Player.SendMessage(GetString($"ban {"del".Color(Utils.RedHighlight)} "), Color.White); + args.Player.SendMessage(GetString($"ban {"list".Color(Utils.RedHighlight)}"), Color.White); + args.Player.SendMessage(GetString($"ban {"details".Color(Utils.RedHighlight)} "), Color.White); + args.Player.SendMessage(GetString($"Quick usage: {"ban add".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)} \"Griefing\""), Color.White); + args.Player.SendMessage(GetString($"For more info, use {"ban help".Color(Utils.BoldHighlight)} {"command".Color(Utils.RedHighlight)} or {"ban help".Color(Utils.BoldHighlight)} {"examples".Color(Utils.RedHighlight)}"), Color.White); } void MoreHelp(string cmd) @@ -1370,40 +1370,40 @@ namespace TShockAPI switch (cmd) { case "add": - args.Player.SendMessage("", Color.White); - args.Player.SendMessage("Ban Add Syntax", Color.White); - args.Player.SendMessage($"{"ban add".Color(Utils.BoldHighlight)} <{"Target".Color(Utils.RedHighlight)}> [{"Reason".Color(Utils.BoldHighlight)}] [{"Duration".Color(Utils.PinkHighlight)}] [{"Flags".Color(Utils.GreenHighlight)}]", Color.White); - args.Player.SendMessage($"- {"Duration".Color(Utils.PinkHighlight)}: uses the format {"0d0m0s".Color(Utils.PinkHighlight)} to determine the length of the ban.", Color.White); - args.Player.SendMessage($" Eg a value of {"10d30m0s".Color(Utils.PinkHighlight)} would represent 10 days, 30 minutes, 0 seconds.", Color.White); - args.Player.SendMessage($" If no duration is provided, the ban will be permanent.", Color.White); - args.Player.SendMessage($"- {"Flags".Color(Utils.GreenHighlight)}: -a (account name), -u (UUID), -n (character name), -ip (IP address), -e (exact, {"Target".Color(Utils.RedHighlight)} will be treated as identifier)", Color.White); - args.Player.SendMessage($" Unless {"-e".Color(Utils.GreenHighlight)} is passed to the command, {"Target".Color(Utils.RedHighlight)} is assumed to be a player or player index", Color.White); - args.Player.SendMessage($" If no {"Flags".Color(Utils.GreenHighlight)} are specified, the command uses {"-a -u -ip".Color(Utils.GreenHighlight)} by default.", Color.White); - args.Player.SendMessage($"Example usage: {"ban add".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)} {"\"Cheating\"".Color(Utils.BoldHighlight)} {"10d30m0s".Color(Utils.PinkHighlight)} {"-a -u -ip".Color(Utils.GreenHighlight)}", Color.White); + args.Player.SendMessage(GetString(""), Color.White); + args.Player.SendMessage(GetString("Ban Add Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"ban add".Color(Utils.BoldHighlight)} <{"Target".Color(Utils.RedHighlight)}> [{"Reason".Color(Utils.BoldHighlight)}] [{"Duration".Color(Utils.PinkHighlight)}] [{"Flags".Color(Utils.GreenHighlight)}]"), Color.White); + args.Player.SendMessage(GetString($"- {"Duration".Color(Utils.PinkHighlight)}: uses the format {"0d0m0s".Color(Utils.PinkHighlight)} to determine the length of the ban."), Color.White); + args.Player.SendMessage(GetString($" Eg a value of {"10d30m0s".Color(Utils.PinkHighlight)} would represent 10 days, 30 minutes, 0 seconds."), Color.White); + args.Player.SendMessage(GetString($" If no duration is provided, the ban will be permanent."), Color.White); + args.Player.SendMessage(GetString($"- {"Flags".Color(Utils.GreenHighlight)}: -a (account name), -u (UUID), -n (character name), -ip (IP address), -e (exact, {"Target".Color(Utils.RedHighlight)} will be treated as identifier)"), Color.White); + args.Player.SendMessage(GetString($" Unless {"-e".Color(Utils.GreenHighlight)} is passed to the command, {"Target".Color(Utils.RedHighlight)} is assumed to be a player or player index"), Color.White); + args.Player.SendMessage(GetString($" If no {"Flags".Color(Utils.GreenHighlight)} are specified, the command uses {"-a -u -ip".Color(Utils.GreenHighlight)} by default."), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"ban add".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)} {"\"Cheating\"".Color(Utils.BoldHighlight)} {"10d30m0s".Color(Utils.PinkHighlight)} {"-a -u -ip".Color(Utils.GreenHighlight)}"), Color.White); break; case "del": - args.Player.SendMessage("", Color.White); - args.Player.SendMessage("Ban Del Syntax", Color.White); - args.Player.SendMessage($"{"ban del".Color(Utils.BoldHighlight)} <{"Ticket Number".Color(Utils.RedHighlight)}>", Color.White); - args.Player.SendMessage($"- {"Ticket Numbers".Color(Utils.RedHighlight)} are provided when you add a ban, and can also be viewed with the {"ban list".Color(Utils.BoldHighlight)} command.", Color.White); - args.Player.SendMessage($"Example usage: {"ban del".Color(Utils.BoldHighlight)} {"12345".Color(Utils.RedHighlight)}", Color.White); + args.Player.SendMessage(GetString(""), Color.White); + args.Player.SendMessage(GetString("Ban Del Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"ban del".Color(Utils.BoldHighlight)} <{"Ticket Number".Color(Utils.RedHighlight)}>"), Color.White); + args.Player.SendMessage(GetString($"- {"Ticket Numbers".Color(Utils.RedHighlight)} are provided when you add a ban, and can also be viewed with the {"ban list".Color(Utils.BoldHighlight)} command."), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"ban del".Color(Utils.BoldHighlight)} {"12345".Color(Utils.RedHighlight)}"), Color.White); break; case "list": - args.Player.SendMessage("", Color.White); - args.Player.SendMessage("Ban List Syntax", Color.White); - args.Player.SendMessage($"{"ban list".Color(Utils.BoldHighlight)} [{"Page".Color(Utils.PinkHighlight)}]", Color.White); - args.Player.SendMessage("- Lists active bans. Color trends towards green as the ban approaches expiration", Color.White); - args.Player.SendMessage($"Example usage: {"ban list".Color(Utils.BoldHighlight)}", Color.White); + args.Player.SendMessage(GetString(""), Color.White); + args.Player.SendMessage(GetString("Ban List Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"ban list".Color(Utils.BoldHighlight)} [{"Page".Color(Utils.PinkHighlight)}]"), Color.White); + args.Player.SendMessage(GetString("- Lists active bans. Color trends towards green as the ban approaches expiration"), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"ban list".Color(Utils.BoldHighlight)}"), Color.White); break; case "details": - args.Player.SendMessage("", Color.White); - args.Player.SendMessage("Ban Details Syntax", Color.White); - args.Player.SendMessage($"{"ban details".Color(Utils.BoldHighlight)} <{"Ticket Number".Color(Utils.RedHighlight)}>", Color.White); - args.Player.SendMessage($"- {"Ticket Numbers".Color(Utils.RedHighlight)} are provided when you add a ban, and can be found with the {"ban list".Color(Utils.BoldHighlight)} command.", Color.White); - args.Player.SendMessage($"Example usage: {"ban details".Color(Utils.BoldHighlight)} {"12345".Color(Utils.RedHighlight)}", Color.White); + args.Player.SendMessage(GetString(""), Color.White); + args.Player.SendMessage(GetString("Ban Details Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"ban details".Color(Utils.BoldHighlight)} <{"Ticket Number".Color(Utils.RedHighlight)}>"), Color.White); + args.Player.SendMessage(GetString($"- {"Ticket Numbers".Color(Utils.RedHighlight)} are provided when you add a ban, and can be found with the {"ban list".Color(Utils.BoldHighlight)} command."), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"ban details".Color(Utils.BoldHighlight)} {"12345".Color(Utils.RedHighlight)}"), Color.White); break; case "identifiers": @@ -1416,46 +1416,46 @@ namespace TShockAPI var idents = from ident in Identifier.Available select $"{ident.Color(Utils.RedHighlight)} - {ident.Description}"; - args.Player.SendMessage("", Color.White); + args.Player.SendMessage(GetString(""), Color.White); PaginationTools.SendPage(args.Player, pageNumber, idents.ToList(), new PaginationTools.Settings { - HeaderFormat = "Available identifiers ({0}/{1}):", - FooterFormat = "Type {0}ban help identifiers {{0}} for more.".SFormat(Specifier), - NothingToDisplayString = "There are currently no available identifiers.", + HeaderFormat = GetString("Available identifiers ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}ban help identifiers {{0}} for more.", Specifier), + NothingToDisplayString = GetString("There are currently no available identifiers."), HeaderTextColor = Color.White, LineTextColor = Color.White }); break; case "examples": - args.Player.SendMessage("", Color.White); - args.Player.SendMessage("Ban Usage Examples", Color.White); - args.Player.SendMessage("- Ban an offline player by account name", Color.White); - args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} \"{"acc:".Color(Utils.RedHighlight)}{args.Player.Account.Color(Utils.RedHighlight)}\" {"\"Multiple accounts are not allowed\"".Color(Utils.BoldHighlight)} {"-e".Color(Utils.GreenHighlight)} (Permanently bans this account name)", Color.White); - args.Player.SendMessage("- Ban an offline player by IP address", Color.White); - args.Player.SendMessage($" {Specifier}{"ai".Color(Utils.BoldHighlight)} \"{args.Player.Account.Color(Utils.RedHighlight)}\" (Find the IP associated with the offline target's account)", Color.White); - args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"ip:".Color(Utils.RedHighlight)}{args.Player.IP.Color(Utils.RedHighlight)} {"\"Griefing\"".Color(Utils.BoldHighlight)} {"-e".Color(Utils.GreenHighlight)} (Permanently bans this IP address)", Color.White); - args.Player.SendMessage($"- Ban an online player by index (Useful for hard to type names)", Color.White); - args.Player.SendMessage($" {Specifier}{"who".Color(Utils.BoldHighlight)} {"-i".Color(Utils.GreenHighlight)} (Find the player index for the target)", Color.White); - args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"tsi:".Color(Utils.RedHighlight)}{args.Player.Index.Color(Utils.RedHighlight)} {"\"Trolling\"".Color(Utils.BoldHighlight)} {"-a -u -ip".Color(Utils.GreenHighlight)} (Permanently bans the online player by Account, UUID, and IP)", Color.White); + args.Player.SendMessage(GetString(""), Color.White); + args.Player.SendMessage(GetString("Ban Usage Examples"), Color.White); + args.Player.SendMessage(GetString("- Ban an offline player by account name"), Color.White); + args.Player.SendMessage(GetString($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} \"{"acc:".Color(Utils.RedHighlight)}{args.Player.Account.Color(Utils.RedHighlight)}\" {"\"Multiple accounts are not allowed\"".Color(Utils.BoldHighlight)} {"-e".Color(Utils.GreenHighlight)} (Permanently bans this account name)"), Color.White); + args.Player.SendMessage(GetString("- Ban an offline player by IP address"), Color.White); + args.Player.SendMessage(GetString($" {Specifier}{"ai".Color(Utils.BoldHighlight)} \"{args.Player.Account.Color(Utils.RedHighlight)}\" (Find the IP associated with the offline target's account)"), Color.White); + args.Player.SendMessage(GetString($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"ip:".Color(Utils.RedHighlight)}{args.Player.IP.Color(Utils.RedHighlight)} {"\"Griefing\"".Color(Utils.BoldHighlight)} {"-e".Color(Utils.GreenHighlight)} (Permanently bans this IP address)"), Color.White); + args.Player.SendMessage(GetString($"- Ban an online player by index (Useful for hard to type names)"), Color.White); + args.Player.SendMessage(GetString($" {Specifier}{"who".Color(Utils.BoldHighlight)} {"-i".Color(Utils.GreenHighlight)} (Find the player index for the target)"), Color.White); + args.Player.SendMessage(GetString($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"tsi:".Color(Utils.RedHighlight)}{args.Player.Index.Color(Utils.RedHighlight)} {"\"Trolling\"".Color(Utils.BoldHighlight)} {"-a -u -ip".Color(Utils.GreenHighlight)} (Permanently bans the online player by Account, UUID, and IP)"), Color.White); // Ban by account ID when? break; default: - args.Player.SendMessage($"Unknown ban command. Try {"ban help".Color(Utils.BoldHighlight)} {"add".Color(Utils.RedHighlight)}, {"del".Color(Utils.RedHighlight)}, {"list".Color(Utils.RedHighlight)}, {"details".Color(Utils.RedHighlight)}, {"identifiers".Color(Utils.RedHighlight)}, or {"examples".Color(Utils.RedHighlight)}.", Color.White); break; + args.Player.SendMessage(GetString($"Unknown ban command. Try {"ban help".Color(Utils.BoldHighlight)} {"add".Color(Utils.RedHighlight)}, {"del".Color(Utils.RedHighlight)}, {"list".Color(Utils.RedHighlight)}, {"details".Color(Utils.RedHighlight)}, {"identifiers".Color(Utils.RedHighlight)}, or {"examples".Color(Utils.RedHighlight)}."), Color.White); break; } } void DisplayBanDetails(Ban ban) { - args.Player.SendMessage($"{"Ban Details".Color(Utils.BoldHighlight)} - Ticket Number: {ban.TicketNumber.Color(Utils.GreenHighlight)}", Color.White); - args.Player.SendMessage($"{"Identifier:".Color(Utils.BoldHighlight)} {ban.Identifier}", Color.White); - args.Player.SendMessage($"{"Reason:".Color(Utils.BoldHighlight)} {ban.Reason}", Color.White); - args.Player.SendMessage($"{"Banned by:".Color(Utils.BoldHighlight)} {ban.BanningUser.Color(Utils.GreenHighlight)} on {ban.BanDateTime.ToString("yyyy/MM/dd").Color(Utils.RedHighlight)} ({ban.GetPrettyTimeSinceBanString().Color(Utils.YellowHighlight)} ago)", Color.White); + args.Player.SendMessage(GetString($"{"Ban Details".Color(Utils.BoldHighlight)} - Ticket Number: {ban.TicketNumber.Color(Utils.GreenHighlight)}"), Color.White); + args.Player.SendMessage(GetString($"{"Identifier:".Color(Utils.BoldHighlight)} {ban.Identifier}"), Color.White); + args.Player.SendMessage(GetString($"{"Reason:".Color(Utils.BoldHighlight)} {ban.Reason}"), Color.White); + args.Player.SendMessage(GetString($"{"Banned by:".Color(Utils.BoldHighlight)} {ban.BanningUser.Color(Utils.GreenHighlight)} on {ban.BanDateTime.ToString("yyyy/MM/dd").Color(Utils.RedHighlight)} ({ban.GetPrettyTimeSinceBanString().Color(Utils.YellowHighlight)} ago)"), Color.White); if (ban.ExpirationDateTime < DateTime.UtcNow) { - args.Player.SendMessage($"{"Ban expired:".Color(Utils.BoldHighlight)} {ban.ExpirationDateTime.ToString("yyyy/MM/dd").Color(Utils.RedHighlight)} ({ban.GetPrettyExpirationString().Color(Utils.YellowHighlight)} ago)", Color.White); + args.Player.SendMessage(GetString($"{"Ban expired:".Color(Utils.BoldHighlight)} {ban.ExpirationDateTime.ToString("yyyy/MM/dd").Color(Utils.RedHighlight)} ({ban.GetPrettyExpirationString().Color(Utils.YellowHighlight)} ago)"), Color.White); } else { @@ -1469,7 +1469,7 @@ namespace TShockAPI remaining = GetString($"{ban.GetPrettyExpirationString().Color(Utils.YellowHighlight)} remaining."); } - args.Player.SendMessage($"{"Ban expires:".Color(Utils.BoldHighlight)} {ban.ExpirationDateTime.ToString("yyyy/MM/dd").Color(Utils.RedHighlight)} ({remaining})", Color.White); + args.Player.SendMessage(GetString($"{"Ban expires:".Color(Utils.BoldHighlight)} {ban.ExpirationDateTime.ToString("yyyy/MM/dd").Color(Utils.RedHighlight)} ({remaining})"), Color.White); } } @@ -1493,7 +1493,7 @@ namespace TShockAPI { if (!args.Parameters.TryGetValue(1, out string target)) { - args.Player.SendMessage($"Invalid Ban Add syntax. Refer to {"ban help add".Color(Utils.BoldHighlight)} for details on how to use the {"ban add".Color(Utils.BoldHighlight)} command", Color.White); + args.Player.SendMessage(GetString($"Invalid Ban Add syntax. Refer to {"ban help add".Color(Utils.BoldHighlight)} for details on how to use the {"ban add".Color(Utils.BoldHighlight)} command"), Color.White); return; } @@ -1609,13 +1609,13 @@ namespace TShockAPI { if (!args.Parameters.TryGetValue(1, out string target)) { - args.Player.SendMessage($"Invalid Ban Del syntax. Refer to {"ban help del".Color(Utils.BoldHighlight)} for details on how to use the {"ban del".Color(Utils.BoldHighlight)} command", Color.White); + args.Player.SendMessage(GetString($"Invalid Ban Del syntax. Refer to {"ban help del".Color(Utils.BoldHighlight)} for details on how to use the {"ban del".Color(Utils.BoldHighlight)} command"), Color.White); return; } if (!int.TryParse(target, out int banId)) { - args.Player.SendMessage($"Invalid Ticket Number. Refer to {"ban help del".Color(Utils.BoldHighlight)} for details on how to use the {"ban del".Color(Utils.BoldHighlight)} command", Color.White); + args.Player.SendMessage(GetString($"Invalid Ticket Number. Refer to {"ban help del".Color(Utils.BoldHighlight)} for details on how to use the {"ban del".Color(Utils.BoldHighlight)} command"), Color.White); return; } @@ -1646,21 +1646,21 @@ namespace TShockAPI if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out int pageNumber)) { - args.Player.SendMessage($"Invalid Ban List syntax. Refer to {"ban help list".Color(Utils.BoldHighlight)} for details on how to use the {"ban list".Color(Utils.BoldHighlight)} command", Color.White); + args.Player.SendMessage(GetString($"Invalid Ban List syntax. Refer to {"ban help list".Color(Utils.BoldHighlight)} for details on how to use the {"ban list".Color(Utils.BoldHighlight)} command"), Color.White); return; } var bans = from ban in TShock.Bans.Bans - where ban.Value.ExpirationDateTime > DateTime.UtcNow - orderby ban.Value.ExpirationDateTime ascending - select $"[{ban.Key.Color(Utils.GreenHighlight)}] {ban.Value.Identifier.Color(PickColorForBan(ban.Value))}"; + where ban.Value.ExpirationDateTime > DateTime.UtcNow + orderby ban.Value.ExpirationDateTime ascending + select $"[{ban.Key.Color(Utils.GreenHighlight)}] {ban.Value.Identifier.Color(PickColorForBan(ban.Value))}"; PaginationTools.SendPage(args.Player, pageNumber, bans.ToList(), new PaginationTools.Settings { - HeaderFormat = "Bans ({0}/{1}):", - FooterFormat = "Type {0}ban list {{0}} for more.".SFormat(Specifier), - NothingToDisplayString = "There are currently no active bans." + HeaderFormat = GetString("Bans ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}ban list {{0}} for more.", Specifier), + NothingToDisplayString = GetString("There are currently no active bans.") }); } @@ -1668,13 +1668,13 @@ namespace TShockAPI { if (!args.Parameters.TryGetValue(1, out string target)) { - args.Player.SendMessage($"Invalid Ban Details syntax. Refer to {"ban help details".Color(Utils.BoldHighlight)} for details on how to use the {"ban details".Color(Utils.BoldHighlight)} command", Color.White); + args.Player.SendMessage(GetString($"Invalid Ban Details syntax. Refer to {"ban help details".Color(Utils.BoldHighlight)} for details on how to use the {"ban details".Color(Utils.BoldHighlight)} command"), Color.White); return; } if (!int.TryParse(target, out int banId)) { - args.Player.SendMessage($"Invalid Ticket Number. Refer to {"ban help details".Color(Utils.BoldHighlight)} for details on how to use the {"ban details".Color(Utils.BoldHighlight)} command", Color.White); + args.Player.SendMessage(GetString($"Invalid Ticket Number. Refer to {"ban help details".Color(Utils.BoldHighlight)} for details on how to use the {"ban details".Color(Utils.BoldHighlight)} command"), Color.White); return; } @@ -1817,7 +1817,7 @@ namespace TShockAPI } else if (players.Count == 0) { - args.Player.SendErrorMessage(GetString("No player was found matching '{0}'."), args.Parameters[0]); + args.Player.SendErrorMessage(GetString("No player was found matching '{0}'.", args.Parameters[0])); return; } else @@ -1866,9 +1866,17 @@ namespace TShockAPI TShock.Config.Settings.ForceHalloween = !TShock.Config.Settings.ForceHalloween; Main.checkHalloween(); if (args.Silent) - args.Player.SendInfoMessage("{0}abled halloween mode!", (TShock.Config.Settings.ForceHalloween ? "en" : "dis")); + if (TShock.Config.Settings.ForceHalloween) + args.Player.SendInfoMessage(GetString("Enabled halloween mode.")); + else + args.Player.SendInfoMessage(GetString("Disabled halloween mode.")); else - TSPlayer.All.SendInfoMessage("{0} {1}abled halloween mode!", args.Player.Name, (TShock.Config.Settings.ForceHalloween ? "en" : "dis")); + { + if (TShock.Config.Settings.ForceHalloween) + TSPlayer.All.SendInfoMessage(GetString("{0} enabled halloween mode.", args.Player.Name)); + else + TSPlayer.All.SendInfoMessage(GetString("{0} disabled halloween mode.", args.Player.Name)); + } } private static void ForceXmas(CommandArgs args) @@ -1878,16 +1886,16 @@ namespace TShockAPI if (args.Silent) { if (TShock.Config.Settings.ForceXmas) - args.Player.SendInfoMessage("Enabled xmas mode!"); + args.Player.SendInfoMessage(GetString("Enabled xmas mode.")); else - args.Player.SendInfoMessage("Disabled xmas mode!"); + args.Player.SendInfoMessage(GetString("Disabled xmas mode.")); } else { if (TShock.Config.Settings.ForceXmas) - TSPlayer.All.SendInfoMessage("{0} enabled xmas mode!", args.Player.Name); + TSPlayer.All.SendInfoMessage(GetString("{0} enabled xmas mode.", args.Player.Name)); else - TSPlayer.All.SendInfoMessage("{0} disabled xmas mode!", args.Player.Name); + TSPlayer.All.SendInfoMessage(GetString("{0} disabled xmas mode.", args.Player.Name)); } } @@ -2074,8 +2082,8 @@ namespace TShockAPI args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(restUsers), new PaginationTools.Settings { NothingToDisplayString = GetString("There are currently no active REST users."), - HeaderFormat = "Active REST Users ({0}/{1}):", - FooterFormat = "Type {0}rest listusers {{0}} for more.".SFormat(Specifier) + HeaderFormat = GetString("Active REST Users ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}rest listusers {{0}} for more.", Specifier) } ); @@ -2807,11 +2815,11 @@ namespace TShockAPI if (args.Silent) { - args.Player.SendSuccessMessage(GetString("You spawned {0} {1} time(s).", spawnName, amount)); + args.Player.SendSuccessMessage(GetPluralString("You spawned {0} {1} time.", "You spawned {0} {1} times.", amount, spawnName, amount)); } else { - TSPlayer.All.SendSuccessMessage(GetString("{0} spawned {1} {2} time(s).", args.Player.Name, spawnName, amount)); + TSPlayer.All.SendSuccessMessage(GetPluralString("{0} spawned {1} {2} time.", "{0} spawned {1} {2} times.", amount, args.Player.Name, spawnName, amount)); } } @@ -2854,11 +2862,11 @@ namespace TShockAPI TSPlayer.Server.SpawnNPC(npc.netID, npc.FullName, amount, args.Player.TileX, args.Player.TileY, 50, 20); if (args.Silent) { - args.Player.SendSuccessMessage(GetString("Spawned {0} {1} time(s).", npc.FullName, amount)); + args.Player.SendSuccessMessage(GetPluralString("Spawned {0} {1} time.", "Spawned {0} {1} times.", amount, npc.FullName, amount)); } else { - TSPlayer.All.SendSuccessMessage(GetString("{0} has spawned {1} {2} time(s).", args.Player.Name, npc.FullName, amount)); + TSPlayer.All.SendSuccessMessage(GetPluralString("{0} has spawned {1} {2} time.", "{0} has spawned {1} {2} times.", amount, args.Player.Name, npc.FullName, amount)); } } else if (npc.type == 113) @@ -3094,13 +3102,13 @@ namespace TShockAPI var englishName = EnglishLanguage.GetNpcNameById(npc.netID); if (string.Equals(npc.FullName, npcStr, StringComparison.InvariantCultureIgnoreCase) || - string.Equals(englishName, npcStr, StringComparison.InvariantCultureIgnoreCase)) + string.Equals(englishName, npcStr, StringComparison.InvariantCultureIgnoreCase)) { matches = new List { npc }; break; } if (npc.FullName.ToLowerInvariant().StartsWith(npcStr.ToLowerInvariant()) || - englishName?.StartsWith(npcStr, StringComparison.InvariantCultureIgnoreCase) == true) + englishName?.StartsWith(npcStr, StringComparison.InvariantCultureIgnoreCase) == true) matches.Add(npc); } @@ -3208,8 +3216,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(warpNames), new PaginationTools.Settings { - HeaderFormat = "Warps ({0}/{1}):", - FooterFormat = "Type {0}warp list {{0}} for more.".SFormat(Specifier), + HeaderFormat = GetString("Warps ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}warp list {{0}} for more.", Specifier), NothingToDisplayString = GetString("There are currently no warps defined.") }); #endregion @@ -3230,7 +3238,7 @@ namespace TShockAPI } else { - args.Player.SendErrorMessage(GetString("Warp {warpName} already exists.")); + args.Player.SendErrorMessage(GetString($"Warp {warpName} already exists.")); } } else @@ -3266,9 +3274,9 @@ namespace TShockAPI if (TShock.Warps.Hide(args.Parameters[1], state)) { if (state) - args.Player.SendSuccessMessage(GetString("Warp {warpName} is now private.")); + args.Player.SendSuccessMessage(GetString("Warp {0} is now private.", warpName)); else - args.Player.SendSuccessMessage(GetString("Warp {warpName} is now public.")); + args.Player.SendSuccessMessage(GetString("Warp {0} is now public.", warpName)); } else args.Player.SendErrorMessage(GetString("Could not find specified warp.")); @@ -3434,8 +3442,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, lines, new PaginationTools.Settings { - HeaderFormat = "Group Sub-Commands ({0}/{1}):", - FooterFormat = "Type {0}group help {{0}} for more sub-commands.".SFormat(Specifier) + HeaderFormat = GetString("Group Sub-Commands ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}group help {{0}} for more sub-commands.", Specifier) } ); } @@ -3725,8 +3733,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(groupNames), new PaginationTools.Settings { - HeaderFormat = "Groups ({0}/{1}):", - FooterFormat = "Type {0}group list {{0}} for more.".SFormat(Specifier) + HeaderFormat = GetString("Groups ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}group list {{0}} for more.", Specifier) }); } #endregion @@ -3754,16 +3762,16 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(permissions), new PaginationTools.Settings { - HeaderFormat = "Permissions for " + grp.Name + " ({0}/{1}):", - FooterFormat = "Type {0}group listperm {1} {{0}} for more.".SFormat(Specifier, grp.Name), - NothingToDisplayString = "There are currently no permissions for " + grp.Name + "." + HeaderFormat = GetString("Permissions for {0} ({{0}}/{{1}}):", grp.Name), + FooterFormat = GetString("Type {0}group listperm {1} {{0}} for more.", Specifier, grp.Name), + NothingToDisplayString = GetString($"There are currently no permissions for {grp.Name}.") }); } #endregion return; default: args.Player.SendErrorMessage(GetString("Invalid subcommand! Type {0}group help for more information on valid commands.", Specifier)); - return; + return; } } #endregion Group Management @@ -3821,7 +3829,7 @@ namespace TShockAPI } // This returns the localized name to the player, not the item as it was stored. - args.Player.SendSuccessMessage(GetString($"Banned ${items[0].Name}.")); + args.Player.SendSuccessMessage(GetString($"Banned {items[0].Name}.")); } } #endregion @@ -3961,8 +3969,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, lines, new PaginationTools.Settings { - HeaderFormat = "Item Ban Sub-Commands ({0}/{1}):", - FooterFormat = "Type {0}itemban help {{0}} for more sub-commands.".SFormat(Specifier) + HeaderFormat = GetString("Item Ban Sub-Commands ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}itemban help {{0}} for more sub-commands.", Specifier) } ); } @@ -3979,8 +3987,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(itemNames), new PaginationTools.Settings { - HeaderFormat = "Item bans ({0}/{1}):", - FooterFormat = "Type {0}itemban list {{0}} for more.".SFormat(Specifier), + HeaderFormat = GetString("Item bans ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}itemban list {{0}} for more.", Specifier), NothingToDisplayString = GetString("There are currently no banned items.") }); } @@ -4139,8 +4147,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, lines, new PaginationTools.Settings { - HeaderFormat = "Projectile Ban Sub-Commands ({0}/{1}):", - FooterFormat = "Type {0}projban help {{0}} for more sub-commands.".SFormat(Specifier) + HeaderFormat = GetString("Projectile Ban Sub-Commands ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}projban help {{0}} for more sub-commands.", Specifier) } ); } @@ -4157,9 +4165,9 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(projectileIds), new PaginationTools.Settings { - HeaderFormat = "Projectile bans ({0}/{1}):", - FooterFormat = "Type {0}projban list {{0}} for more.".SFormat(Specifier), - NothingToDisplayString = "There are currently no banned projectiles." + HeaderFormat = GetString("Projectile bans ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}projban list {{0}} for more.", Specifier), + NothingToDisplayString = GetString("There are currently no banned projectiles.") }); } #endregion @@ -4263,7 +4271,7 @@ namespace TShockAPI { if (args.Parameters.Count != 3) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}tileban disallow .", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}tileban disallow .", Specifier)); return; } @@ -4315,8 +4323,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, lines, new PaginationTools.Settings { - HeaderFormat = "Tile Ban Sub-Commands ({0}/{1}):", - FooterFormat = "Type {0}tileban help {{0}} for more sub-commands.".SFormat(Specifier) + HeaderFormat = GetString("Tile Ban Sub-Commands ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}tileban help {{0}} for more sub-commands.", Specifier) } ); } @@ -4333,8 +4341,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(tileIds), new PaginationTools.Settings { - HeaderFormat = "Tile bans ({0}/{1}):", - FooterFormat = "Type {0}tileban list {{0}} for more.".SFormat(Specifier), + HeaderFormat = GetString("Tile bans ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}tileban list {{0}} for more.", Specifier), NothingToDisplayString = GetString("There are currently no banned tiles.") }); } @@ -4870,7 +4878,7 @@ namespace TShockAPI { if (TShock.Regions.RemoveGroup(regionName, group)) { - args.Player.SendInfoMessage("Removed group " + group + " from " + regionName); + args.Player.SendInfoMessage(GetString("Removed group {0} from {1}", group, regionName)); } else args.Player.SendErrorMessage(GetString($"Could not find the region {regionName}.")); @@ -4895,8 +4903,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(regionNames), new PaginationTools.Settings { - HeaderFormat = "Regions ({0}/{1}):", - FooterFormat = "Type {0}region list {{0}} for more.".SFormat(Specifier), + HeaderFormat = GetString("Regions ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}region list {{0}} for more.", Specifier), NothingToDisplayString = GetString("There are currently no regions defined.") }); break; @@ -4944,30 +4952,30 @@ namespace TShockAPI return string.Concat("{ID: ", userId, "}"); }); List extraLines = PaginationTools.BuildLinesFromTerms(sharedUsersSelector.Distinct()); - extraLines[0] = "Shared with: " + extraLines[0]; + extraLines[0] = GetString("Shared with: ") + extraLines[0]; lines.AddRange(extraLines); } else { - lines.Add("Region is not shared with any users."); + lines.Add(GetString("Region is not shared with any users.")); } if (region.AllowedGroups.Count > 0) { List extraLines = PaginationTools.BuildLinesFromTerms(region.AllowedGroups.Distinct()); - extraLines[0] = "Shared with groups: " + extraLines[0]; + extraLines[0] = GetString("Shared with groups: ") + extraLines[0]; lines.AddRange(extraLines); } else { - lines.Add("Region is not shared with any groups."); + lines.Add(GetString("Region is not shared with any groups.")); } PaginationTools.SendPage( args.Player, pageNumber, lines, new PaginationTools.Settings { - HeaderFormat = string.Format("Information About Region \"{0}\" ({{0}}/{{1}}):", region.Name), - FooterFormat = string.Format("Type {0}region info {1} {{0}} for more information.", Specifier, regionName) + HeaderFormat = GetString("Information About Region \"{0}\" ({{0}}/{{1}}):", region.Name), + FooterFormat = GetString("Type {0}region info {1} {{0}} for more information.", Specifier, regionName) } ); @@ -5022,15 +5030,15 @@ namespace TShockAPI if (int.TryParse(args.Parameters[2], out z)) { if (TShock.Regions.SetZ(regionName, z)) - args.Player.SendInfoMessage("Region's z is now " + z); + args.Player.SendInfoMessage(GetString("Region's z is now {0}", z)); else - args.Player.SendErrorMessage("Could not find specified region"); + args.Player.SendErrorMessage(GetString("Could not find specified region")); } else - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}region z <#>", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}region z <#>", Specifier)); } else - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}region z <#>", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}region z <#>", Specifier)); break; } case "resize": @@ -5075,21 +5083,21 @@ namespace TShockAPI int.TryParse(args.Parameters[3], out addAmount); if (TShock.Regions.ResizeRegion(args.Parameters[1], addAmount, direction)) { - args.Player.SendInfoMessage("Region Resized Successfully!"); + args.Player.SendInfoMessage(GetString("Region Resized Successfully!")); TShock.Regions.Reload(); } else - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}region resize ", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}region resize ", Specifier)); } else - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}region resize ", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}region resize ", Specifier)); break; } case "rename": { if (args.Parameters.Count != 3) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}region rename ", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}region rename ", Specifier)); break; } else @@ -5099,7 +5107,7 @@ namespace TShockAPI if (oldName == newName) { - args.Player.SendErrorMessage("Error: both names are the same."); + args.Player.SendErrorMessage(GetString("Error: both names are the same.")); break; } @@ -5107,7 +5115,7 @@ namespace TShockAPI if (oldRegion == null) { - args.Player.SendErrorMessage("Invalid region \"{0}\".", oldName); + args.Player.SendErrorMessage(GetString("Invalid region \"{0}\".", oldName)); break; } @@ -5115,17 +5123,17 @@ namespace TShockAPI if (newRegion != null) { - args.Player.SendErrorMessage("Region \"{0}\" already exists.", newName); + args.Player.SendErrorMessage(GetString("Region \"{0}\" already exists.", newName)); break; } - if(TShock.Regions.RenameRegion(oldName, newName)) + if (TShock.Regions.RenameRegion(oldName, newName)) { - args.Player.SendInfoMessage("Region renamed successfully!"); + args.Player.SendInfoMessage(GetString("Region renamed successfully!")); } else { - args.Player.SendErrorMessage("Failed to rename the region."); + args.Player.SendErrorMessage(GetString("Failed to rename the region.")); } } break; @@ -5134,12 +5142,12 @@ namespace TShockAPI { if (!args.Player.HasPermission(Permissions.tp)) { - args.Player.SendErrorMessage("You do not have permission to teleport."); + args.Player.SendErrorMessage(GetString("You do not have permission to teleport.")); break; } if (args.Parameters.Count <= 1) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}region tp .", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}region tp .", Specifier)); break; } @@ -5147,7 +5155,7 @@ namespace TShockAPI Region region = TShock.Regions.GetRegionByName(regionName); if (region == null) { - args.Player.SendErrorMessage("Region \"{0}\" does not exist.", regionName); + args.Player.SendErrorMessage(GetString("Region \"{0}\" does not exist.", regionName)); break; } @@ -5165,31 +5173,31 @@ namespace TShockAPI return; List lines = new List { - "set <1/2> - Sets the temporary region points.", - "clear - Clears the temporary region points.", - "define - Defines the region with the given name.", - "delete - Deletes the given region.", - "name [-u][-z][-p] - Shows the name of the region at the given point.", - "rename - Renames the given region.", - "list - Lists all regions.", - "resize - Resizes a region.", - "allow - Allows a user to a region.", - "remove - Removes a user from a region.", - "allowg - Allows a user group to a region.", - "removeg - Removes a user group from a region.", - "info [-d] - Displays several information about the given region.", - "protect - Sets whether the tiles inside the region are protected or not.", - "z <#> - Sets the z-order of the region.", + GetString("set <1/2> - Sets the temporary region points."), + GetString("clear - Clears the temporary region points."), + GetString("define - Defines the region with the given name."), + GetString("delete - Deletes the given region."), + GetString("name [-u][-z][-p] - Shows the name of the region at the given point."), + GetString("rename - Renames the given region."), + GetString("list - Lists all regions."), + GetString("resize - Resizes a region."), + GetString("allow - Allows a user to a region."), + GetString("remove - Removes a user from a region."), + GetString("allowg - Allows a user group to a region."), + GetString("removeg - Removes a user group from a region."), + GetString("info [-d] - Displays several information about the given region."), + GetString("protect - Sets whether the tiles inside the region are protected or not."), + GetString("z <#> - Sets the z-order of the region."), }; if (args.Player.HasPermission(Permissions.tp)) - lines.Add("tp - Teleports you to the given region's center."); + lines.Add(GetString("tp - Teleports you to the given region's center.")); PaginationTools.SendPage( args.Player, pageNumber, lines, new PaginationTools.Settings { - HeaderFormat = "Available Region Sub-Commands ({0}/{1}):", - FooterFormat = "Type {0}region {{0}} for more sub-commands.".SFormat(Specifier) + HeaderFormat = GetString("Available Region Sub-Commands ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}region {{0}} for more sub-commands.", Specifier) } ); break; @@ -5204,13 +5212,13 @@ namespace TShockAPI private static void ToggleAntiBuild(CommandArgs args) { TShock.Config.Settings.DisableBuild = !TShock.Config.Settings.DisableBuild; - TSPlayer.All.SendSuccessMessage(string.Format("Anti-build is now {0}.", (TShock.Config.Settings.DisableBuild ? "on" : "off"))); + TSPlayer.All.SendSuccessMessage(TShock.Config.Settings.DisableBuild ? GetString("Anti-build is now on.") : GetString("Anti-build is now off.")); } private static void ProtectSpawn(CommandArgs args) { TShock.Config.Settings.SpawnProtection = !TShock.Config.Settings.SpawnProtection; - TSPlayer.All.SendSuccessMessage(string.Format("Spawn is now {0}.", (TShock.Config.Settings.SpawnProtection ? "protected" : "open"))); + TSPlayer.All.SendSuccessMessage(TShock.Config.Settings.SpawnProtection ? GetString("Spawn is now protected.") : GetString("Spawn is now open.")); } #endregion World Protection Commands @@ -5221,7 +5229,7 @@ namespace TShockAPI { if (args.Parameters.Count > 1) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}help ", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}help ", Specifier)); return; } @@ -5240,8 +5248,8 @@ namespace TShockAPI PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(cmdNames), new PaginationTools.Settings { - HeaderFormat = "Commands ({0}/{1}):", - FooterFormat = "Type {0}help {{0}} for more.".SFormat(Specifier) + HeaderFormat = GetString("Commands ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}help {{0}} for more.", Specifier) }); } else @@ -5255,16 +5263,16 @@ namespace TShockAPI Command command = ChatCommands.Find(c => c.Names.Contains(commandName)); if (command == null) { - args.Player.SendErrorMessage("Invalid command."); + args.Player.SendErrorMessage(GetString("Invalid command.")); return; } if (!command.CanRun(args.Player)) { - args.Player.SendErrorMessage("You do not have access to this command."); + args.Player.SendErrorMessage(GetString("You do not have access to this command.")); return; } - args.Player.SendSuccessMessage("{0}{1} help: ", Specifier, command.Name); + args.Player.SendSuccessMessage(GetString("{0}{1} help: ", Specifier, command.Name)); if (command.HelpDesc == null) { args.Player.SendInfoMessage(command.HelpText); @@ -5279,7 +5287,7 @@ namespace TShockAPI private static void GetVersion(CommandArgs args) { - args.Player.SendMessage($"TShock: {TShock.VersionNum.Color(Utils.BoldHighlight)} {TShock.VersionCodename.Color(Utils.RedHighlight)}.", Color.White); + args.Player.SendMessage(GetString($"TShock: {TShock.VersionNum.Color(Utils.BoldHighlight)} {TShock.VersionCodename.Color(Utils.RedHighlight)}."), Color.White); } private static void ListConnectedPlayers(CommandArgs args) @@ -5307,24 +5315,24 @@ namespace TShockAPI } if (invalidUsage) { - args.Player.SendMessage($"List Online Players Syntax", Color.White); - args.Player.SendMessage($"{"playing".Color(Utils.BoldHighlight)} {"[-i]".Color(Utils.RedHighlight)} {"[page]".Color(Utils.GreenHighlight)}", Color.White); - args.Player.SendMessage($"Command aliases: {"playing".Color(Utils.GreenHighlight)}, {"online".Color(Utils.GreenHighlight)}, {"who".Color(Utils.GreenHighlight)}", Color.White); - args.Player.SendMessage($"Example usage: {"who".Color(Utils.BoldHighlight)} {"-i".Color(Utils.RedHighlight)}", Color.White); + args.Player.SendMessage(GetString($"List Online Players Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"playing".Color(Utils.BoldHighlight)} {"[-i]".Color(Utils.RedHighlight)} {"[page]".Color(Utils.GreenHighlight)}"), Color.White); + args.Player.SendMessage(GetString($"Command aliases: {"playing".Color(Utils.GreenHighlight)}, {"online".Color(Utils.GreenHighlight)}, {"who".Color(Utils.GreenHighlight)}"), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"who".Color(Utils.BoldHighlight)} {"-i".Color(Utils.RedHighlight)}"), Color.White); return; } if (displayIdsRequested && !args.Player.HasPermission(Permissions.seeids)) { - args.Player.SendErrorMessage("You do not have permission to see player IDs."); + args.Player.SendErrorMessage(GetString("You do not have permission to see player IDs.")); return; } if (TShock.Utils.GetActivePlayerCount() == 0) { - args.Player.SendMessage("There are currently no players online.", Color.White); + args.Player.SendMessage(GetString("There are currently no players online."), Color.White); return; } - args.Player.SendMessage($"Online Players ({TShock.Utils.GetActivePlayerCount().Color(Utils.GreenHighlight)}/{TShock.Config.Settings.MaxSlots})", Color.White); + args.Player.SendMessage(GetString($"Online Players ({TShock.Utils.GetActivePlayerCount().Color(Utils.GreenHighlight)}/{TShock.Config.Settings.MaxSlots})"), Color.White); var players = new List(); @@ -5333,7 +5341,7 @@ namespace TShockAPI if (ply != null && ply.Active) { if (displayIdsRequested) - players.Add($"{ply.Name} (Index: {ply.Index}{(ply.Account != null ? ", Account ID: " + ply.Account.ID : "")})"); + players.Add(GetString($"{ply.Name} (Index: {ply.Index}{(ply.Account != null ? ", Account ID: " + ply.Account.ID : "")})")); else players.Add(ply.Name); } @@ -5344,7 +5352,7 @@ namespace TShockAPI new PaginationTools.Settings { IncludeHeader = false, - FooterFormat = $"Type {Specifier}who {(displayIdsRequested ? "-i" : string.Empty)}{Specifier} for more." + FooterFormat = GetString($"Type {Specifier}who {(displayIdsRequested ? "-i" : string.Empty)}{Specifier} for more.") } ); } @@ -5353,8 +5361,8 @@ namespace TShockAPI { if (TShock.SetupToken == 0) { - args.Player.SendWarningMessage("The initial setup system is disabled. This incident has been logged."); - args.Player.SendWarningMessage("If you are locked out of all admin accounts, ask for help on https://tshock.co/"); + args.Player.SendWarningMessage(GetString("The initial setup system is disabled. This incident has been logged.")); + args.Player.SendWarningMessage(GetString("If you are locked out of all admin accounts, ask for help on https://tshock.co/")); TShock.Log.Warn("{0} attempted to use the initial setup system even though it's disabled.", args.Player.IP); return; } @@ -5362,9 +5370,9 @@ namespace TShockAPI // If the user account is already logged in, turn off the setup system if (args.Player.IsLoggedIn && args.Player.tempGroup == null) { - args.Player.SendSuccessMessage("Your new account has been verified, and the {0}setup system has been turned off.", Specifier); - args.Player.SendSuccessMessage("Share your server, talk with admins, and chill on GitHub & Discord. -- https://tshock.co/"); - args.Player.SendSuccessMessage("Thank you for using TShock for Terraria!"); + args.Player.SendSuccessMessage(GetString("Your new account has been verified, and the {0}setup system has been turned off.", Specifier)); + args.Player.SendSuccessMessage(GetString("Share your server, talk with admins, and chill on GitHub & Discord. -- https://tshock.co/")); + args.Player.SendSuccessMessage(GetString("Thank you for using TShock for Terraria!")); FileTools.CreateFile(Path.Combine(TShock.SavePath, "setup.lock")); File.Delete(Path.Combine(TShock.SavePath, "setup-code.txt")); TShock.SetupToken = 0; @@ -5373,14 +5381,14 @@ namespace TShockAPI if (args.Parameters.Count == 0) { - args.Player.SendErrorMessage("You must provide a setup code!"); + args.Player.SendErrorMessage(GetString("You must provide a setup code!")); return; } int givenCode; if (!Int32.TryParse(args.Parameters[0], out givenCode) || givenCode != TShock.SetupToken) { - args.Player.SendErrorMessage("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."); return; } @@ -5388,12 +5396,12 @@ namespace TShockAPI if (args.Player.Group.Name != "superadmin") args.Player.tempGroup = new SuperAdminGroup(); - args.Player.SendInfoMessage("Temporary system access has been given to you, so you can run one command."); - args.Player.SendWarningMessage("Please use the following to create a permanent account for you."); - args.Player.SendWarningMessage("{0}user add owner", Specifier); - args.Player.SendInfoMessage("Creates: with the password as part of the owner group."); - args.Player.SendInfoMessage("Please use {0}login after this process.", Specifier); - args.Player.SendWarningMessage("If you understand, please {0}login now, and then type {0}setup.", Specifier); + args.Player.SendInfoMessage(GetString("Temporary system access has been given to you, so you can run one command.")); + args.Player.SendWarningMessage(GetString("Please use the following to create a permanent account for you.")); + args.Player.SendWarningMessage(GetString("{0}user add owner", Specifier)); + args.Player.SendInfoMessage(GetString("Creates: with the password as part of the owner group.")); + args.Player.SendInfoMessage(GetString("Please use {0}login after this process.", Specifier)); + args.Player.SendWarningMessage(GetString("If you understand, please {0}login now, and then type {0}setup.", Specifier)); return; } @@ -5401,29 +5409,29 @@ namespace TShockAPI { if (args.Parameters.Count == 0) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}me ", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}me ", Specifier)); return; } if (args.Player.mute) - args.Player.SendErrorMessage("You are muted."); + args.Player.SendErrorMessage(GetString("You are muted.")); else - TSPlayer.All.SendMessage(string.Format("*{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) { if (args.Parameters.Count == 0) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}p ", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}p ", Specifier)); return; } int playerTeam = args.Player.Team; if (args.Player.mute) - args.Player.SendErrorMessage("You are muted."); + args.Player.SendErrorMessage(GetString("You are muted.")); else if (playerTeam != 0) { - string msg = string.Format("<{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) { if (player != null && player.Active && player.Team == playerTeam) @@ -5431,24 +5439,24 @@ namespace TShockAPI } } else - args.Player.SendErrorMessage("You are not in a party!"); + args.Player.SendErrorMessage(GetString("You are not in a party!")); } private static void Mute(CommandArgs args) { if (args.Parameters.Count < 1) { - args.Player.SendMessage("Mute Syntax", Color.White); - args.Player.SendMessage($"{"mute".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> [{"reason".Color(Utils.GreenHighlight)}]", Color.White); - args.Player.SendMessage($"Example usage: {"mute".Color(Utils.BoldHighlight)} \"{args.Player.Name.Color(Utils.RedHighlight)}\" \"{"No swearing on my Christian server".Color(Utils.GreenHighlight)}\"", Color.White); - args.Player.SendMessage($"To mute a player without broadcasting to chat, use the command with {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}", Color.White); + args.Player.SendMessage(GetString("Mute Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"mute".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> [{"reason".Color(Utils.GreenHighlight)}]"), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"mute".Color(Utils.BoldHighlight)} \"{args.Player.Name.Color(Utils.RedHighlight)}\" \"{"No swearing on my Christian server".Color(Utils.GreenHighlight)}\""), Color.White); + args.Player.SendMessage(GetString($"To mute a player without broadcasting to chat, use the command with {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}"), Color.White); return; } var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) { - args.Player.SendErrorMessage($"Could not find any players named \"{args.Parameters[0]}\""); + args.Player.SendErrorMessage(GetString($"Could not find any players named \"{args.Parameters[0]}\"")); } else if (players.Count > 1) { @@ -5456,28 +5464,28 @@ namespace TShockAPI } else if (players[0].HasPermission(Permissions.mute)) { - args.Player.SendErrorMessage($"You do not have permission to mute {players[0].Name}"); + args.Player.SendErrorMessage(GetString($"You do not have permission to mute {players[0].Name}")); } else if (players[0].mute) { var plr = players[0]; plr.mute = false; if (args.Silent) - args.Player.SendSuccessMessage($"You have unmuted {plr.Name}."); + args.Player.SendSuccessMessage(GetString($"You have unmuted {plr.Name}.")); else - TSPlayer.All.SendInfoMessage($"{args.Player.Name} has unmuted {plr.Name}."); + TSPlayer.All.SendInfoMessage(GetString($"{args.Player.Name} has unmuted {plr.Name}.")); } else { - string reason = "No reason specified."; + string reason = GetString("No reason specified."); if (args.Parameters.Count > 1) reason = String.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1); var plr = players[0]; plr.mute = true; if (args.Silent) - args.Player.SendSuccessMessage($"You have muted {plr.Name} for {reason}"); + args.Player.SendSuccessMessage(GetString($"You have muted {plr.Name} for {reason}")); else - TSPlayer.All.SendInfoMessage($"{args.Player.Name} has muted {plr.Name} for {reason}."); + TSPlayer.All.SendInfoMessage(GetString($"{args.Player.Name} has muted {plr.Name} for {reason}.")); } } @@ -5495,15 +5503,15 @@ namespace TShockAPI { if (args.Parameters.Count < 2) { - args.Player.SendMessage("Whisper Syntax", Color.White); - args.Player.SendMessage($"{"whisper".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"message".Color(Utils.PinkHighlight)}>", Color.White); - args.Player.SendMessage($"Example usage: {"w".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)} {"We're no strangers to love, you know the rules, and so do I.".Color(Utils.PinkHighlight)}", Color.White); + args.Player.SendMessage(GetString("Whisper Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"whisper".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"message".Color(Utils.PinkHighlight)}>"), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"w".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)} {"We're no strangers to love, you know the rules, and so do I.".Color(Utils.PinkHighlight)}"), Color.White); return; } var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) { - args.Player.SendErrorMessage($"Could not find any player named \"{args.Parameters[0]}\""); + args.Player.SendErrorMessage(GetString($"Could not find any player named \"{args.Parameters[0]}\"")); } else if (players.Count > 1) { @@ -5511,24 +5519,24 @@ namespace TShockAPI } else if (args.Player.mute) { - args.Player.SendErrorMessage("You are muted."); + args.Player.SendErrorMessage(GetString("You are muted.")); } else { var plr = players[0]; if (plr == args.Player) { - args.Player.SendErrorMessage("You cannot whisper to yourself."); + args.Player.SendErrorMessage(GetString("You cannot whisper to yourself.")); return; } if (!plr.AcceptingWhispers) { - args.Player.SendErrorMessage($"{plr.Name} is not accepting whispers."); + args.Player.SendErrorMessage(GetString($"{plr.Name} is not accepting whispers.")); return; } var msg = string.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1); - plr.SendMessage($" {msg}", Color.MediumPurple); - args.Player.SendMessage($" {msg}", Color.MediumPurple); + plr.SendMessage(GetString($" {msg}"), Color.MediumPurple); + args.Player.SendMessage(GetString($" {msg}"), Color.MediumPurple); plr.LastWhisper = args.Player; args.Player.LastWhisper = plr; } @@ -5537,35 +5545,38 @@ namespace TShockAPI private static void Wallow(CommandArgs args) { args.Player.AcceptingWhispers = !args.Player.AcceptingWhispers; - args.Player.SendSuccessMessage($"You {(args.Player.AcceptingWhispers ? "may now" : "will no longer")} receive whispers from other players."); - args.Player.SendMessage($"You can use {Specifier.Color(Utils.GreenHighlight)}{"wa".Color(Utils.GreenHighlight)} to toggle this setting.", Color.White); + if (args.Player.AcceptingWhispers) + args.Player.SendInfoMessage(GetString("You may now receive whispers from other players.")); + else + args.Player.SendInfoMessage(GetString("You will no longer receive whispers from other players.")); + args.Player.SendMessage(GetString($"You can use {Specifier.Color(Utils.GreenHighlight)}{"wa".Color(Utils.GreenHighlight)} to toggle this setting."), Color.White); } private static void Reply(CommandArgs args) { if (args.Player.mute) { - args.Player.SendErrorMessage("You are muted."); + args.Player.SendErrorMessage(GetString("You are muted.")); } else if (args.Player.LastWhisper != null && args.Player.LastWhisper.Active) { if (!args.Player.LastWhisper.AcceptingWhispers) { - args.Player.SendErrorMessage($"{args.Player.LastWhisper.Name} is not accepting whispers."); + args.Player.SendErrorMessage(GetString($"{args.Player.LastWhisper.Name} is not accepting whispers.")); return; } var msg = string.Join(" ", args.Parameters); - args.Player.LastWhisper.SendMessage($" {msg}", Color.MediumPurple); - args.Player.SendMessage($" {msg}", Color.MediumPurple); + args.Player.LastWhisper.SendMessage(GetString($" {msg}"), Color.MediumPurple); + args.Player.SendMessage(GetString($" {msg}"), Color.MediumPurple); } else if (args.Player.LastWhisper != null) { - args.Player.SendErrorMessage($"{args.Player.LastWhisper.Name} is offline and cannot receive your reply."); + args.Player.SendErrorMessage(GetString($"{args.Player.LastWhisper.Name} is offline and cannot receive your reply.")); } else { - args.Player.SendErrorMessage("You haven't previously received any whispers."); - args.Player.SendMessage($"You can use {Specifier.Color(Utils.GreenHighlight)}{"w".Color(Utils.GreenHighlight)} to whisper to other players.", Color.White); + args.Player.SendErrorMessage(GetString("You haven't previously received any whispers.")); + args.Player.SendMessage(GetString($"You can use {Specifier.Color(Utils.GreenHighlight)}{"w".Color(Utils.GreenHighlight)} to whisper to other players."), Color.White); } } @@ -5573,10 +5584,10 @@ namespace TShockAPI { if (args.Parameters.Count != 2) { - args.Player.SendMessage("Annoy Syntax", Color.White); - args.Player.SendMessage($"{"annoy".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"seconds".Color(Utils.PinkHighlight)}>", Color.White); - args.Player.SendMessage($"Example usage: {"annoy".Color(Utils.BoldHighlight)} <{args.Player.Name.Color(Utils.RedHighlight)}> <{"10".Color(Utils.PinkHighlight)}>", Color.White); - args.Player.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to annoy a player silently.", Color.White); + args.Player.SendMessage(GetString("Annoy Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"annoy".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"seconds".Color(Utils.PinkHighlight)}>"), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"annoy".Color(Utils.BoldHighlight)} <{args.Player.Name.Color(Utils.RedHighlight)}> <{"10".Color(Utils.PinkHighlight)}>"), Color.White); + args.Player.SendMessage(GetString($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to annoy a player silently."), Color.White); return; } int annoy = 5; @@ -5584,15 +5595,15 @@ namespace TShockAPI var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) - args.Player.SendErrorMessage($"Could not find any player named \"{args.Parameters[0]}\""); + args.Player.SendErrorMessage(GetString($"Could not find any player named \"{args.Parameters[0]}\"")); else if (players.Count > 1) args.Player.SendMultipleMatchError(players.Select(p => p.Name)); else { var ply = players[0]; - args.Player.SendSuccessMessage($"Annoying {ply.Name} for {annoy} seconds."); + args.Player.SendSuccessMessage(GetString($"Annoying {ply.Name} for {annoy} seconds.")); if (!args.Silent) - ply.SendMessage("You are now being annoyed.", Color.LightGoldenrodYellow); + ply.SendMessage(GetString("You are now being annoyed."), Color.LightGoldenrodYellow); new Thread(ply.Whoopie).Start(annoy); } } @@ -5601,15 +5612,15 @@ namespace TShockAPI { if (args.Parameters.Count != 1) { - args.Player.SendMessage("Rocket Syntax", Color.White); - args.Player.SendMessage($"{"rocket".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}>", Color.White); - args.Player.SendMessage($"Example usage: {"rocket".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)}", Color.White); - args.Player.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to rocket a player silently.", Color.White); + args.Player.SendMessage(GetString("Rocket Syntax"), Color.White); + args.Player.SendMessage(GetString($"{"rocket".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}>"), Color.White); + args.Player.SendMessage(GetString($"Example usage: {"rocket".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)}"), Color.White); + args.Player.SendMessage(GetString($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to rocket a player silently."), Color.White); return; } var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) - args.Player.SendErrorMessage($"Could not find any player named \"{args.Parameters[0]}\""); + args.Player.SendErrorMessage(GetString($"Could not find any player named \"{args.Parameters[0]}\"")); else if (players.Count > 1) args.Player.SendMultipleMatchError(players.Select(p => p.Name)); else @@ -5623,21 +5634,30 @@ namespace TShockAPI if (!args.Silent) { - TSPlayer.All.SendInfoMessage($"{args.Player.Name} has launched {(target == args.Player ? (args.Player.TPlayer.Male ? "himself" : "herself") : target.Name)} into space."); + if (target == args.Player) + if (args.Player.TPlayer.Male) + TSPlayer.All.SendInfoMessage(GetString($"{args.Player.Name} has launched himself into space.")); + else + TSPlayer.All.SendInfoMessage(GetString($"{args.Player.Name} has launched herself into space.")); + else + TSPlayer.All.SendInfoMessage(GetString($"{args.Player.Name} has launched {target.Name} into space.")); return; } if (target == args.Player) - args.Player.SendSuccessMessage("You have launched yourself into space."); + args.Player.SendSuccessMessage(GetString("You have launched yourself into space.")); else - args.Player.SendSuccessMessage($"You have launched {target.Name} into space."); + args.Player.SendSuccessMessage(GetString($"You have launched {target.Name} into space.")); } else { if (!Main.ServerSideCharacter) - args.Player.SendErrorMessage("SSC must be enabled to use this command."); + args.Player.SendErrorMessage(GetString("SSC must be enabled to use this command.")); else - args.Player.SendErrorMessage($"Unable to rocket {target.Name} because {(target.TPlayer.Male ? "he" : "she")} is not logged in."); + if (target.TPlayer.Male) + args.Player.SendErrorMessage(GetString($"Unable to launch {target.Name} because he is not logged in.")); + else + args.Player.SendErrorMessage(GetString($"Unable to launch {target.Name} because she is not logged in.")); } } } @@ -5648,15 +5668,15 @@ namespace TShockAPI if (args.Parameters.Count < 1) { // firework [R|G|B|Y] - user.SendMessage("Firework Syntax", Color.White); - user.SendMessage($"{"firework".Color(Utils.CyanHighlight)} <{"player".Color(Utils.PinkHighlight)}> [{"R".Color(Utils.RedHighlight)}|{"G".Color(Utils.GreenHighlight)}|{"B".Color(Utils.BoldHighlight)}|{"Y".Color(Utils.YellowHighlight)}]", Color.White); - user.SendMessage($"Example usage: {"firework".Color(Utils.CyanHighlight)} {user.Name.Color(Utils.PinkHighlight)} {"R".Color(Utils.RedHighlight)}", Color.White); - user.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to launch a firework silently.", Color.White); + user.SendMessage(GetString("Firework Syntax"), Color.White); + user.SendMessage(GetString($"{"firework".Color(Utils.CyanHighlight)} <{"player".Color(Utils.PinkHighlight)}> [{"R".Color(Utils.RedHighlight)}|{"G".Color(Utils.GreenHighlight)}|{"B".Color(Utils.BoldHighlight)}|{"Y".Color(Utils.YellowHighlight)}]"), Color.White); + user.SendMessage(GetString($"Example usage: {"firework".Color(Utils.CyanHighlight)} {user.Name.Color(Utils.PinkHighlight)} {"R".Color(Utils.RedHighlight)}"), Color.White); + user.SendMessage(GetString($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to launch a firework silently."), Color.White); return; } var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) - user.SendErrorMessage($"Could not find any player named \"{args.Parameters[0]}\""); + user.SendErrorMessage(GetString($"Could not find any player named \"{args.Parameters[0]}\"")); else if (players.Count > 1) user.SendMultipleMatchError(players.Select(p => p.Name)); else @@ -5706,9 +5726,12 @@ namespace TShockAPI var target = players[0]; int p = Projectile.NewProjectile(Projectile.GetNoneSource(), target.TPlayer.position.X, target.TPlayer.position.Y - 64f, 0f, -8f, type, 0, 0); Main.projectile[p].Kill(); - args.Player.SendSuccessMessage($"You launched fireworks on {(target == user ? "yourself" : target.Name)}."); + if (target == user) + args.Player.SendSuccessMessage(GetString("You launched fireworks on yourself.")); + else + args.Player.SendSuccessMessage(GetString($"You launched fireworks on {target.Name}.")); if (!args.Silent && target != user) - target.SendSuccessMessage($"{user.Name} launched fireworks on you."); + target.SendSuccessMessage(GetString($"{user.Name} launched fireworks on you.")); } } @@ -5716,14 +5739,14 @@ namespace TShockAPI { if (args.Parameters.Count < 1) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}aliases ", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}aliases ", Specifier)); return; } string givenCommandName = string.Join(" ", args.Parameters); if (string.IsNullOrWhiteSpace(givenCommandName)) { - args.Player.SendErrorMessage("Please enter a proper command name or alias."); + args.Player.SendErrorMessage(GetString("Please enter a proper command name or alias.")); return; } @@ -5738,29 +5761,29 @@ namespace TShockAPI { if (matchingCommand.Names.Count > 1) args.Player.SendInfoMessage( - "Aliases of {0}{1}: {0}{2}", Specifier, matchingCommand.Name, string.Join(", {0}".SFormat(Specifier), matchingCommand.Names.Skip(1))); + GetString("Aliases of {0}{1}: {0}{2}", Specifier, matchingCommand.Name, string.Join($", {Specifier}", matchingCommand.Names.Skip(1)))); else - args.Player.SendInfoMessage("{0}{1} defines no aliases.", Specifier, matchingCommand.Name); + args.Player.SendInfoMessage(GetString("{0}{1} defines no aliases.", Specifier, matchingCommand.Name)); didMatch = true; } if (!didMatch) - args.Player.SendErrorMessage("No command or command alias matching \"{0}\" found.", givenCommandName); + args.Player.SendErrorMessage(GetString("No command or command alias matching \"{0}\" found.", givenCommandName)); } private static void CreateDumps(CommandArgs args) { TShock.Utils.DumpPermissionMatrix("PermissionMatrix.txt"); TShock.Utils.Dump(false); - args.Player.SendSuccessMessage("Your reference dumps have been created in the server folder."); + args.Player.SendSuccessMessage(GetString("Your reference dumps have been created in the server folder.")); return; } private static void SyncLocalArea(CommandArgs args) { args.Player.SendTileSquareCentered(args.Player.TileX, args.Player.TileY, 32); - args.Player.SendWarningMessage("Sync'd!"); + args.Player.SendWarningMessage(GetString("Sync'd!")); return; } @@ -5776,11 +5799,11 @@ namespace TShockAPI if (args.Parameters.Count != 1 && args.Parameters.Count != 2) { - user.SendMessage("Clear Syntax", Color.White); - user.SendMessage($"{"clear".Color(Utils.BoldHighlight)} <{"item".Color(Utils.GreenHighlight)}|{"npc".Color(Utils.RedHighlight)}|{"projectile".Color(Utils.YellowHighlight)}> [{"radius".Color(Utils.PinkHighlight)}]", Color.White); - user.SendMessage($"Example usage: {"clear".Color(Utils.BoldHighlight)} {"i".Color(Utils.RedHighlight)} {"10000".Color(Utils.GreenHighlight)}", Color.White); user.SendMessage($"Example usage: {"clear".Color(Utils.BoldHighlight)} {"item".Color(Utils.RedHighlight)} {"10000".Color(Utils.GreenHighlight)}", Color.White); - user.SendMessage($"If you do not specify a radius, it will use a default radius of {radius} around your character.", Color.White); - user.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to execute this command silently.", Color.White); + user.SendMessage(GetString("Clear Syntax"), Color.White); + user.SendMessage(GetString($"{"clear".Color(Utils.BoldHighlight)} <{"item".Color(Utils.GreenHighlight)}|{"npc".Color(Utils.RedHighlight)}|{"projectile".Color(Utils.YellowHighlight)}> [{"radius".Color(Utils.PinkHighlight)}]"), Color.White); + user.SendMessage(GetString($"Example usage: {"clear".Color(Utils.BoldHighlight)} {"i".Color(Utils.RedHighlight)} {"10000".Color(Utils.GreenHighlight)}"), Color.White); user.SendMessage(GetString($"Example usage: {"clear".Color(Utils.BoldHighlight)} {"item".Color(Utils.RedHighlight)} {"10000".Color(Utils.GreenHighlight)}"), Color.White); + user.SendMessage(GetString($"If you do not specify a radius, it will use a default radius of {radius} around your character."), Color.White); + user.SendMessage(GetString($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to execute this command silently."), Color.White); return; } @@ -5788,7 +5811,7 @@ namespace TShockAPI { if (!int.TryParse(args.Parameters[1], out radius) || radius <= 0) { - user.SendErrorMessage($"\"{args.Parameters[1]}\" is not a valid radius."); + user.SendErrorMessage(GetString($"\"{args.Parameters[1]}\" is not a valid radius.")); return; } } @@ -5813,9 +5836,9 @@ namespace TShockAPI } } if (args.Silent) - user.SendSuccessMessage($"You deleted {cleared} item{(cleared > 1 ? "s": "")} within a radius of {radius}."); + user.SendSuccessMessage(GetPluralString("You deleted {0} item within a radius of {1}.", "You deleted {0} items within a radius of {1}.", cleared, cleared, radius)); else - everyone.SendInfoMessage($"{user.Name} deleted {cleared} item{(cleared > 1 ? "s" : "")} within a radius of {radius}."); + everyone.SendInfoMessage(GetPluralString("{0} deleted {1} item within a radius of {2}.", "{0} deleted {1} items within a radius of {2}.", cleared, user.Name, cleared, radius)); } break; case "npc": @@ -5837,9 +5860,9 @@ namespace TShockAPI } } if (args.Silent) - user.SendSuccessMessage($"You deleted {cleared} NPC{(cleared > 1 ? "s" : "")} within a radius of {radius}."); + user.SendSuccessMessage(GetPluralString("You deleted {0} NPC within a radius of {1}.", "You deleted {0} NPCs within a radius of {1}.", cleared, cleared, radius)); else - everyone.SendInfoMessage($"{user.Name} deleted {cleared} NPC{(cleared > 1 ? "s" : "")} within a radius of {radius}."); + everyone.SendInfoMessage(GetPluralString("{0} deleted {1} NPC within a radius of {2}.", "{0} deleted {1} NPCs within a radius of {2}.", cleared, user.Name, cleared, radius)); } break; case "proj": @@ -5862,13 +5885,13 @@ namespace TShockAPI } } if (args.Silent) - user.SendSuccessMessage($"You deleted {cleared} projectile{(cleared > 1 ? "s" : "")} within a radius of {radius}."); + user.SendSuccessMessage(GetPluralString("You deleted {0} projectile within a radius of {1}.", "You deleted {0} projectiles within a radius of {1}.", cleared, cleared, radius)); else - everyone.SendInfoMessage($"{user.Name} deleted {cleared} projectile{(cleared > 1 ? "s" : "")} within a radius of {radius}"); + everyone.SendInfoMessage(GetPluralString("{0} deleted {1} projectile within a radius of {2}.", "{0} deleted {1} projectiles within a radius of {2}.", cleared, user.Name, cleared, radius)); } break; default: - user.SendErrorMessage($"\"{args.Parameters[0]}\" is not a valid clear option."); + user.SendErrorMessage(GetString($"\"{args.Parameters[0]}\" is not a valid clear option.")); break; } } @@ -5879,10 +5902,10 @@ namespace TShockAPI var user = args.Player; if (args.Parameters.Count < 1) { - user.SendMessage("Kill syntax and example", Color.White); - user.SendMessage($"{"kill".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}>", Color.White); - user.SendMessage($"Example usage: {"kill".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)}", Color.White); - user.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to execute this command silently.", Color.White); + user.SendMessage(GetString("Kill syntax and example"), Color.White); + user.SendMessage(GetString($"{"kill".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}>"), Color.White); + user.SendMessage(GetString($"Example usage: {"kill".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)}"), Color.White); + user.SendMessage(GetString($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to execute this command silently."), Color.White); return; } @@ -5890,7 +5913,7 @@ namespace TShockAPI var players = TSPlayer.FindByNameOrID(targetName); if (players.Count == 0) - user.SendErrorMessage($"Could not find any player named \"{targetName}\"."); + user.SendErrorMessage(GetString($"Could not find any player named \"{targetName}\".")); else if (players.Count > 1) user.SendMultipleMatchError(players.Select(p => p.Name)); else @@ -5899,13 +5922,19 @@ namespace TShockAPI if (target.Dead) { - user.SendErrorMessage($"{(target == user ? "You" : target.Name)} {(target == user ? "are" : "is")} already dead!"); + if (target == user) + user.SendErrorMessage(GetString("You are already dead!")); + else + user.SendErrorMessage(GetString($"{target.Name} is already dead!")); return; } target.KillPlayer(); - user.SendSuccessMessage($"You just killed {(target == user ? "yourself" : target.Name)}!"); + if (target == user) + user.SendSuccessMessage(GetString("You just killed yourself!")); + else + user.SendSuccessMessage(GetString($"You just killed {target.Name}!")); if (!args.Silent && target != user) - target.SendErrorMessage($"{user.Name} just killed you!"); + target.SendErrorMessage(GetString($"{user.Name} just killed you!")); } } @@ -5913,7 +5942,7 @@ namespace TShockAPI { if (!args.Player.RealPlayer && args.Parameters.Count == 0) { - args.Player.SendErrorMessage("You can't respawn the server console!"); + args.Player.SendErrorMessage(GetString("You can't respawn the server console!")); return; } TSPlayer playerToRespawn; @@ -5921,14 +5950,14 @@ namespace TShockAPI { if (!args.Player.HasPermission(Permissions.respawnother)) { - args.Player.SendErrorMessage("You do not have permission to respawn another player."); + args.Player.SendErrorMessage(GetString("You do not have permission to respawn another player.")); return; } string plStr = String.Join(" ", args.Parameters); var players = TSPlayer.FindByNameOrID(plStr); if (players.Count == 0) { - args.Player.SendErrorMessage($"Could not find any player named \"{plStr}\""); + args.Player.SendErrorMessage(GetString($"Could not find any player named \"{plStr}\"")); return; } if (players.Count > 1) @@ -5943,19 +5972,22 @@ namespace TShockAPI if (!playerToRespawn.Dead) { - args.Player.SendErrorMessage($"{(playerToRespawn == args.Player ? "You" : playerToRespawn.Name)} {(playerToRespawn == args.Player ? "are" : "is")} not dead."); + if (playerToRespawn == args.Player) + args.Player.SendErrorMessage(GetString("You are not dead!")); + else + args.Player.SendErrorMessage(GetString($"{playerToRespawn.Name} is not dead!")); return; } playerToRespawn.Spawn(PlayerSpawnContext.ReviveFromDeath); if (playerToRespawn != args.Player) { - args.Player.SendSuccessMessage($"You have respawned {playerToRespawn.Name}"); + args.Player.SendSuccessMessage(GetString($"You have respawned {playerToRespawn.Name}")); if (!args.Silent) - playerToRespawn.SendSuccessMessage($"{args.Player.Name} has respawned you."); + playerToRespawn.SendSuccessMessage(GetString($"{args.Player.Name} has respawned you.")); } else - playerToRespawn.SendSuccessMessage("You have respawned yourself."); + playerToRespawn.SendSuccessMessage(GetString("You have respawned yourself.")); } private static void Butcher(CommandArgs args) @@ -5963,12 +5995,12 @@ namespace TShockAPI var user = args.Player; if (args.Parameters.Count > 1) { - user.SendMessage("Butcher Syntax and Example", Color.White); - user.SendMessage($"{"butcher".Color(Utils.BoldHighlight)} [{"NPC name".Color(Utils.RedHighlight)}|{"ID".Color(Utils.RedHighlight)}]", Color.White); - user.SendMessage($"Example usage: {"butcher".Color(Utils.BoldHighlight)} {"pigron".Color(Utils.RedHighlight)}", Color.White); - user.SendMessage("All alive NPCs (excluding town NPCs) on the server will be killed if you do not input a name or ID.", Color.White); - user.SendMessage($"To get rid of NPCs without making them drop items, use the {"clear".Color(Utils.BoldHighlight)} command instead.", Color.White); - user.SendMessage($"To execute this command silently, use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}", Color.White); + user.SendMessage(GetString("Butcher Syntax and Example"), Color.White); + user.SendMessage(GetString($"{"butcher".Color(Utils.BoldHighlight)} [{"NPC name".Color(Utils.RedHighlight)}|{"ID".Color(Utils.RedHighlight)}]"), Color.White); + user.SendMessage(GetString($"Example usage: {"butcher".Color(Utils.BoldHighlight)} {"pigron".Color(Utils.RedHighlight)}"), Color.White); + user.SendMessage(GetString("All alive NPCs (excluding town NPCs) on the server will be killed if you do not input a name or ID."), Color.White); + user.SendMessage(GetString($"To get rid of NPCs without making them drop items, use the {"clear".Color(Utils.BoldHighlight)} command instead."), Color.White); + user.SendMessage(GetString($"To execute this command silently, use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}"), Color.White); return; } @@ -5979,7 +6011,7 @@ namespace TShockAPI var npcs = TShock.Utils.GetNPCByIdOrName(args.Parameters[0]); if (npcs.Count == 0) { - user.SendErrorMessage($"\"{args.Parameters[0]}\" is not a valid NPC."); + user.SendErrorMessage(GetString($"\"{args.Parameters[0]}\" is not a valid NPC.")); return; } @@ -6002,16 +6034,16 @@ namespace TShockAPI } if (args.Silent) - user.SendSuccessMessage($"You butchered {kills} NPC{(kills > 1 ? "s": "")}."); + user.SendSuccessMessage(GetPluralString("You butchered {0} NPC.", "You butchered {0} NPCs.", kills, kills)); else - TSPlayer.All.SendInfoMessage($"{user.Name} butchered {kills} NPC{(kills > 1 ? "s" : "")}."); + TSPlayer.All.SendInfoMessage(GetPluralString("{0} butchered {1} NPC.", "{0} butchered {1} NPCs.", kills, user.Name, kills)); } private static void Item(CommandArgs args) { if (args.Parameters.Count < 1) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}item [item amount] [prefix id/name]", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}item [item amount] [prefix id/name]", Specifier)); return; } @@ -6036,7 +6068,7 @@ namespace TShockAPI List matchedItems = TShock.Utils.GetItemByIdOrName(itemNameOrId); if (matchedItems.Count == 0) { - args.Player.SendErrorMessage("Invalid item type!"); + args.Player.SendErrorMessage(GetString("Invalid item type!")); return; } else if (matchedItems.Count > 1) @@ -6050,7 +6082,7 @@ namespace TShockAPI } if (item.type < 1 && item.type >= Main.maxItemTypes) { - args.Player.SendErrorMessage("The item type {0} is invalid.", itemNameOrId); + args.Player.SendErrorMessage(GetString("The item type {0} is invalid.", itemNameOrId)); return; } @@ -6076,7 +6108,7 @@ namespace TShockAPI } else if (prefixIds.Count == 0) { - args.Player.SendErrorMessage("No prefix matched \"{0}\".", prefixidOrName); + args.Player.SendErrorMessage(GetString("No prefix matched \"{0}\".", prefixidOrName)); return; } else @@ -6093,16 +6125,16 @@ namespace TShockAPI if (args.Player.GiveItemCheck(item.type, EnglishLanguage.GetItemNameById(item.type), itemAmount, prefixId)) { item.prefix = (byte)prefixId; - args.Player.SendSuccessMessage("Gave {0} {1}(s).", itemAmount, item.AffixName()); + args.Player.SendSuccessMessage(GetPluralString("Gave {0} {1}.", "Gave {0} {1}s.", itemAmount, itemAmount, item.AffixName())); } else { - args.Player.SendErrorMessage("You cannot spawn banned items."); + args.Player.SendErrorMessage(GetString("You cannot spawn banned items.")); } } else { - args.Player.SendErrorMessage("Your inventory seems full."); + args.Player.SendErrorMessage(GetString("Your inventory seems full.")); } } @@ -6110,7 +6142,7 @@ namespace TShockAPI { if (args.Parameters.Count != 2) { - args.Player.SendErrorMessage("Invalid syntax. Proper syntax: {0}renameNPC ", Specifier); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}renameNPC ", Specifier)); return; } int npcId = 0; @@ -6119,7 +6151,7 @@ namespace TShockAPI List npcs = TShock.Utils.GetNPCByIdOrName(args.Parameters[0]); if (npcs.Count == 0) { - args.Player.SendErrorMessage("Invalid mob type!"); + args.Player.SendErrorMessage(GetString("Invalid mob type!")); return; } else if (npcs.Count > 1) @@ -6129,7 +6161,7 @@ namespace TShockAPI } else if (args.Parameters[1].Length > 200) { - args.Player.SendErrorMessage("New name is too large!"); + args.Player.SendErrorMessage(GetString("New name is too large!")); return; } else @@ -6149,11 +6181,11 @@ namespace TShockAPI } if (done > 0) { - TSPlayer.All.SendInfoMessage("{0} renamed the {1}.", args.Player.Name, args.Parameters[0]); + TSPlayer.All.SendInfoMessage(GetString("{0} renamed the {1}.", args.Player.Name, args.Parameters[0])); } else { - args.Player.SendErrorMessage("Could not rename {0}!", args.Parameters[0]); + args.Player.SendErrorMessage(GetString("Could not rename {0}!", args.Parameters[0])); } } @@ -6167,12 +6199,12 @@ namespace TShockAPI } if (args.Parameters[0].Length == 0) { - args.Player.SendErrorMessage("Missing item name/id."); + args.Player.SendErrorMessage(GetString("Missing item name/id.")); return; } if (args.Parameters[1].Length == 0) { - args.Player.SendErrorMessage("Missing player name."); + args.Player.SendErrorMessage(GetString("Missing player name.")); return; } int itemAmount = 0; @@ -6185,7 +6217,7 @@ namespace TShockAPI int.TryParse(args.Parameters[0], out itemAmount); if (items.Count == 0) { - args.Player.SendErrorMessage("Invalid item type!"); + args.Player.SendErrorMessage(GetString("Invalid item type!")); } else if (items.Count > 1) { @@ -6216,7 +6248,7 @@ namespace TShockAPI var players = TSPlayer.FindByNameOrID(plStr); if (players.Count == 0) { - args.Player.SendErrorMessage("Invalid player!"); + args.Player.SendErrorMessage(GetString("Invalid player!")); } else if (players.Count > 1) { @@ -6231,24 +6263,24 @@ namespace TShockAPI itemAmount = item.maxStack; if (plr.GiveItemCheck(item.type, EnglishLanguage.GetItemNameById(item.type), itemAmount, prefix)) { - args.Player.SendSuccessMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount, item.Name)); - plr.SendSuccessMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.Name)); + args.Player.SendSuccessMessage(GetPluralString("Gave {0} {1} {2}.", "Gave {0} {1} {2}s.", itemAmount, plr.Name, itemAmount, item.Name)); + plr.SendSuccessMessage(GetPluralString("{0} gave you {1} {2}.", "{0} gave you {1} {2}s.", itemAmount, args.Player.Name, itemAmount, item.Name)); } else { - args.Player.SendErrorMessage("You cannot spawn banned items."); + args.Player.SendErrorMessage(GetString("You cannot spawn banned items.")); } } else { - args.Player.SendErrorMessage("Player does not have free slots!"); + args.Player.SendErrorMessage(GetString("Player does not have free slots!")); } } } else { - args.Player.SendErrorMessage("Invalid item type!"); + args.Player.SendErrorMessage(GetString("Invalid item type!")); } } } @@ -6260,23 +6292,23 @@ namespace TShockAPI var user = args.Player; if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { - user.SendMessage("Heal Syntax and Example", Color.White); - user.SendMessage($"{"heal".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> [{"amount".Color(Utils.GreenHighlight)}]", Color.White); - user.SendMessage($"Example usage: {"heal".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)} {"100".Color(Utils.GreenHighlight)}", Color.White); - user.SendMessage($"If no amount is specified, it will default to healing the target player by their max HP.", Color.White); - user.SendMessage($"To execute this command silently, use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}", Color.White); + user.SendMessage(GetString("Heal Syntax and Example"), Color.White); + user.SendMessage(GetString($"{"heal".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> [{"amount".Color(Utils.GreenHighlight)}]"), Color.White); + user.SendMessage(GetString($"Example usage: {"heal".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)} {"100".Color(Utils.GreenHighlight)}"), Color.White); + user.SendMessage(GetString($"If no amount is specified, it will default to healing the target player by their max HP."), Color.White); + user.SendMessage(GetString($"To execute this command silently, use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}"), Color.White); return; } if (args.Parameters[0].Length == 0) { - user.SendErrorMessage($"You didn't put a player name."); + user.SendErrorMessage(GetString($"You didn't put a player name.")); return; } string targetName = args.Parameters[0]; var players = TSPlayer.FindByNameOrID(targetName); if (players.Count == 0) - user.SendErrorMessage($"Unable to find any players named \"{targetName}\""); + user.SendErrorMessage(GetString($"Unable to find any players named \"{targetName}\"")); else if (players.Count > 1) user.SendMultipleMatchError(players.Select(p => p.Name)); else @@ -6286,7 +6318,7 @@ namespace TShockAPI if (target.Dead) { - user.SendErrorMessage("You can't heal a dead player!"); + user.SendErrorMessage(GetString("You can't heal a dead player!")); return; } @@ -6297,9 +6329,20 @@ namespace TShockAPI target.Heal(amount); if (args.Silent) - user.SendSuccessMessage($"You healed {(target == user ? "yourself" : target.Name)} for {amount} HP."); + if (target == user) + user.SendSuccessMessage(GetString($"You healed yourself for {amount} HP.")); + else + user.SendSuccessMessage(GetString($"You healed {target.Name} for {amount} HP.")); else - TSPlayer.All.SendInfoMessage($"{user.Name} healed {(target == user ? (target.TPlayer.Male ? "himself" : "herself") : target.Name)} for {amount} HP."); + { + if (target == user) + if (target.TPlayer.Male) + TSPlayer.All.SendInfoMessage(GetString($"{user.Name} healed himself for {amount} HP.")); + else + TSPlayer.All.SendInfoMessage(GetString($"{user.Name} healed herself for {amount} HP.")); + else + TSPlayer.All.SendInfoMessage(GetString($"{user.Name} healed {target.Name} for {amount} HP.")); + } } } @@ -6309,11 +6352,11 @@ namespace TShockAPI var user = args.Player; if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { - user.SendMessage("Buff Syntax and Example", Color.White); - user.SendMessage($"{"buff".Color(Utils.BoldHighlight)} <\"{"buff name".Color(Utils.RedHighlight)}|{"ID".Color(Utils.RedHighlight)}\"> [{"duration".Color(Utils.GreenHighlight)}]", Color.White); - user.SendMessage($"Example usage: {"buff".Color(Utils.BoldHighlight)} \"{"obsidian skin".Color(Utils.RedHighlight)}\" {"-1".Color(Utils.GreenHighlight)}", Color.White); - user.SendMessage($"If you don't specify the duration, it will default to {"60".Color(Utils.GreenHighlight)} seconds.", Color.White); - user.SendMessage($"If you put {"-1".Color(Utils.GreenHighlight)} as the duration, it will use the max possible time of 415 days.", Color.White); + user.SendMessage(GetString("Buff Syntax and Example"), Color.White); + user.SendMessage(GetString($"{"buff".Color(Utils.BoldHighlight)} <\"{"buff name".Color(Utils.RedHighlight)}|{"ID".Color(Utils.RedHighlight)}\"> [{"duration".Color(Utils.GreenHighlight)}]"), Color.White); + user.SendMessage(GetString($"Example usage: {"buff".Color(Utils.BoldHighlight)} \"{"obsidian skin".Color(Utils.RedHighlight)}\" {"-1".Color(Utils.GreenHighlight)}"), Color.White); + user.SendMessage(GetString($"If you don't specify the duration, it will default to {"60".Color(Utils.GreenHighlight)} seconds."), Color.White); + user.SendMessage(GetString($"If you put {"-1".Color(Utils.GreenHighlight)} as the duration, it will use the max possible time of 415 days."), Color.White); return; } @@ -6327,7 +6370,7 @@ namespace TShockAPI if (found.Count == 0) { - user.SendErrorMessage($"Unable to find any buffs named \"{args.Parameters[0]}\""); + user.SendErrorMessage(GetString($"Unable to find any buffs named \"{args.Parameters[0]}\"")); return; } @@ -6348,10 +6391,10 @@ namespace TShockAPI if (time < 0 || time > timeLimit) time = timeLimit; user.SetBuff(id, time * 60); - user.SendSuccessMessage($"You buffed yourself with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds."); + user.SendSuccessMessage(GetString($"You buffed yourself with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds.")); } else - user.SendErrorMessage($"\"{id}\" is not a valid buff ID!"); + user.SendErrorMessage(GetString($"\"{id}\" is not a valid buff ID!")); } private static void GBuff(CommandArgs args) @@ -6359,10 +6402,10 @@ namespace TShockAPI var user = args.Player; if (args.Parameters.Count < 2 || args.Parameters.Count > 3) { - user.SendMessage("Give Buff Syntax and Example", Color.White); - user.SendMessage($"{"gbuff".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"buff name".Color(Utils.PinkHighlight)}|{"ID".Color(Utils.PinkHighlight)}> [{"seconds".Color(Utils.GreenHighlight)}]", Color.White); - user.SendMessage($"Example usage: {"gbuff".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)} {"regen".Color(Utils.PinkHighlight)} {"-1".Color(Utils.GreenHighlight)}", Color.White); - user.SendMessage($"To buff a player without them knowing, use {SilentSpecifier.Color(Utils.RedHighlight)} instead of {Specifier.Color(Utils.GreenHighlight)}", Color.White); + user.SendMessage(GetString("Give Buff Syntax and Example"), Color.White); + user.SendMessage(GetString($"{"gbuff".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"buff name".Color(Utils.PinkHighlight)}|{"ID".Color(Utils.PinkHighlight)}> [{"seconds".Color(Utils.GreenHighlight)}]"), Color.White); + user.SendMessage(GetString($"Example usage: {"gbuff".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)} {"regen".Color(Utils.PinkHighlight)} {"-1".Color(Utils.GreenHighlight)}"), Color.White); + user.SendMessage(GetString($"To buff a player without them knowing, use {SilentSpecifier.Color(Utils.RedHighlight)} instead of {Specifier.Color(Utils.GreenHighlight)}"), Color.White); return; } int id = 0; @@ -6371,7 +6414,7 @@ namespace TShockAPI var foundplr = TSPlayer.FindByNameOrID(args.Parameters[0]); if (foundplr.Count == 0) { - user.SendErrorMessage($"Unable to find any player named \"{args.Parameters[0]}\""); + user.SendErrorMessage(GetString($"Unable to find any player named \"{args.Parameters[0]}\"")); return; } else if (foundplr.Count > 1) @@ -6386,7 +6429,7 @@ namespace TShockAPI var found = TShock.Utils.GetBuffByName(args.Parameters[1]); if (found.Count == 0) { - user.SendErrorMessage($"Unable to find any buff named \"{args.Parameters[1]}\""); + user.SendErrorMessage(GetString($"Unable to find any buff named \"{args.Parameters[1]}\"")); return; } else if (found.Count > 1) @@ -6404,12 +6447,12 @@ namespace TShockAPI if (time < 0 || time > timeLimit) time = timeLimit; target.SetBuff(id, time * 60); - user.SendSuccessMessage($"You have buffed {(target == user ? "yourself" : target.Name)} with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds!"); + user.SendSuccessMessage(GetString($"You have buffed {(target == user ? GetString("yourself") : target.Name)} with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds!")); if (!args.Silent && target != user) - target.SendSuccessMessage($"{user.Name} has buffed you with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds!"); + target.SendSuccessMessage(GetString($"{user.Name} has buffed you with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds!")); } else - user.SendErrorMessage("Invalid buff ID!"); + user.SendErrorMessage(GetString("Invalid buff ID!")); } } @@ -6418,13 +6461,13 @@ namespace TShockAPI bool canGrowEvil = args.Player.HasPermission(Permissions.growevil); string subcmd = args.Parameters.Count == 0 ? "help" : args.Parameters[0].ToLower(); - var name = "Fail"; + var name = "Fail"; // assigned value never used var x = args.Player.TileX; var y = args.Player.TileY + 3; if (!TShock.Regions.CanBuild(x, y, args.Player)) { - args.Player.SendErrorMessage("You're not allowed to change tiles here!"); + args.Player.SendErrorMessage(GetString("You're not allowed to change tiles here!")); return; } @@ -6436,22 +6479,22 @@ namespace TShockAPI return; var lines = new List - { - "- Default trees :", - " 'basic', 'sakura', 'willow', 'boreal', 'mahogany', 'ebonwood', 'shadewood', 'pearlwood'.", - "- Palm trees :", - " 'palm', 'corruptpalm', 'crimsonpalm', 'hallowpalm'.", - "- Gem trees :", - " 'topaz', 'amethyst', 'sapphire', 'emerald', 'ruby', 'diamond', 'amber'.", - "- Misc :", - " 'cactus', 'herb', 'mushroom'." - }; + { + GetString("- Default trees :"), + GetString(" 'basic', 'sakura', 'willow', 'boreal', 'mahogany', 'ebonwood', 'shadewood', 'pearlwood'."), + GetString("- Palm trees :"), + GetString(" 'palm', 'corruptpalm', 'crimsonpalm', 'hallowpalm'."), + GetString("- Gem trees :"), + GetString(" 'topaz', 'amethyst', 'sapphire', 'emerald', 'ruby', 'diamond', 'amber'."), + GetString("- Misc :"), + GetString(" 'cactus', 'herb', 'mushroom'.") + }; PaginationTools.SendPage(args.Player, pageNumber, lines, new PaginationTools.Settings { - HeaderFormat = "Trees types & misc available to use. ({0}/{1}):", - FooterFormat = "Type {0}grow help {{0}} for more sub-commands.".SFormat(Commands.Specifier) + HeaderFormat = GetString("Trees types & misc available to use. ({{0}}/{{1}}):"), + FooterFormat = GetString("Type {0}grow help {{0}} for more sub-commands.", Commands.Specifier) } ); } @@ -6459,9 +6502,9 @@ namespace TShockAPI bool rejectCannotGrowEvil() { - if(!canGrowEvil) + if (!canGrowEvil) { - args.Player.SendErrorMessage("You do not have permission to grow this tree type"); + args.Player.SendErrorMessage(GetString("You do not have permission to grow this tree type")); return false; } @@ -6470,7 +6513,7 @@ namespace TShockAPI bool prepareAreaForGrow(ushort groundType = TileID.Grass, bool evil = false) { - if(evil && !rejectCannotGrowEvil()) + if (evil && !rejectCannotGrowEvil()) return false; for (var i = x - 2; i < x + 3; i++) @@ -6486,7 +6529,7 @@ namespace TShockAPI bool growTree(ushort groundType, string fancyName, bool evil = false) { - if(!prepareAreaForGrow(groundType, evil)) + if (!prepareAreaForGrow(groundType, evil)) return false; WorldGen.GrowTree(x, y); name = fancyName; @@ -6496,7 +6539,7 @@ namespace TShockAPI bool growTreeByType(ushort groundType, string fancyName, ushort typeToPrepare = 2, bool evil = false) { - if(!prepareAreaForGrow(typeToPrepare, evil)) + if (!prepareAreaForGrow(typeToPrepare, evil)) return false; WorldGen.TryGrowingTreeByType(groundType, x, y); name = fancyName; @@ -6506,7 +6549,7 @@ namespace TShockAPI bool growPalmTree(ushort sandType, ushort supportingType, string properName, bool evil = false) { - if(evil && !rejectCannotGrowEvil()) + if (evil && !rejectCannotGrowEvil()) return false; for (int i = x - 2; i < x + 3; i++) @@ -6531,91 +6574,91 @@ namespace TShockAPI } case "basic": - growTree(TileID.Grass, "Basic Tree"); + growTree(TileID.Grass, GetString("Basic Tree")); break; case "boreal": - growTree(TileID.SnowBlock, "Boreal Tree"); + growTree(TileID.SnowBlock, GetString("Boreal Tree")); break; case "mahogany": - growTree(TileID.JungleGrass, "Rich Mahogany"); + growTree(TileID.JungleGrass, GetString("Rich Mahogany")); break; case "sakura": - growTreeByType(TileID.VanityTreeSakura, "Sakura Tree"); + growTreeByType(TileID.VanityTreeSakura, GetString("Sakura Tree")); break; case "willow": - growTreeByType(TileID.VanityTreeYellowWillow, "Willow Tree"); + growTreeByType(TileID.VanityTreeYellowWillow, GetString("Willow Tree")); break; case "shadewood": - if(!growTree(TileID.CrimsonGrass, "Shadewood Tree", true)) + if (!growTree(TileID.CrimsonGrass, GetString("Shadewood Tree"), true)) return; break; case "ebonwood": - if(!growTree(TileID.CorruptGrass, "Ebonwood Tree", true)) + if (!growTree(TileID.CorruptGrass, GetString("Ebonwood Tree"), true)) return; break; case "pearlwood": - if(!growTree(TileID.HallowedGrass, "Pearlwood Tree", true)) + if (!growTree(TileID.HallowedGrass, GetString("Pearlwood Tree"), true)) return; break; case "palm": - growPalmTree(TileID.Sand, TileID.HardenedSand, "Desert Palm"); + growPalmTree(TileID.Sand, TileID.HardenedSand, GetString("Desert Palm")); break; case "hallowpalm": - if(!growPalmTree(TileID.Pearlsand, TileID.HallowHardenedSand, "Hallow Palm", true)) + if (!growPalmTree(TileID.Pearlsand, TileID.HallowHardenedSand, GetString("Hallow Palm"), true)) return; break; case "crimsonpalm": - if(!growPalmTree(TileID.Crimsand, TileID.CrimsonHardenedSand, "Crimson Palm", true)) + if (!growPalmTree(TileID.Crimsand, TileID.CrimsonHardenedSand, GetString("Crimson Palm"), true)) return; break; case "corruptpalm": - if(!growPalmTree(TileID.Ebonsand, TileID.CorruptHardenedSand, "Corruption Palm", true)) + if (!growPalmTree(TileID.Ebonsand, TileID.CorruptHardenedSand, GetString("Corruption Palm"), true)) return; break; case "topaz": - growTreeByType(TileID.TreeTopaz, "Topaz Gemtree", 1); + growTreeByType(TileID.TreeTopaz, GetString("Topaz Gemtree"), 1); break; case "amethyst": - growTreeByType(TileID.TreeAmethyst, "Amethyst Gemtree", 1); + growTreeByType(TileID.TreeAmethyst, GetString("Amethyst Gemtree"), 1); break; case "sapphire": - growTreeByType(TileID.TreeSapphire, "Sapphire Gemtree", 1); + growTreeByType(TileID.TreeSapphire, GetString("Sapphire Gemtree"), 1); break; case "emerald": - growTreeByType(TileID.TreeEmerald, "Emerald Gemtree", 1); + growTreeByType(TileID.TreeEmerald, GetString("Emerald Gemtree"), 1); break; case "ruby": - growTreeByType(TileID.TreeRuby, "Ruby Gemtree", 1); + growTreeByType(TileID.TreeRuby, GetString("Ruby Gemtree"), 1); break; case "diamond": - growTreeByType(TileID.TreeDiamond, "Diamond Gemtree", 1); + growTreeByType(TileID.TreeDiamond, GetString("Diamond Gemtree"), 1); break; case "amber": - growTreeByType(TileID.TreeAmber, "Amber Gemtree", 1); + growTreeByType(TileID.TreeAmber, GetString("Amber Gemtree"), 1); break; case "cactus": Main.tile[x, y].type = TileID.Sand; WorldGen.GrowCactus(x, y); - name = "Cactus"; + name = GetString("Cactus"); break; case "herb": @@ -6623,23 +6666,23 @@ namespace TShockAPI Main.tile[x, y].frameX = 36; Main.tile[x, y].type = TileID.MatureHerbs; WorldGen.GrowAlch(x, y); - name = "Herb"; + name = GetString("Herb"); break; case "mushroom": prepareAreaForGrow(TileID.MushroomGrass); WorldGen.GrowShroom(x, y); - name = "Glowing Mushroom Tree"; + name = GetString("Glowing Mushroom Tree"); break; default: - args.Player.SendErrorMessage("Unknown plant!"); + args.Player.SendErrorMessage(GetString("Unknown plant!")); return; } if (args.Parameters.Count == 1) { args.Player.SendTileSquareCentered(x - 2, y - 20, 25); - args.Player.SendSuccessMessage("Tried to grow a " + name + "."); + args.Player.SendSuccessMessage(GetString($"Tried to grow a {name}.")); } } @@ -6650,14 +6693,14 @@ namespace TShockAPI { if (!args.Player.HasPermission(Permissions.godmodeother)) { - args.Player.SendErrorMessage("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; } string plStr = String.Join(" ", args.Parameters); var players = TSPlayer.FindByNameOrID(plStr); if (players.Count == 0) { - args.Player.SendErrorMessage("Invalid player!"); + args.Player.SendErrorMessage(GetString("Invalid player!")); return; } else if (players.Count > 1) @@ -6672,7 +6715,7 @@ namespace TShockAPI } else if (!args.Player.RealPlayer) { - args.Player.SendErrorMessage("You can't god mode a non player!"); + args.Player.SendErrorMessage(GetString("You can't god mode a non player!")); return; } else @@ -6688,12 +6731,16 @@ namespace TShockAPI if (playerToGod != args.Player) { - args.Player.SendSuccessMessage(string.Format("{0} is {1} in god mode.", playerToGod.Name, playerToGod.GodMode ? "now" : "no longer")); + args.Player.SendSuccessMessage(playerToGod.GodMode + ? GetString("{0} is now in god mode.", playerToGod.Name) + : GetString("{0} is no longer in god mode.", playerToGod.Name)); } if (!args.Silent || (playerToGod == args.Player)) { - playerToGod.SendSuccessMessage(string.Format("You are {0} in god mode.", playerToGod.GodMode ? "now" : "no longer")); + playerToGod.SendSuccessMessage(playerToGod.GodMode + ? GetString("You are now in god mode.", playerToGod.Name) + : GetString("You are no longer in god mode.", playerToGod.Name)); } } diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 22feee47..485f46f8 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1066,7 +1066,7 @@ namespace TShockAPI /// The Terraria ID of the player talking to the NPC /// public byte PlayerId { get; set; } - + /// /// The NPC ID of the NPC the player is talking to /// @@ -1089,8 +1089,8 @@ namespace TShockAPI }; NpcTalk.Invoke(null, args); return args.Handled; - } - + } + /// /// For use with a PlayerAnimation event /// @@ -1304,7 +1304,7 @@ namespace TShockAPI TileX = tilex, TileY = tiley, Amount = amount, - Type = (LiquidType) type, + Type = (LiquidType)type, }; LiquidSet.Invoke(null, args); return args.Handled; @@ -1496,7 +1496,7 @@ namespace TShockAPI ID = id, X = x, Y = y, - HouseholdStatus = (HouseholdStatus) houseHoldStatus, + HouseholdStatus = (HouseholdStatus)houseHoldStatus, }; NPCHome.Invoke(null, args); return args.Handled; @@ -1706,7 +1706,7 @@ namespace TShockAPI var args = new ReleaseNpcEventArgs { Player = player, - Data = data, + Data = data, X = _x, Y = _y, Type = _type, @@ -1714,8 +1714,8 @@ namespace TShockAPI }; ReleaseNPC.Invoke(null, args); return args.Handled; - } - + } + /// The arguments to the PlaceObject hook. public class PlaceObjectEventArgs : GetDataHandledEventArgs { @@ -2254,7 +2254,7 @@ namespace TShockAPI /// Called when a player lands a golf ball in a cup. /// public static HandlerList LandGolfBallInCup = new HandlerList(); - private static bool OnLandGolfBallInCup(TSPlayer player, MemoryStream data, byte playerIndex, ushort tileX, ushort tileY, ushort hits, ushort projectileType ) + private static bool OnLandGolfBallInCup(TSPlayer player, MemoryStream data, byte playerIndex, ushort tileX, ushort tileY, ushort hits, ushort projectileType) { if (LandGolfBallInCup == null) return false; @@ -2476,7 +2476,7 @@ namespace TShockAPI for (int i = 0; i < 8; i++) args.Player.TPlayer.hideVisibleAccessory[i] = hideVisual[i]; for (int i = 0; i < 2; i++) - args.Player.TPlayer.hideVisibleAccessory[i+8] = hideVisual2[i]; + args.Player.TPlayer.hideVisibleAccessory[i + 8] = hideVisual2[i]; args.Player.TPlayer.hideMisc = hideMisc; args.Player.TPlayer.extraAccessory = extraSlot; args.Player.TPlayer.UsingBiomeTorches = usingBiomeTorches; @@ -2528,7 +2528,7 @@ namespace TShockAPI } if (OnPlayerSlot(args.Player, args.Data, plr, slot, stack, prefix, type) || plr != args.Player.Index || slot < 0 || - slot > NetItem.MaxInventory) + slot > NetItem.MaxInventory) return true; if (args.Player.IgnoreSSCPackets) { @@ -2547,7 +2547,7 @@ namespace TShockAPI args.Player.PlayerData.StoreSlot(slot, type, prefix, stack); } else if (Main.ServerSideCharacter && TShock.Config.Settings.DisableLoginBeforeJoin && !bypassTrashCanCheck && - args.Player.HasSentInventory && !args.Player.HasPermission(Permissions.bypassssc)) + args.Player.HasSentInventory && !args.Player.HasPermission(Permissions.bypassssc)) { // The player might have moved an item to their trash can before they performed a single login attempt yet. args.Player.IsDisabledPendingTrashRemoval = true; @@ -2597,7 +2597,7 @@ namespace TShockAPI { if (args.Player.PlayerData.exists && TShock.ServerSideCharacterConfig.Settings.WarnPlayersAboutBypassPermission) { - args.Player.SendWarningMessage("Bypass SSC is enabled for your account. SSC data will not be loaded or saved."); + args.Player.SendWarningMessage(GetString("Bypass SSC is enabled for your account. SSC data will not be loaded or saved.")); TShock.Log.ConsoleInfo(args.Player.Name + " has SSC data in the database, but has the tshock.ignore.ssc permission. This means their SSC data is being ignored."); TShock.Log.ConsoleInfo("You may wish to consider removing the tshock.ignore.ssc permission or negating it for this player."); } @@ -2614,8 +2614,8 @@ namespace TShockAPI if (args.Player.HasPermission(Permissions.usebanneditem)) args.Player.IsDisabledForBannedWearable = false; - args.Player.SendSuccessMessage("Authenticated as " + account.Name + " successfully."); - TShock.Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user " + args.Player.Name + "."); + args.Player.SendSuccessMessage(GetString($"Authenticated as {account.Name} successfully.")); + TShock.Log.ConsoleInfo($"{args.Player.Name} authenticated successfully as user {args.Player.Name}."); Hooks.PlayerHooks.OnPlayerPostLogin(args.Player); return true; } @@ -2645,7 +2645,7 @@ namespace TShockAPI return true; if (TShock.Utils.GetActivePlayerCount() + 1 > TShock.Config.Settings.MaxSlots && - !args.Player.HasPermission(Permissions.reservedslot)) + !args.Player.HasPermission(Permissions.reservedslot)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleGetSection rejected reserve slot"); args.Player.Kick(TShock.Config.Settings.ServerFullReason, true, true); @@ -2777,7 +2777,7 @@ namespace TShockAPI short tileY = args.Data.ReadInt16(); short editData = args.Data.ReadInt16(); EditType type = (action == EditAction.KillTile || action == EditAction.KillWall || - action == EditAction.KillTileNoItem || action == EditAction.TryKillTile) + action == EditAction.KillTileNoItem || action == EditAction.TryKillTile) ? EditType.Fail : (action == EditAction.PlaceTile || action == EditAction.PlaceWall || action == EditAction.ReplaceTile || action == EditAction.ReplaceWall) ? EditType.Type @@ -2819,8 +2819,8 @@ namespace TShockAPI if (tileType != TileID.ClosedDoor && tileType != TileID.OpenDoor - && tileType != TileID.TallGateClosed && tileType != TileID.TallGateOpen - && tileType != TileID.TrapdoorClosed && tileType != TileID.TrapdoorOpen) + && tileType != TileID.TallGateClosed && tileType != TileID.TallGateOpen + && tileType != TileID.TrapdoorClosed && tileType != TileID.TrapdoorOpen) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleDoorUse rejected door gap check {0}", args.Player.Name); return true; @@ -2938,34 +2938,34 @@ namespace TShockAPI if (Main.npc[id].townNPC && !args.Player.HasPermission(Permissions.hurttownnpc)) { - args.Player.SendErrorMessage("You do not have permission to hurt Town NPCs."); + args.Player.SendErrorMessage(GetString("You do not have permission to hurt Town NPCs.")); args.Player.SendData(PacketTypes.NpcUpdate, "", id); TShock.Log.ConsoleDebug($"GetDataHandlers / HandleNpcStrike rejected npc strike {args.Player.Name}"); return true; } - + if (Main.npc[id].netID == NPCID.EmpressButterfly) { if (!args.Player.HasPermission(Permissions.summonboss)) { - args.Player.SendErrorMessage("You do not have permission to summon the Empress of Light."); + args.Player.SendErrorMessage(GetString("You do not have permission to summon the Empress of Light.")); args.Player.SendData(PacketTypes.NpcUpdate, "", id); TShock.Log.ConsoleDebug($"GetDataHandlers / HandleNpcStrike rejected EoL summon from {args.Player.Name}"); return true; } else if (!TShock.Config.Settings.AnonymousBossInvasions) { - TShock.Utils.Broadcast(string.Format($"{args.Player.Name} summoned the Empress of Light!"), 175, 75, 255); + TShock.Utils.Broadcast(GetString($"{args.Player.Name} summoned the Empress of Light!"), 175, 75, 255); } else - TShock.Utils.SendLogs(string.Format($"{args.Player.Name} summoned the Empress of Light!"), Color.PaleVioletRed, args.Player); + TShock.Utils.SendLogs(GetString($"{args.Player.Name} summoned the Empress of Light!"), Color.PaleVioletRed, args.Player); } - + if (Main.npc[id].netID == NPCID.CultistDevote || Main.npc[id].netID == NPCID.CultistArcherBlue) { if (!args.Player.HasPermission(Permissions.summonboss)) { - args.Player.SendErrorMessage("You do not have permission to summon the Lunatic Cultist!"); + args.Player.SendErrorMessage(GetString("You do not have permission to summon the Lunatic Cultist!")); args.Player.SendData(PacketTypes.NpcUpdate, "", id); TShock.Log.ConsoleDebug($"GetDataHandlers / HandleNpcStrike rejected Cultist summon from {args.Player.Name}"); return true; @@ -2986,7 +2986,7 @@ namespace TShockAPI return true; } - short type = (short) Main.projectile[index].type; + short type = (short)Main.projectile[index].type; // TODO: This needs to be moved somewhere else. @@ -3189,7 +3189,7 @@ namespace TShockAPI args.Player.IsDisabledForBannedWearable = false; - args.Player.SendMessage("Authenticated as " + args.Player.Name + " successfully.", Color.LimeGreen); + args.Player.SendMessage(GetString("Authenticated as " + args.Player.Name + " successfully."), Color.LimeGreen); TShock.Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user " + args.Player.Name + "."); TShock.UserAccounts.SetUserAccountUUID(account, args.Player.UUID); Hooks.PlayerHooks.OnPlayerPostLogin(args.Player); @@ -3224,7 +3224,7 @@ namespace TShockAPI if (OnNpcTalk(args.Player, args.Data, plr, npc)) return true; - + //Rejecting player who trying to talk to a npc if player were disabled, mainly for unregistered and logged out players. Preventing smuggling or duplicating their items if player put it in a npc's item slot if (args.Player.IsBeingDisabled()) { @@ -3405,7 +3405,7 @@ namespace TShockAPI if (type == 1 && TShock.Config.Settings.DisableDungeonGuardian) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected type 1 for {0}", args.Player.Name); - args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point.", Color.Purple); + args.Player.SendMessage(GetString("The Dungeon Guardian returned you to your spawn point."), Color.Purple); args.Player.Spawn(PlayerSpawnContext.RecallFromItem); return true; } @@ -3415,7 +3415,7 @@ namespace TShockAPI if (!args.Player.HasPermission(Permissions.usesundial)) { TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission {args.Player.Name}"); - args.Player.SendErrorMessage("You do not have permission to use the Enchanted Sundial."); + args.Player.SendErrorMessage(GetString("You do not have permission to use the Enchanted Sundial.")); return true; } else if (TShock.Config.Settings.ForceTime != "normal") @@ -3423,10 +3423,10 @@ namespace TShockAPI TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission (ForceTime) {args.Player.Name}"); if (!args.Player.HasPermission(Permissions.cfgreload)) { - args.Player.SendErrorMessage("You cannot use the Enchanted Sundial because time is stopped."); + args.Player.SendErrorMessage(GetString("You cannot use the Enchanted Sundial because time is stopped.")); } else - args.Player.SendErrorMessage("You must set ForceTime to normal via config to use the Enchanted Sundial."); + args.Player.SendErrorMessage(GetString("You must set ForceTime to normal via config to use the Enchanted Sundial.")); return true; } } @@ -3471,7 +3471,7 @@ namespace TShockAPI if (!args.Player.HasPermission(Permissions.movenpc)) { TShock.Log.ConsoleDebug("GetDataHandlers / UpdateNPCHome rejected no permission {0}", args.Player.Name); - args.Player.SendErrorMessage("You do not have permission to relocate Town NPCs."); + args.Player.SendErrorMessage(GetString("You do not have permission to relocate Town NPCs.")); args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY, Convert.ToByte(Main.npc[id].homeless)); return true; @@ -3498,21 +3498,21 @@ namespace TShockAPI if (bosses.Contains(thingType) && !args.Player.HasPermission(Permissions.summonboss)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected boss {0} {1}", args.Player.Name, thingType); - args.Player.SendErrorMessage("You do not have permission to summon bosses."); + args.Player.SendErrorMessage(GetString("You do not have permission to summon bosses.")); return true; } if (invasions.Contains(thingType) && !args.Player.HasPermission(Permissions.startinvasion)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected invasion {0} {1}", args.Player.Name, thingType); - args.Player.SendErrorMessage("You do not have permission to start invasions."); + args.Player.SendErrorMessage(GetString("You do not have permission to start invasions.")); return true; } if (pets.Contains(thingType) && !args.Player.HasPermission(Permissions.spawnpets)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected pet {0} {1}", args.Player.Name, thingType); - args.Player.SendErrorMessage("You do not have permission to spawn pets."); + args.Player.SendErrorMessage(GetString("You do not have permission to spawn pets.")); return true; } @@ -3523,52 +3523,52 @@ namespace TShockAPI switch (thingType) { case -14: - thing = "has sent a request to the bunny delivery service"; + thing = GetString("{0} has sent a request to the bunny delivery service!", args.Player.Name); break; case -13: - thing = "has sent a request to the dog delivery service"; + thing = GetString("{0} has sent a request to the dog delivery service!", args.Player.Name); break; case -12: - thing = "has sent a request to the cat delivery service"; + thing = GetString("{0} has sent a request to the cat delivery service!", args.Player.Name); break; case -11: - thing = "applied advanced combat techniques"; + thing = GetString("{0} applied advanced combat techniques!", args.Player.Name); break; case -10: - thing = "summoned a Blood Moon"; + thing = GetString("{0} summoned a Blood Moon!", args.Player.Name); break; case -8: - thing = "summoned a Moon Lord"; + thing = GetString("{0} summoned a Moon Lord!", args.Player.Name); break; case -7: - thing = "summoned a Martian invasion"; + thing = GetString("{0} summoned a Martian invasion!", args.Player.Name); break; case -6: - thing = "summoned an eclipse"; + thing = GetString("{0} summoned an eclipse!", args.Player.Name); break; case -5: - thing = "summoned a frost moon"; + thing = GetString("{0} summoned a frost moon!", args.Player.Name); break; case -4: - thing = "summoned a pumpkin moon"; + thing = GetString("{0} summoned a pumpkin moon!", args.Player.Name); break; case -3: - thing = "summoned the Pirates"; + thing = GetString("{0} summoned the Pirates!", args.Player.Name); break; case -2: - thing = "summoned the Snow Legion"; + thing = GetString("{0} summoned the Snow Legion!", args.Player.Name); break; case -1: - thing = "summoned a Goblin Invasion"; + thing = GetString("{0} summoned a Goblin Invasion!", args.Player.Name); break; default: - thing = String.Format("summoned the {0}", npc.FullName); + thing = GetString("{0} summoned the {1}!", args.Player.Name, npc.FullName); break; } if (TShock.Config.Settings.AnonymousBossInvasions) - TShock.Utils.SendLogs(string.Format("{0} {1}!", args.Player.Name, thing), Color.PaleVioletRed, args.Player); + TShock.Utils.SendLogs(thing, Color.PaleVioletRed, args.Player); else - TShock.Utils.Broadcast(String.Format("{0} {1}!", args.Player.Name, thing), 175, 75, 255); + TShock.Utils.Broadcast(thing, 175, 75, 255); return false; } @@ -3709,7 +3709,7 @@ namespace TShockAPI if (type == 0 && !args.Player.HasPermission(Permissions.rod)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected rod type {0} {1}", args.Player.Name, type); - args.Player.SendErrorMessage("You do not have permission to teleport using items."); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD. + args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD. args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y); // Suggest renaming rod permission unless someone plans to add separate perms for the other 2 tp items. return true; } @@ -3733,7 +3733,7 @@ namespace TShockAPI if (!args.Player.HasPermission(Permissions.wormhole)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected p2p wormhole permission {0} {1}", args.Player.Name, type); - args.Player.SendErrorMessage("You do not have permission to teleport using Wormhole Potions."); + args.Player.SendErrorMessage(GetString("You do not have permission to teleport using Wormhole Potions.")); args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y); return true; } @@ -3765,8 +3765,8 @@ namespace TShockAPI NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcID); return true; } - - if(args.Player.IsBeingDisabled()) + + if (args.Player.IsBeingDisabled()) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleCatchNpc rejected catch npc {0}", args.Player.Name); return true; @@ -3781,15 +3781,15 @@ namespace TShockAPI var y = args.Data.ReadInt32(); var type = args.Data.ReadInt16(); var style = args.Data.ReadInt8(); - + if (OnReleaseNpc(args.Player, args.Data, x, y, type, style)) { return true; } return false; - } - + } + private static bool HandleTeleportationPotion(GetDataHandlerArgs args) { var type = args.Data.ReadByte(); @@ -3797,14 +3797,14 @@ namespace TShockAPI void Fail(string tpItem) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected permissions {0} {1}", args.Player.Name, type); - args.Player.SendErrorMessage("You do not have permission to teleport using {0}.", tpItem); + args.Player.SendErrorMessage(GetString("You do not have permission to teleport using {0}.", tpItem)); } switch (type) { case 0: // Teleportation Potion if (args.Player.ItemInHand.type != ItemID.TeleportationPotion && - args.Player.SelectedItem.type != ItemID.TeleportationPotion) + args.Player.SelectedItem.type != ItemID.TeleportationPotion) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type); return true; @@ -3931,7 +3931,7 @@ namespace TShockAPI if (TShock.TileBans.TileIsBanned((short)TileID.LogicSensor, args.Player)) { args.Player.SendTileSquareCentered(x, y, 1); - args.Player.SendErrorMessage("You do not have permission to place Logic Sensors."); + args.Player.SendErrorMessage(GetString("You do not have permission to place Logic Sensors.")); return true; } @@ -3987,7 +3987,7 @@ namespace TShockAPI } var distanceFromCoinPacketToNpc = Utils.Distance(position, npc.position); - if (distanceFromCoinPacketToNpc >= (5*16f)) //5 tile range + if (distanceFromCoinPacketToNpc >= (5 * 16f)) //5 tile range { TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected range check {0},{1} vs {2},{3} which is {4}", npc.position.X, npc.position.Y, position.X, position.Y, distanceFromCoinPacketToNpc); return true; @@ -4043,7 +4043,7 @@ namespace TShockAPI if (projectile == null || !projectile.active) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcTeleportPortal rejected null check {0}", args.Player.Name); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcTeleportPortal rejected null check {0}", args.Player.Name); NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcIndex); return true; } @@ -4091,7 +4091,7 @@ namespace TShockAPI if (args.Player != null && !args.Player.HasPermission(Permissions.toggleparty)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleToggleParty rejected no party {0}", args.Player.Name); - args.Player.SendErrorMessage("You do not have permission to start a party."); + args.Player.SendErrorMessage(GetString("You do not have permission to start a party.")); return true; } @@ -4109,14 +4109,14 @@ namespace TShockAPI if (!args.Player.HasPermission(Permissions.startdd2)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleOldOnesArmy rejected permissions {0}", args.Player.Name); - args.Player.SendErrorMessage("You do not have permission to start the Old One's Army."); + args.Player.SendErrorMessage(GetString("You do not have permission to start the Old One's Army.")); return true; } if (TShock.Config.Settings.AnonymousBossInvasions) - TShock.Utils.SendLogs(string.Format("{0} started the Old One's Army event!", args.Player.Name), Color.PaleVioletRed, args.Player); + TShock.Utils.SendLogs(GetString("{0} started the Old One's Army event!", args.Player.Name), Color.PaleVioletRed, args.Player); else - TShock.Utils.Broadcast(string.Format("{0} started the Old One's Army event!", args.Player.Name), 175, 75, 255); + TShock.Utils.Broadcast(GetString("{0} started the Old One's Army event!", args.Player.Name), 175, 75, 255); return false; } @@ -4190,14 +4190,14 @@ namespace TShockAPI if (TShock.CharacterDB.RemovePlayer(args.Player.Account.ID)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerKillMeV2 ssc delete {0} {1}", args.Player.Name, args.TPlayer.difficulty); - args.Player.SendErrorMessage("You have fallen in hardcore mode, and your items have been lost forever."); + args.Player.SendErrorMessage(GetString("You have fallen in hardcore mode, and your items have been lost forever.")); TShock.CharacterDB.SeedInitialData(args.Player.Account); } } return false; } - + private static bool HandleEmoji(GetDataHandlerArgs args) { byte playerIndex = args.Data.ReadInt8(); @@ -4289,7 +4289,7 @@ namespace TShockAPI int coinsValue = args.Data.ReadInt32(); float baseValue = args.Data.ReadSingle(); bool spawnedFromStatus = args.Data.ReadBoolean(); - + return false; } @@ -4594,7 +4594,7 @@ namespace TShockAPI {TileID.Crystals, 17}, {TileID.MinecartTrack, 3} }; - + /// /// Contains brief information about a projectile /// diff --git a/TShockAPI/ItemBans.cs b/TShockAPI/ItemBans.cs index 9f951ed2..c12f5558 100644 --- a/TShockAPI/ItemBans.cs +++ b/TShockAPI/ItemBans.cs @@ -199,7 +199,7 @@ namespace TShockAPI if (args.Player.TPlayer.autoActuator && DataModel.ItemIsBanned("Actuator", args.Player)) { args.Player.SendTileSquareCentered(args.X, args.Y, 1); - args.Player.SendErrorMessage("You do not have permission to place actuators."); + args.Player.SendErrorMessage(GetString("You do not have permission to place actuators.")); args.Handled = true; return; } @@ -231,7 +231,7 @@ namespace TShockAPI private void SendCorrectiveMessage(TSPlayer player, string itemName) { - player.SendErrorMessage("{0} is banned! Remove it!", itemName); + player.SendErrorMessage(GetString("{0} is banned! Remove it!", itemName)); } } } diff --git a/TShockAPI/PaginationTools.cs b/TShockAPI/PaginationTools.cs index ab01e555..1f9b457e 100644 --- a/TShockAPI/PaginationTools.cs +++ b/TShockAPI/PaginationTools.cs @@ -102,10 +102,10 @@ namespace TShockAPI public Settings() { this.IncludeHeader = true; - this.headerFormat = "Page {0} of {1}"; + this.headerFormat = GetString("Page {{0}} of {{1}}"); this.HeaderTextColor = Color.Green; this.IncludeFooter = true; - this.footerFormat = "Type / {0} for more."; + this.footerFormat = GetString("Type / {{0}} for more."); this.FooterTextColor = Color.Yellow; this.NothingToDisplayString = null; this.LineFormatter = null; diff --git a/TShockAPI/RegionHandler.cs b/TShockAPI/RegionHandler.cs index 48d5421a..9c61b700 100644 --- a/TShockAPI/RegionHandler.cs +++ b/TShockAPI/RegionHandler.cs @@ -151,12 +151,12 @@ namespace TShockAPI if (output.Count == 0) { player.SendInfoMessage(includeUnprotected - ? "There are no regions at this point." - : "There are no regions at this point, or they are not protected."); + ? GetString("There are no regions at this point.") + : GetString("There are no regions at this point, or they are not protected.")); } else { - player.SendInfoMessage(includeUnprotected ? "Regions at this point: " : "Protected regions at this point: "); + player.SendInfoMessage(includeUnprotected ? GetString("Regions at this point: ") : GetString("Protected regions at this point: ")); foreach (string line in PaginationTools.BuildLinesFromTerms(output)) { @@ -184,7 +184,7 @@ namespace TShockAPI // Set temp point coordinates to current tile coordinates player.TempPoints[player.AwaitingTempPoint - 1].X = e.X; player.TempPoints[player.AwaitingTempPoint - 1].Y = e.Y; - player.SendInfoMessage($"Set temp point {player.AwaitingTempPoint}."); + player.SendInfoMessage(GetString($"Set temp point {player.AwaitingTempPoint}.")); // Reset the awaiting temp point player.AwaitingTempPoint = 0; diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index cc1f24e1..1717c1dc 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -844,7 +844,7 @@ namespace TShockAPI } } - return RestResponse(GetPluralString($"{killcount} NPC has been killed.", "{killcount} NPCs have been killed.", killcount)); + return RestResponse(GetPluralString("{0} NPC has been killed.", "{0} NPCs have been killed.", killcount, killcount)); } [Description("Get information regarding the world.")] diff --git a/TShockAPI/SaveManager.cs b/TShockAPI/SaveManager.cs index 335fe965..76fe294f 100644 --- a/TShockAPI/SaveManager.cs +++ b/TShockAPI/SaveManager.cs @@ -55,7 +55,7 @@ namespace TShockAPI // These can be caused by an unexpected error such as a bad or out of date plugin try { - TShock.Utils.Broadcast("Saving world...", Color.Yellow); + TShock.Utils.Broadcast(GetString("Saving world..."), Color.Yellow); } catch (Exception ex) { @@ -132,9 +132,9 @@ namespace TShockAPI WorldFile.SaveWorld(task.resetTime); if (TShock.Config.Settings.AnnounceSave) - TShock.Utils.Broadcast("World saved.", Color.Yellow); + TShock.Utils.Broadcast(GetString("World saved."), Color.Yellow); - TShock.Log.Info(string.Format("World saved at ({0})", Main.worldPathName)); + TShock.Log.Info(GetString("World saved at ({0})", Main.worldPathName)); } catch (Exception e) { @@ -160,7 +160,7 @@ namespace TShockAPI public override string ToString() { - return string.Format("resetTime {0}, direct {1}", resetTime, direct); + return GetString("resetTime {0}, direct {1}", resetTime, direct); } } } diff --git a/TShockAPI/SqlLog.cs b/TShockAPI/SqlLog.cs index 3c2885d9..3e79aaab 100644 --- a/TShockAPI/SqlLog.cs +++ b/TShockAPI/SqlLog.cs @@ -36,7 +36,7 @@ namespace TShockAPI public override string ToString() { - return string.Format("Message: {0}: {1}: {2}", + return GetString("Message: {0}: {1}: {2}", caller, logLevel.ToString().ToUpper(), message); } } @@ -314,7 +314,7 @@ namespace TShockAPI { caller = "TShock", logLevel = TraceLevel.Error, - message = string.Format("SQL Log insert query failed: {0}", ex), + message = GetString("SQL Log insert query failed: {0}", ex), timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) }); } @@ -343,7 +343,7 @@ namespace TShockAPI foreach (var logInfo in _failures) { - _backupLog.Write(string.Format("SQL log failed at: {0}. {1}", logInfo.timestamp, logInfo), + _backupLog.Write(GetString("SQL log failed at: {0}. {1}", logInfo.timestamp, logInfo), TraceLevel.Error); } _failures.Clear(); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index ed73af1c..73820eaa 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -981,7 +981,7 @@ namespace TShockAPI get { return RealPlayer - && (Netplay.Clients[Index] != null && Netplay.Clients[Index].IsActive && !Netplay.Clients[Index].PendingTermination); + && (Netplay.Clients[Index] != null && Netplay.Clients[Index].IsActive && !Netplay.Clients[Index].PendingTermination); } } @@ -1722,7 +1722,7 @@ namespace TShockAPI Main.player[Index].team = team; NetMessage.SendData((int)PacketTypes.PlayerTeam, -1, -1, NetworkText.Empty, Index); } - + /// /// Sets the player's pvp. /// @@ -1838,12 +1838,12 @@ namespace TShockAPI TShock.Bans.InsertBan($"{Identifier.Account}{Account.Name}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); } - Disconnect(string.Format("Banned: {0}", reason)); + Disconnect(GetString("Banned: {0}", reason)); if (string.IsNullOrWhiteSpace(adminUserName)) - TSPlayer.All.SendInfoMessage("{0} was banned for '{1}'.", Name, reason); + TSPlayer.All.SendInfoMessage(GetString("{0} was banned for '{1}'.", Name, reason)); else - TSPlayer.All.SendInfoMessage("{0} banned {1} for '{2}'.", adminUserName, Name, reason); + TSPlayer.All.SendInfoMessage(GetString("{0} banned {1} for '{2}'.", adminUserName, Name, reason)); return true; } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index d3fadac3..13a0bc71 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -443,8 +443,8 @@ namespace TShockAPI if(Log is not null) Log.ConsoleError(message); else Console.WriteLine(message); }; - SafeError("TShock encountered a problem from which it cannot recover. The following message may help diagnose the problem."); - SafeError("Until the problem is resolved, TShock will not be able to start (and will crash on startup)."); + SafeError(GetString("TShock encountered a problem from which it cannot recover. The following message may help diagnose the problem.")); + SafeError(GetString("Until the problem is resolved, TShock will not be able to start (and will crash on startup).")); SafeError(ex.ToString()); Environment.Exit(1); } @@ -780,7 +780,7 @@ namespace TShockAPI { if (!string.IsNullOrWhiteSpace(cfg)) { - ServerApi.LogWriter.PluginWriteLine(this, string.Format("Loading dedicated config file: {0}", cfg), TraceLevel.Verbose); + ServerApi.LogWriter.PluginWriteLine(this, GetString("Loading dedicated config file: {0}", cfg), TraceLevel.Verbose); Main.instance.LoadDedConfig(cfg); } }) @@ -791,7 +791,7 @@ namespace TShockAPI if (int.TryParse(p, out port)) { Netplay.ListenPort = port; - ServerApi.LogWriter.PluginWriteLine(this, string.Format("Listening on port {0}.", port), TraceLevel.Verbose); + ServerApi.LogWriter.PluginWriteLine(this, GetString("Listening on port {0}.", port), TraceLevel.Verbose); } }) @@ -800,7 +800,7 @@ namespace TShockAPI if (!string.IsNullOrWhiteSpace(world)) { Main.instance.SetWorldName(world); - ServerApi.LogWriter.PluginWriteLine(this, string.Format("World name will be overridden by: {0}", world), TraceLevel.Verbose); + ServerApi.LogWriter.PluginWriteLine(this, GetString("World name will be overridden by: {0}", world), TraceLevel.Verbose); } }) @@ -810,7 +810,7 @@ namespace TShockAPI if (IPAddress.TryParse(ip, out addr)) { Netplay.ServerIP = addr; - ServerApi.LogWriter.PluginWriteLine(this, string.Format("Listening on IP {0}.", addr), TraceLevel.Verbose); + ServerApi.LogWriter.PluginWriteLine(this, GetString("Listening on IP {0}.", addr), TraceLevel.Verbose); } else { @@ -846,7 +846,7 @@ namespace TShockAPI throw new InvalidOperationException("Invalid value given for command line argument \"-worldevil\"."); } - ServerApi.LogWriter.PluginWriteLine(this, String.Format("New worlds will be generated with the {0} world evil type!", value), TraceLevel.Verbose); + ServerApi.LogWriter.PluginWriteLine(this, GetString("New worlds will be generated with the {0} world evil type!", value), TraceLevel.Verbose); WorldGen.WorldGenParam_Evil = worldEvil; }) @@ -978,8 +978,8 @@ namespace TShockAPI if (File.Exists(Path.Combine(SavePath, "setup-code.txt"))) { - Log.ConsoleInfo("An account has been detected in the user database, but setup-code.txt is still present."); - Log.ConsoleInfo("TShock will now disable the initial setup system and remove setup-code.txt as it is no longer needed."); + Log.ConsoleInfo(GetString("An account has been detected in the user database, but setup-code.txt is still present.")); + Log.ConsoleInfo(GetString("TShock will now disable the initial setup system and remove setup-code.txt as it is no longer needed.")); File.Delete(Path.Combine(SavePath, "setup-code.txt")); } @@ -994,8 +994,8 @@ namespace TShockAPI var r = new Random((int)DateTime.Now.ToBinary()); SetupToken = r.Next(100000, 10000000); Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine("To setup the server, join the game and type {0}setup {1}", Commands.Specifier, SetupToken); - Console.WriteLine("This token will display until disabled by verification. ({0}setup)", Commands.Specifier); + Console.WriteLine(GetString("To setup the server, join the game and type {0}setup {1}", Commands.Specifier, SetupToken)); + Console.WriteLine(GetString("This token will display until disabled by verification. ({0}setup)", Commands.Specifier)); Console.ResetColor(); File.WriteAllText(Path.Combine(SavePath, "setup-code.txt"), SetupToken.ToString()); } @@ -1003,9 +1003,9 @@ namespace TShockAPI { SetupToken = Convert.ToInt32(File.ReadAllText(Path.Combine(SavePath, "setup-code.txt"))); Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine("TShock Notice: setup-code.txt is still present, and the code located in that file will be used."); - Console.WriteLine("To setup the server, join the game and type {0}setup {1}", Commands.Specifier, SetupToken); - Console.WriteLine("This token will display until disabled by verification. ({0}setup)", Commands.Specifier); + Console.WriteLine(GetString("TShock Notice: setup-code.txt is still present, and the code located in that file will be used.")); + Console.WriteLine(GetString("To setup the server, join the game and type {0}setup {1}", Commands.Specifier, SetupToken)); + Console.WriteLine(GetString("This token will display until disabled by verification. ({0}setup)", Commands.Specifier)); Console.ResetColor(); } @@ -1465,7 +1465,7 @@ namespace TShockAPI if (!Commands.HandleCommand(tsplr, text)) { // This is required in case anyone makes HandleCommand return false again - tsplr.SendErrorMessage("Unable to parse command. Please contact an administrator for assistance."); + tsplr.SendErrorMessage(GetString("Unable to parse command. Please contact an administrator for assistance.")); Log.ConsoleError("Unable to parse command '{0}' from player {1}.", text, tsplr.Name); } } @@ -1483,7 +1483,7 @@ namespace TShockAPI } else if (tsplr.mute) { - tsplr.SendErrorMessage("You are muted!"); + tsplr.SendErrorMessage(GetString("You are muted!")); args.Handled = true; } else if (!TShock.Config.Settings.EnableChatAboveHeads) @@ -1638,22 +1638,22 @@ namespace TShockAPI if (Config.Settings.EnableGeoIP && TShock.Geo != null) { - Log.Info("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", player.Name, player.IP, + Log.Info(GetString("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", player.Name, player.IP, player.Group.Name, player.Country, TShock.Utils.GetActivePlayerCount(), - TShock.Config.Settings.MaxSlots); + TShock.Config.Settings.MaxSlots)); if (!player.SilentJoinInProgress) - Utils.Broadcast(string.Format("{0} ({1}) has joined.", player.Name, player.Country), Color.Yellow); + Utils.Broadcast(GetString("{0} ({1}) has joined.", player.Name, player.Country), Color.Yellow); } else { - Log.Info("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP, - player.Group.Name, TShock.Utils.GetActivePlayerCount(), TShock.Config.Settings.MaxSlots); + Log.Info(GetString("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP, + player.Group.Name, TShock.Utils.GetActivePlayerCount(), TShock.Config.Settings.MaxSlots)); if (!player.SilentJoinInProgress) - Utils.Broadcast(player.Name + " has joined.", Color.Yellow); + Utils.Broadcast(GetString("{0} has joined.", player.Name), Color.Yellow); } if (Config.Settings.DisplayIPToAdmins) - Utils.SendLogs(string.Format("{0} has joined. IP: {1}", player.Name, player.IP), Color.Blue); + Utils.SendLogs(GetString("{0} has joined. IP: {1}", player.Name, player.IP), Color.Blue); player.SendFileTextAsMessage(FileTools.MotdPath); @@ -1670,12 +1670,12 @@ namespace TShockAPI if (Main.ServerSideCharacter) { player.IsDisabledForSSC = true; - player.SendErrorMessage(String.Format("Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier)); + player.SendErrorMessage(GetString("Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier)); player.LoginHarassed = true; } else if (Config.Settings.RequireLogin) { - player.SendErrorMessage("Please {0}register or {0}login to play!", Commands.Specifier); + player.SendErrorMessage(GetString("Please {0}register or {0}login to play!", Commands.Specifier)); player.LoginHarassed = true; } } @@ -1685,7 +1685,7 @@ namespace TShockAPI if (Config.Settings.RememberLeavePos && (RememberedPos.GetLeavePos(player.Name, player.IP) != Vector2.Zero) && !player.LoginHarassed) { player.RPPending = 3; - player.SendInfoMessage("You will be teleported to your last known location..."); + player.SendInfoMessage(GetString("You will be teleported to your last known location...")); } args.Handled = true; diff --git a/TShockAPI/UpdateManager.cs b/TShockAPI/UpdateManager.cs index 80e4d8ff..8cb277f9 100644 --- a/TShockAPI/UpdateManager.cs +++ b/TShockAPI/UpdateManager.cs @@ -129,13 +129,13 @@ namespace TShockAPI { return update; } - + return null; } private void NotifyAdministrators(Dictionary update) { - var changes = update["changes"].Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries); + var changes = update["changes"].Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); NotifyAdministrator(TSPlayer.Server, changes); foreach (TSPlayer player in TShock.Players) { @@ -148,7 +148,7 @@ namespace TShockAPI private void NotifyAdministrator(TSPlayer player, string[] changes) { - player.SendMessage("The server is out of date. Latest version: ", Color.Red); + player.SendMessage(GetString("The server is out of date. Latest version: "), Color.Red); for (int j = 0; j < changes.Length; j++) { player.SendMessage(changes[j], Color.Red); diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index ffd9ce5f..bf63958f 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -133,7 +133,7 @@ namespace TShockAPI { TSPlayer.All.SendMessage(msg, red, green, blue); TSPlayer.Server.SendMessage(msg, red, green, blue); - TShock.Log.Info(string.Format("Broadcast: {0}", msg)); + TShock.Log.Info(GetString("Broadcast: {0}", msg)); } /// >Broadcast - Broadcasts a message to all players on the server, as well as the server console, and the logs. @@ -156,7 +156,7 @@ namespace TShockAPI { TSPlayer.All.SendMessageFromPlayer(msg, red, green, blue, ply); TSPlayer.Server.SendMessage(Main.player[ply].name + ": " + msg, red, green, blue); - TShock.Log.Info(string.Format("Broadcast: {0}", Main.player[ply].name + ": " + msg)); + TShock.Log.Info(GetString("Broadcast: {0}: {1}", Main.player[ply].name, msg)); } /// @@ -1063,7 +1063,7 @@ namespace TShockAPI /// If the server is empty; determines if we should use Utils.GetActivePlayerCount() for player count or 0. internal void SetConsoleTitle(bool empty) { - Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})", + Console.Title = GetString("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})", !string.IsNullOrWhiteSpace(TShock.Config.Settings.ServerName) ? TShock.Config.Settings.ServerName + " - " : "", empty ? 0 : GetActivePlayerCount(), TShock.Config.Settings.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum);