Use i18n for most string.Format if shown in log, console or client side

This commit is contained in:
SGKoishi 2022-10-24 13:28:44 -07:00
parent ea9f6b73e0
commit b766e045b5
No known key found for this signature in database
GPG key ID: 8FFC399070653828
7 changed files with 117 additions and 113 deletions

View file

@ -1665,7 +1665,7 @@ namespace TShockAPI
{ {
if (TShock.Config.Settings.KickOnTileLiquidThresholdBroken) 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 else
{ {

View file

@ -4944,30 +4944,30 @@ namespace TShockAPI
return string.Concat("{ID: ", userId, "}"); return string.Concat("{ID: ", userId, "}");
}); });
List<string> extraLines = PaginationTools.BuildLinesFromTerms(sharedUsersSelector.Distinct()); List<string> extraLines = PaginationTools.BuildLinesFromTerms(sharedUsersSelector.Distinct());
extraLines[0] = "Shared with: " + extraLines[0]; extraLines[0] = GetString("Shared with: ") + extraLines[0];
lines.AddRange(extraLines); lines.AddRange(extraLines);
} }
else 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) if (region.AllowedGroups.Count > 0)
{ {
List<string> extraLines = PaginationTools.BuildLinesFromTerms(region.AllowedGroups.Distinct()); List<string> extraLines = PaginationTools.BuildLinesFromTerms(region.AllowedGroups.Distinct());
extraLines[0] = "Shared with groups: " + extraLines[0]; extraLines[0] = GetString("Shared with groups: ") + extraLines[0];
lines.AddRange(extraLines); lines.AddRange(extraLines);
} }
else else
{ {
lines.Add("Region is not shared with any groups."); lines.Add(GetString("Region is not shared with any groups."));
} }
PaginationTools.SendPage( PaginationTools.SendPage(
args.Player, pageNumber, lines, new PaginationTools.Settings args.Player, pageNumber, lines, new PaginationTools.Settings
{ {
HeaderFormat = string.Format("Information About Region \"{0}\" ({{0}}/{{1}}):", region.Name), HeaderFormat = GetString("Information About Region \"{0}\" ({{0}}/{{1}}):", region.Name),
FooterFormat = string.Format("Type {0}region info {1} {{0}} for more information.", Specifier, regionName) FooterFormat = GetString("Type {0}region info {1} {{0}} for more information.", Specifier, regionName)
} }
); );
@ -5204,13 +5204,13 @@ namespace TShockAPI
private static void ToggleAntiBuild(CommandArgs args) private static void ToggleAntiBuild(CommandArgs args)
{ {
TShock.Config.Settings.DisableBuild = !TShock.Config.Settings.DisableBuild; 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) private static void ProtectSpawn(CommandArgs args)
{ {
TShock.Config.Settings.SpawnProtection = !TShock.Config.Settings.SpawnProtection; 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 #endregion World Protection Commands
@ -5407,7 +5407,7 @@ namespace TShockAPI
if (args.Player.mute) if (args.Player.mute)
args.Player.SendErrorMessage("You are muted."); args.Player.SendErrorMessage("You are muted.");
else 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) private static void PartyChat(CommandArgs args)
@ -5423,7 +5423,7 @@ namespace TShockAPI
args.Player.SendErrorMessage("You are muted."); args.Player.SendErrorMessage("You are muted.");
else if (playerTeam != 0) 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) foreach (TSPlayer player in TShock.Players)
{ {
if (player != null && player.Active && player.Team == playerTeam) if (player != null && player.Active && player.Team == playerTeam)
@ -6093,7 +6093,7 @@ namespace TShockAPI
if (args.Player.GiveItemCheck(item.type, EnglishLanguage.GetItemNameById(item.type), itemAmount, prefixId)) if (args.Player.GiveItemCheck(item.type, EnglishLanguage.GetItemNameById(item.type), itemAmount, prefixId))
{ {
item.prefix = (byte)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 else
{ {
@ -6231,8 +6231,8 @@ namespace TShockAPI
itemAmount = item.maxStack; itemAmount = item.maxStack;
if (plr.GiveItemCheck(item.type, EnglishLanguage.GetItemNameById(item.type), itemAmount, prefix)) 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)); args.Player.SendSuccessMessage(GetPluralString("Gave {0} {1} {2}.", "Gave {0} {1} {2}s.", itemAmount, plr.Name, itemAmount, item.Name));
plr.SendSuccessMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.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 else
{ {
@ -6418,13 +6418,13 @@ namespace TShockAPI
bool canGrowEvil = args.Player.HasPermission(Permissions.growevil); bool canGrowEvil = args.Player.HasPermission(Permissions.growevil);
string subcmd = args.Parameters.Count == 0 ? "help" : args.Parameters[0].ToLower(); 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 x = args.Player.TileX;
var y = args.Player.TileY + 3; var y = args.Player.TileY + 3;
if (!TShock.Regions.CanBuild(x, y, args.Player)) 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; return;
} }
@ -6436,22 +6436,22 @@ namespace TShockAPI
return; return;
var lines = new List<string> var lines = new List<string>
{ {
"- Default trees :", GetString("- Default trees :"),
" 'basic', 'sakura', 'willow', 'boreal', 'mahogany', 'ebonwood', 'shadewood', 'pearlwood'.", GetString(" 'basic', 'sakura', 'willow', 'boreal', 'mahogany', 'ebonwood', 'shadewood', 'pearlwood'."),
"- Palm trees :", GetString("- Palm trees :"),
" 'palm', 'corruptpalm', 'crimsonpalm', 'hallowpalm'.", GetString(" 'palm', 'corruptpalm', 'crimsonpalm', 'hallowpalm'."),
"- Gem trees :", GetString("- Gem trees :"),
" 'topaz', 'amethyst', 'sapphire', 'emerald', 'ruby', 'diamond', 'amber'.", GetString(" 'topaz', 'amethyst', 'sapphire', 'emerald', 'ruby', 'diamond', 'amber'."),
"- Misc :", GetString("- Misc :"),
" 'cactus', 'herb', 'mushroom'." GetString(" 'cactus', 'herb', 'mushroom'.")
}; };
PaginationTools.SendPage(args.Player, pageNumber, lines, PaginationTools.SendPage(args.Player, pageNumber, lines,
new PaginationTools.Settings new PaginationTools.Settings
{ {
HeaderFormat = "Trees types & misc available to use. ({0}/{1}):", HeaderFormat = GetString("Trees types & misc available to use. ({0}/{1}):"),
FooterFormat = "Type {0}grow help {{0}} for more sub-commands.".SFormat(Commands.Specifier) FooterFormat = GetString("Type {0}grow help {{0}} for more sub-commands.", Commands.Specifier)
} }
); );
} }
@ -6461,7 +6461,7 @@ namespace TShockAPI
{ {
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; return false;
} }
@ -6531,91 +6531,91 @@ namespace TShockAPI
} }
case "basic": case "basic":
growTree(TileID.Grass, "Basic Tree"); growTree(TileID.Grass, GetString("Basic Tree"));
break; break;
case "boreal": case "boreal":
growTree(TileID.SnowBlock, "Boreal Tree"); growTree(TileID.SnowBlock, GetString("Boreal Tree"));
break; break;
case "mahogany": case "mahogany":
growTree(TileID.JungleGrass, "Rich Mahogany"); growTree(TileID.JungleGrass, GetString("Rich Mahogany"));
break; break;
case "sakura": case "sakura":
growTreeByType(TileID.VanityTreeSakura, "Sakura Tree"); growTreeByType(TileID.VanityTreeSakura, GetString("Sakura Tree"));
break; break;
case "willow": case "willow":
growTreeByType(TileID.VanityTreeYellowWillow, "Willow Tree"); growTreeByType(TileID.VanityTreeYellowWillow, GetString("Willow Tree"));
break; break;
case "shadewood": case "shadewood":
if(!growTree(TileID.CrimsonGrass, "Shadewood Tree", true)) if(!growTree(TileID.CrimsonGrass, GetString("Shadewood Tree"), true))
return; return;
break; break;
case "ebonwood": case "ebonwood":
if(!growTree(TileID.CorruptGrass, "Ebonwood Tree", true)) if(!growTree(TileID.CorruptGrass, GetString("Ebonwood Tree"), true))
return; return;
break; break;
case "pearlwood": case "pearlwood":
if(!growTree(TileID.HallowedGrass, "Pearlwood Tree", true)) if(!growTree(TileID.HallowedGrass, GetString("Pearlwood Tree"), true))
return; return;
break; break;
case "palm": case "palm":
growPalmTree(TileID.Sand, TileID.HardenedSand, "Desert Palm"); growPalmTree(TileID.Sand, TileID.HardenedSand, GetString("Desert Palm"));
break; break;
case "hallowpalm": case "hallowpalm":
if(!growPalmTree(TileID.Pearlsand, TileID.HallowHardenedSand, "Hallow Palm", true)) if(!growPalmTree(TileID.Pearlsand, TileID.HallowHardenedSand, GetString("Hallow Palm"), true))
return; return;
break; break;
case "crimsonpalm": case "crimsonpalm":
if(!growPalmTree(TileID.Crimsand, TileID.CrimsonHardenedSand, "Crimson Palm", true)) if(!growPalmTree(TileID.Crimsand, TileID.CrimsonHardenedSand, GetString("Crimson Palm"), true))
return; return;
break; break;
case "corruptpalm": case "corruptpalm":
if(!growPalmTree(TileID.Ebonsand, TileID.CorruptHardenedSand, "Corruption Palm", true)) if(!growPalmTree(TileID.Ebonsand, TileID.CorruptHardenedSand, GetString("Corruption Palm"), true))
return; return;
break; break;
case "topaz": case "topaz":
growTreeByType(TileID.TreeTopaz, "Topaz Gemtree", 1); growTreeByType(TileID.TreeTopaz, GetString("Topaz Gemtree"), 1);
break; break;
case "amethyst": case "amethyst":
growTreeByType(TileID.TreeAmethyst, "Amethyst Gemtree", 1); growTreeByType(TileID.TreeAmethyst, GetString("Amethyst Gemtree"), 1);
break; break;
case "sapphire": case "sapphire":
growTreeByType(TileID.TreeSapphire, "Sapphire Gemtree", 1); growTreeByType(TileID.TreeSapphire, GetString("Sapphire Gemtree"), 1);
break; break;
case "emerald": case "emerald":
growTreeByType(TileID.TreeEmerald, "Emerald Gemtree", 1); growTreeByType(TileID.TreeEmerald, GetString("Emerald Gemtree"), 1);
break; break;
case "ruby": case "ruby":
growTreeByType(TileID.TreeRuby, "Ruby Gemtree", 1); growTreeByType(TileID.TreeRuby, GetString("Ruby Gemtree"), 1);
break; break;
case "diamond": case "diamond":
growTreeByType(TileID.TreeDiamond, "Diamond Gemtree", 1); growTreeByType(TileID.TreeDiamond, GetString("Diamond Gemtree"), 1);
break; break;
case "amber": case "amber":
growTreeByType(TileID.TreeAmber, "Amber Gemtree", 1); growTreeByType(TileID.TreeAmber, GetString("Amber Gemtree"), 1);
break; break;
case "cactus": case "cactus":
Main.tile[x, y].type = TileID.Sand; Main.tile[x, y].type = TileID.Sand;
WorldGen.GrowCactus(x, y); WorldGen.GrowCactus(x, y);
name = "Cactus"; name = GetString("Cactus");
break; break;
case "herb": case "herb":
@ -6623,23 +6623,23 @@ namespace TShockAPI
Main.tile[x, y].frameX = 36; Main.tile[x, y].frameX = 36;
Main.tile[x, y].type = TileID.MatureHerbs; Main.tile[x, y].type = TileID.MatureHerbs;
WorldGen.GrowAlch(x, y); WorldGen.GrowAlch(x, y);
name = "Herb"; name = GetString("Herb");
break; break;
case "mushroom": case "mushroom":
prepareAreaForGrow(TileID.MushroomGrass); prepareAreaForGrow(TileID.MushroomGrass);
WorldGen.GrowShroom(x, y); WorldGen.GrowShroom(x, y);
name = "Glowing Mushroom Tree"; name = GetString("Glowing Mushroom Tree");
break; break;
default: default:
args.Player.SendErrorMessage("Unknown plant!"); args.Player.SendErrorMessage(GetString("Unknown plant!"));
return; return;
} }
if (args.Parameters.Count == 1) if (args.Parameters.Count == 1)
{ {
args.Player.SendTileSquareCentered(x - 2, y - 20, 25); 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 +6650,14 @@ namespace TShockAPI
{ {
if (!args.Player.HasPermission(Permissions.godmodeother)) 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; return;
} }
string plStr = String.Join(" ", args.Parameters); string plStr = String.Join(" ", args.Parameters);
var players = TSPlayer.FindByNameOrID(plStr); var players = TSPlayer.FindByNameOrID(plStr);
if (players.Count == 0) if (players.Count == 0)
{ {
args.Player.SendErrorMessage("Invalid player!"); args.Player.SendErrorMessage(GetString("Invalid player!"));
return; return;
} }
else if (players.Count > 1) else if (players.Count > 1)
@ -6672,7 +6672,7 @@ namespace TShockAPI
} }
else if (!args.Player.RealPlayer) 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; return;
} }
else else
@ -6688,12 +6688,16 @@ namespace TShockAPI
if (playerToGod != args.Player) 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)) 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));
} }
} }

View file

@ -2955,10 +2955,10 @@ namespace TShockAPI
} }
else if (!TShock.Config.Settings.AnonymousBossInvasions) 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 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 (Main.npc[id].netID == NPCID.CultistDevote || Main.npc[id].netID == NPCID.CultistArcherBlue)
@ -3523,52 +3523,52 @@ namespace TShockAPI
switch (thingType) switch (thingType)
{ {
case -14: case -14:
thing = "has sent a request to the bunny delivery service"; thing = GetString("has sent a request to the bunny delivery service");
break; break;
case -13: case -13:
thing = "has sent a request to the dog delivery service"; thing = GetString("has sent a request to the dog delivery service");
break; break;
case -12: case -12:
thing = "has sent a request to the cat delivery service"; thing = GetString("has sent a request to the cat delivery service");
break; break;
case -11: case -11:
thing = "applied advanced combat techniques"; thing = GetString("applied advanced combat techniques");
break; break;
case -10: case -10:
thing = "summoned a Blood Moon"; thing = GetString("summoned a Blood Moon");
break; break;
case -8: case -8:
thing = "summoned a Moon Lord"; thing = GetString("summoned a Moon Lord");
break; break;
case -7: case -7:
thing = "summoned a Martian invasion"; thing = GetString("summoned a Martian invasion");
break; break;
case -6: case -6:
thing = "summoned an eclipse"; thing = GetString("summoned an eclipse");
break; break;
case -5: case -5:
thing = "summoned a frost moon"; thing = GetString("summoned a frost moon");
break; break;
case -4: case -4:
thing = "summoned a pumpkin moon"; thing = GetString("summoned a pumpkin moon");
break; break;
case -3: case -3:
thing = "summoned the Pirates"; thing = GetString("summoned the Pirates");
break; break;
case -2: case -2:
thing = "summoned the Snow Legion"; thing = GetString("summoned the Snow Legion");
break; break;
case -1: case -1:
thing = "summoned a Goblin Invasion"; thing = GetString("summoned a Goblin Invasion");
break; break;
default: default:
thing = String.Format("summoned the {0}", npc.FullName); thing = GetString("summoned the {0}", npc.FullName);
break; break;
} }
if (TShock.Config.Settings.AnonymousBossInvasions) if (TShock.Config.Settings.AnonymousBossInvasions)
TShock.Utils.SendLogs(string.Format("{0} {1}!", args.Player.Name, thing), Color.PaleVioletRed, args.Player); TShock.Utils.SendLogs(GetString("{0} {1}!", args.Player.Name, thing), Color.PaleVioletRed, args.Player);
else else
TShock.Utils.Broadcast(String.Format("{0} {1}!", args.Player.Name, thing), 175, 75, 255); TShock.Utils.Broadcast(GetString("{0} {1}!", args.Player.Name, thing), 175, 75, 255);
return false; return false;
} }
@ -4114,9 +4114,9 @@ namespace TShockAPI
} }
if (TShock.Config.Settings.AnonymousBossInvasions) 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 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; return false;
} }

View file

@ -134,7 +134,7 @@ namespace TShockAPI
if (TShock.Config.Settings.AnnounceSave) if (TShock.Config.Settings.AnnounceSave)
TShock.Utils.Broadcast("World saved.", Color.Yellow); TShock.Utils.Broadcast("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) catch (Exception e)
{ {
@ -160,7 +160,7 @@ namespace TShockAPI
public override string ToString() public override string ToString()
{ {
return string.Format("resetTime {0}, direct {1}", resetTime, direct); return GetString("resetTime {0}, direct {1}", resetTime, direct);
} }
} }
} }

View file

@ -36,7 +36,7 @@ namespace TShockAPI
public override string ToString() public override string ToString()
{ {
return string.Format("Message: {0}: {1}: {2}", return GetString("Message: {0}: {1}: {2}",
caller, logLevel.ToString().ToUpper(), message); caller, logLevel.ToString().ToUpper(), message);
} }
} }
@ -314,7 +314,7 @@ namespace TShockAPI
{ {
caller = "TShock", caller = "TShock",
logLevel = TraceLevel.Error, 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) timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
}); });
} }
@ -343,7 +343,7 @@ namespace TShockAPI
foreach (var logInfo in _failures) 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); TraceLevel.Error);
} }
_failures.Clear(); _failures.Clear();

View file

@ -69,7 +69,7 @@ namespace TShockAPI
/// <summary>LogFormat - This is the log format, which is never set again.</summary> /// <summary>LogFormat - This is the log format, which is never set again.</summary>
private static string LogFormat = LogFormatDefault; private static string LogFormat = LogFormatDefault;
/// <summary>LogPathDefault - The default log path.</summary> /// <summary>LogPathDefault - The default log path.</summary>
private const string LogPathDefault = "tshock/logs"; private const string LogPathDefault = "tshock/logs"
/// <summary>This is the log path, which is initially set to the default log path, and then to the config file log path later.</summary> /// <summary>This is the log path, which is initially set to the default log path, and then to the config file log path later.</summary>
private static string LogPath = LogPathDefault; private static string LogPath = LogPathDefault;
/// <summary>LogClear - Determines whether or not the log file should be cleared on initialization.</summary> /// <summary>LogClear - Determines whether or not the log file should be cleared on initialization.</summary>
@ -443,8 +443,8 @@ namespace TShockAPI
if(Log is not null) Log.ConsoleError(message); if(Log is not null) Log.ConsoleError(message);
else Console.WriteLine(message); else Console.WriteLine(message);
}; };
SafeError("TShock encountered a problem from which it cannot recover. The following message may help diagnose the problem."); SafeError(GetString("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("Until the problem is resolved, TShock will not be able to start (and will crash on startup)."));
SafeError(ex.ToString()); SafeError(ex.ToString());
Environment.Exit(1); Environment.Exit(1);
} }
@ -780,7 +780,7 @@ namespace TShockAPI
{ {
if (!string.IsNullOrWhiteSpace(cfg)) 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); Main.instance.LoadDedConfig(cfg);
} }
}) })
@ -791,7 +791,7 @@ namespace TShockAPI
if (int.TryParse(p, out port)) if (int.TryParse(p, out port))
{ {
Netplay.ListenPort = 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)) if (!string.IsNullOrWhiteSpace(world))
{ {
Main.instance.SetWorldName(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)) if (IPAddress.TryParse(ip, out addr))
{ {
Netplay.ServerIP = 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 else
{ {
@ -846,7 +846,7 @@ namespace TShockAPI
throw new InvalidOperationException("Invalid value given for command line argument \"-worldevil\"."); 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; WorldGen.WorldGenParam_Evil = worldEvil;
}) })
@ -978,8 +978,8 @@ namespace TShockAPI
if (File.Exists(Path.Combine(SavePath, "setup-code.txt"))) 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(GetString("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("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")); File.Delete(Path.Combine(SavePath, "setup-code.txt"));
} }
@ -994,8 +994,8 @@ namespace TShockAPI
var r = new Random((int)DateTime.Now.ToBinary()); var r = new Random((int)DateTime.Now.ToBinary());
SetupToken = r.Next(100000, 10000000); SetupToken = r.Next(100000, 10000000);
Console.ForegroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("To setup the server, join the game and type {0}setup {1}", Commands.Specifier, SetupToken); Console.WriteLine(GetString("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("This token will display until disabled by verification. ({0}setup)", Commands.Specifier));
Console.ResetColor(); Console.ResetColor();
File.WriteAllText(Path.Combine(SavePath, "setup-code.txt"), SetupToken.ToString()); 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"))); SetupToken = Convert.ToInt32(File.ReadAllText(Path.Combine(SavePath, "setup-code.txt")));
Console.ForegroundColor = ConsoleColor.Yellow; 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(GetString("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(GetString("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("This token will display until disabled by verification. ({0}setup)", Commands.Specifier));
Console.ResetColor(); Console.ResetColor();
} }
@ -1465,7 +1465,7 @@ namespace TShockAPI
if (!Commands.HandleCommand(tsplr, text)) if (!Commands.HandleCommand(tsplr, text))
{ {
// This is required in case anyone makes HandleCommand return false again // 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); Log.ConsoleError("Unable to parse command '{0}' from player {1}.", text, tsplr.Name);
} }
} }
@ -1483,7 +1483,7 @@ namespace TShockAPI
} }
else if (tsplr.mute) else if (tsplr.mute)
{ {
tsplr.SendErrorMessage("You are muted!"); tsplr.SendErrorMessage(GetString("You are muted!"));
args.Handled = true; args.Handled = true;
} }
else if (!TShock.Config.Settings.EnableChatAboveHeads) else if (!TShock.Config.Settings.EnableChatAboveHeads)
@ -1638,22 +1638,22 @@ namespace TShockAPI
if (Config.Settings.EnableGeoIP && TShock.Geo != null) 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(), player.Group.Name, player.Country, TShock.Utils.GetActivePlayerCount(),
TShock.Config.Settings.MaxSlots); TShock.Config.Settings.MaxSlots));
if (!player.SilentJoinInProgress) 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 else
{ {
Log.Info("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP, 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); player.Group.Name, TShock.Utils.GetActivePlayerCount(), TShock.Config.Settings.MaxSlots));
if (!player.SilentJoinInProgress) 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) 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); player.SendFileTextAsMessage(FileTools.MotdPath);
@ -1670,12 +1670,12 @@ namespace TShockAPI
if (Main.ServerSideCharacter) if (Main.ServerSideCharacter)
{ {
player.IsDisabledForSSC = true; 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; player.LoginHarassed = true;
} }
else if (Config.Settings.RequireLogin) 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; player.LoginHarassed = true;
} }
} }
@ -1685,7 +1685,7 @@ namespace TShockAPI
if (Config.Settings.RememberLeavePos && (RememberedPos.GetLeavePos(player.Name, player.IP) != Vector2.Zero) && !player.LoginHarassed) if (Config.Settings.RememberLeavePos && (RememberedPos.GetLeavePos(player.Name, player.IP) != Vector2.Zero) && !player.LoginHarassed)
{ {
player.RPPending = 3; 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; args.Handled = true;

View file

@ -133,7 +133,7 @@ namespace TShockAPI
{ {
TSPlayer.All.SendMessage(msg, red, green, blue); TSPlayer.All.SendMessage(msg, red, green, blue);
TSPlayer.Server.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));
} }
/// <summary>>Broadcast - Broadcasts a message to all players on the server, as well as the server console, and the logs.</summary> /// <summary>>Broadcast - Broadcasts a message to all players on the server, as well as the server console, and the logs.</summary>
@ -156,7 +156,7 @@ namespace TShockAPI
{ {
TSPlayer.All.SendMessageFromPlayer(msg, red, green, blue, ply); TSPlayer.All.SendMessageFromPlayer(msg, red, green, blue, ply);
TSPlayer.Server.SendMessage(Main.player[ply].name + ": " + msg, red, green, blue); 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));
} }
/// <summary> /// <summary>
@ -1060,7 +1060,7 @@ namespace TShockAPI
/// <param name="empty">If the server is empty; determines if we should use Utils.GetActivePlayerCount() for player count or 0.</param> /// <param name="empty">If the server is empty; determines if we should use Utils.GetActivePlayerCount() for player count or 0.</param>
internal void SetConsoleTitle(bool empty) 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 + " - " : "", !string.IsNullOrWhiteSpace(TShock.Config.Settings.ServerName) ? TShock.Config.Settings.ServerName + " - " : "",
empty ? 0 : GetActivePlayerCount(), empty ? 0 : GetActivePlayerCount(),
TShock.Config.Settings.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum); TShock.Config.Settings.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum);