diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index e750e8d6..9ef0471c 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -1266,16 +1266,16 @@ namespace TShockAPI { if (TShock.Config.Settings.KickOnProjectileThresholdBroken) { - args.Player.Kick(GetString("Projectile update threshold exceeded {0}.", TShock.Config.Settings.ProjectileThreshold)); + args.Player.Kick(GetString("Projectile create threshold exceeded {0}.", TShock.Config.Settings.ProjectileThreshold)); } else { - args.Player.Disable(GetString("Reached projectile update threshold."), DisableFlags.WriteToLogAndConsole); + args.Player.Disable(GetString("Reached projectile create threshold."), DisableFlags.WriteToLogAndConsole); args.Player.RemoveProjectile(ident, owner); } - TShock.Log.ConsoleDebug(GetString("Bouncer / OnNewProjectile rejected from projectile update threshold from {0} {1}/{2}", args.Player.Name, args.Player.ProjectileThreshold, TShock.Config.Settings.ProjectileThreshold)); - TShock.Log.ConsoleDebug(GetString("If this player wasn't hacking, please report the projectile update threshold they were disabled for to TShock so we can improve this!")); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnNewProjectile rejected from projectile create threshold from {0} {1}/{2}", args.Player.Name, args.Player.ProjectileThreshold, TShock.Config.Settings.ProjectileThreshold)); + TShock.Log.ConsoleDebug(GetString("If this player wasn't hacking, please report the projectile create threshold they were disabled for to TShock so we can improve this!")); args.Handled = true; return; } @@ -1995,21 +1995,21 @@ namespace TShockAPI if (npc.townNPC) { if (type != BuffID.Poisoned - && type != BuffID.OnFire - && type != BuffID.Confused - && type != BuffID.CursedInferno - && type != BuffID.Ichor - && type != BuffID.Venom - && type != BuffID.Midas - && type != BuffID.Wet - && type != BuffID.Lovestruck - && type != BuffID.Stinky - && type != BuffID.Slimed - && type != BuffID.DryadsWard - && type != BuffID.GelBalloonBuff - && type != BuffID.OnFire3 - && type != BuffID.Frostburn2 - && type != BuffID.Shimmer) + && type != BuffID.OnFire + && type != BuffID.Confused + && type != BuffID.CursedInferno + && type != BuffID.Ichor + && type != BuffID.Venom + && type != BuffID.Midas + && type != BuffID.Wet + && type != BuffID.Lovestruck + && type != BuffID.Stinky + && type != BuffID.Slimed + && type != BuffID.DryadsWard + && type != BuffID.GelBalloonBuff + && type != BuffID.OnFire3 + && type != BuffID.Frostburn2 + && type != BuffID.Shimmer) { detectedNPCBuffTimeCheat = true; } @@ -2587,7 +2587,7 @@ namespace TShockAPI } else { - TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected damage threshold2 from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.Settings.MaxDamage); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerDamage rejected damage threshold2 from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.Settings.MaxDamage)); args.Player.Disable(GetString("Player damage exceeded {0}.", TShock.Config.Settings.MaxDamage), DisableFlags.WriteToLogAndConsole); } args.Player.SendData(PacketTypes.PlayerHp, "", id); diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 58986697..d638311e 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -649,7 +649,7 @@ namespace TShockAPI string cmdName; if (index == 0) // Space after the command specifier should not be supported { - player.SendErrorMessage(GetString("Invalid command entered. Type {0}help for a list of valid commands.", Specifier)); + player.SendErrorMessage(GetString("You entered a space after {0} instead of a command. Type {0}help for a list of valid commands.", Specifier)); return true; } else if (index < 0) @@ -6455,7 +6455,10 @@ namespace TShockAPI if (time < 0 || time > timeLimit) time = timeLimit; target.SetBuff(id, time * 60); - 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 (target == user) + user.SendSuccessMessage(GetString($"You buffed yourself with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds.")); + else + target.SendSuccessMessage(GetString($"You have buffed {user.Name} with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds!")); if (!args.Silent && target != user) target.SendSuccessMessage(GetString($"{user.Name} has buffed you with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds!")); } diff --git a/TShockAPI/Configuration/ServerSideConfig.cs b/TShockAPI/Configuration/ServerSideConfig.cs index c542e1b7..044bbd5c 100644 --- a/TShockAPI/Configuration/ServerSideConfig.cs +++ b/TShockAPI/Configuration/ServerSideConfig.cs @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; @@ -117,10 +117,10 @@ namespace TShockAPI.Configuration var def = field.GetValue(defaults); - sb.AppendLine("## {0} ".SFormat(name)); - sb.AppendLine("{0}".SFormat(desc)); - sb.AppendLine("* **Field type**: `{0}`".SFormat(type)); - sb.AppendLine("* **Default**: `{0}`".SFormat(def)); + sb.AppendLine($"## {name} "); + sb.AppendLine($"{desc}"); + sb.AppendLine(GetString("* **Field type**: `{0}`", type)); + sb.AppendLine(GetString("* **Default**: `{0}`", def)); sb.AppendLine(); } diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs index b3bef64d..d6f9743e 100644 --- a/TShockAPI/Configuration/TShockConfig.cs +++ b/TShockAPI/Configuration/TShockConfig.cs @@ -314,7 +314,7 @@ namespace TShockAPI.Configuration /// The reason given if banning a mediumcore player on death. [Description("The reason given if banning a mediumcore player on death.")] - public string MediumcoreBanReason = "Death results in a ban"; + public string MediumcoreBanReason = GetString("Death results in a ban"); /// Disbales IP bans by default, if no arguments are passed to the ban command. [Description("Disbales IP bans by default, if no arguments are passed to the ban command.")] @@ -326,15 +326,15 @@ namespace TShockAPI.Configuration /// The reason given when kicking players for not being on the whitelist. [Description("The reason given when kicking players for not being on the whitelist.")] - public string WhitelistKickReason = "You are not on the whitelist."; + public string WhitelistKickReason = GetString("You are not on the whitelist."); /// The reason given when kicking players that attempt to join while the server is full. [Description("The reason given when kicking players that attempt to join while the server is full.")] - public string ServerFullReason = "Server is full"; + public string ServerFullReason = GetString("Server is full"); /// The reason given when kicking players that attempt to join while the server is full with no reserved slots available. [Description("The reason given when kicking players that attempt to join while the server is full with no reserved slots available.")] - public string ServerFullNoReservedReason = "Server is full. No reserved slots open."; + public string ServerFullNoReservedReason = GetString("Server is full. No reserved slots open."); /// Whether or not to kick hardcore players on death. [Description("Whether or not to kick hardcore players on death.")] @@ -342,7 +342,7 @@ namespace TShockAPI.Configuration /// The reason given when kicking hardcore players on death. [Description("The reason given when kicking hardcore players on death.")] - public string HardcoreKickReason = "Death results in a kick"; + public string HardcoreKickReason = GetString("Death results in a kick"); /// Whether or not to ban hardcore players on death. [Description("Whether or not to ban hardcore players on death.")] @@ -350,7 +350,7 @@ namespace TShockAPI.Configuration /// The reason given when banning hardcore players on death. [Description("The reason given when banning hardcore players on death.")] - public string HardcoreBanReason = "Death results in a ban"; + public string HardcoreBanReason = GetString("Death results in a ban"); /// If GeoIP is enabled, this will kick users identified as being under a proxy. [Description("If GeoIP is enabled, this will kick users identified as being under a proxy.")] @@ -489,7 +489,7 @@ namespace TShockAPI.Configuration /// The superadmin chat prefix. [Description("The superadmin chat prefix.")] - public string SuperAdminChatPrefix = "(Super Admin) "; + public string SuperAdminChatPrefix = GetString("(Super Admin) "); /// The superadmin chat suffix. [Description("The superadmin chat suffix.")] @@ -635,10 +635,10 @@ namespace TShockAPI.Configuration var def = field.GetValue(defaults); - sb.AppendLine("## {0} ".SFormat(name)); - sb.AppendLine("{0}".SFormat(desc)); - sb.AppendLine("* **Field type**: `{0}`".SFormat(type)); - sb.AppendLine("* **Default**: `{0}`".SFormat(def)); + sb.AppendLine($"## {name} "); + sb.AppendLine($"{desc}"); + sb.AppendLine(GetString("* **Field type**: `{0}`", type)); + sb.AppendLine(GetString("* **Default**: `{0}`", def)); sb.AppendLine(); } diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 03bf4316..5b954cd2 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2447,22 +2447,22 @@ namespace TShockAPI if (OnPlayerInfo(args.Player, args.Data, playerid, hair, skinVariant, difficulty, name)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected plugin phase {0}", name); - args.Player.Kick("A plugin on this server stopped your login.", true, true); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerInfo rejected plugin phase {0}", name)); + args.Player.Kick(GetString("A plugin on this server stopped your login."), true, true); return true; } if (name.Trim().Length == 0) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected name length 0"); - args.Player.Kick("You have been Bounced.", true, true); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerInfo rejected name length 0")); + args.Player.Kick(GetString("You have been Bounced."), true, true); return true; } if (name.Trim().StartsWith("tsi:") || name.Trim().StartsWith("tsn:")) { - TShock.Log.ConsoleDebug("GetDataHandlers / rejecting player for name prefix starting with tsi: or tsn:."); - args.Player.Kick("Illegal name: prefixes tsi: and tsn: are forbidden.", true, true); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / rejecting player for name prefix starting with tsi: or tsn:.")); + args.Player.Kick(GetString("Illegal name: prefixes tsi: and tsn: are forbidden."), true, true); return true; } @@ -2507,20 +2507,20 @@ namespace TShockAPI } if (TShock.Config.Settings.SoftcoreOnly && difficulty != 0) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected softcore required"); - args.Player.Kick("You need to join with a softcore player.", true, true); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerInfo rejected softcore required")); + args.Player.Kick(GetString("You need to join with a softcore player."), true, true); return true; } if (TShock.Config.Settings.MediumcoreOnly && difficulty < 1) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected mediumcore required"); - args.Player.Kick("You need to join with a mediumcore player or higher.", true, true); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerInfo rejected mediumcore required")); + args.Player.Kick(GetString("You need to join with a mediumcore player or higher."), true, true); return true; } if (TShock.Config.Settings.HardcoreOnly && difficulty < 2) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected hardcore required"); - args.Player.Kick("You need to join with a hardcore player.", true, true); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerInfo rejected hardcore required")); + args.Player.Kick(GetString("You need to join with a hardcore player."), true, true); return true; } args.Player.Difficulty = difficulty; @@ -2551,7 +2551,7 @@ namespace TShockAPI return true; if (args.Player.IgnoreSSCPackets) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerSlot rejected ignore ssc packets"); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerSlot rejected ignore ssc packets")); args.Player.SendData(PacketTypes.PlayerSlot, "", args.Player.Index, slot, prefix); return true; } @@ -2617,8 +2617,8 @@ namespace TShockAPI if (args.Player.PlayerData.exists && TShock.ServerSideCharacterConfig.Settings.WarnPlayersAboutBypassPermission) { 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."); + TShock.Log.ConsoleInfo(GetString($"{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(GetString("You may wish to consider removing the tshock.ignore.ssc permission or negating it for this player.")); } args.Player.PlayerData.CopyCharacter(args.Player); TShock.CharacterDB.InsertPlayerData(args.Player); @@ -2634,7 +2634,7 @@ namespace TShockAPI args.Player.IsDisabledForBannedWearable = false; args.Player.SendSuccessMessage(GetString($"Authenticated as {account.Name} successfully.")); - TShock.Log.ConsoleInfo($"{args.Player.Name} authenticated successfully as user {args.Player.Name}."); + TShock.Log.ConsoleInfo(GetString($"{args.Player.Name} authenticated successfully as user {args.Player.Name}.")); Hooks.PlayerHooks.OnPlayerPostLogin(args.Player); return true; } @@ -2666,7 +2666,7 @@ namespace TShockAPI if (TShock.Utils.GetActivePlayerCount() + 1 > TShock.Config.Settings.MaxSlots && !args.Player.HasPermission(Permissions.reservedslot)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleGetSection rejected reserve slot"); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleGetSection rejected reserve slot")); args.Player.Kick(TShock.Config.Settings.ServerFullReason, true, true); return true; } @@ -2679,7 +2679,7 @@ namespace TShockAPI { if (args.Player.Dead && args.Player.RespawnTimer > 0) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn rejected dead player spawn request {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawn rejected dead player spawn request {0}", args.Player.Name)); return true; } @@ -2697,7 +2697,7 @@ namespace TShockAPI args.Player.sX = Main.spawnTileX; args.Player.sY = Main.spawnTileY; args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48); - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn force teleport 'vanilla spawn' {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawn force teleport 'vanilla spawn' {0}", args.Player.Name)); } else if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY))) @@ -2708,7 +2708,7 @@ namespace TShockAPI if (((Main.tile[args.Player.sX, args.Player.sY - 1].active() && Main.tile[args.Player.sX, args.Player.sY - 1].type == TileID.Beds)) && (WorldGen.StartRoomCheck(args.Player.sX, args.Player.sY - 1))) { args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48); - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn force teleport phase 1 {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawn force teleport phase 1 {0}", args.Player.Name)); } } @@ -2717,7 +2717,7 @@ namespace TShockAPI if (((Main.tile[args.Player.sX, args.Player.sY - 1].active() && Main.tile[args.Player.sX, args.Player.sY - 1].type == TileID.Beds)) && (WorldGen.StartRoomCheck(args.Player.sX, args.Player.sY - 1))) { args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48); - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn force teleport phase 2 {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawn force teleport phase 2 {0}", args.Player.Name)); } } @@ -2732,7 +2732,7 @@ namespace TShockAPI { if (args.Player == null || args.TPlayer == null || args.Data == null) { - TShock.Log.ConsoleDebug("GetDataHandlers / OnPlayerUpdate rejected from null player."); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / OnPlayerUpdate rejected from null player.")); return true; } @@ -2754,7 +2754,7 @@ namespace TShockAPI { originalPosition = new Vector2?(args.Data.ReadVector2()); homePosition = new Vector2?(args.Data.ReadVector2()); - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerUpdate home position delta {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerUpdate home position delta {0}", args.Player.Name)); } if (OnPlayerUpdate(args.Player, args.Data, playerID, controls, miscData1, miscData2, miscData3, selectedItem, position, velocity, originalPosition, homePosition)) @@ -2774,7 +2774,7 @@ namespace TShockAPI if (max > TShock.Config.Settings.MaxHP && !args.Player.HasPermission(Permissions.ignorehp)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerHp rejected over max hp {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerHp rejected over max hp {0}", args.Player.Name)); args.Player.Disable("Maximum HP beyond limit", DisableFlags.WriteToLogAndConsole); return true; } @@ -2826,13 +2826,13 @@ namespace TShockAPI if (x >= Main.maxTilesX || y >= Main.maxTilesY || x < 0 || y < 0) // Check for out of range { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleDoorUse rejected out of range door {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleDoorUse rejected out of range door {0}", args.Player.Name)); return true; } if (action < 0 || action > 5) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleDoorUse rejected type 0 5 check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleDoorUse rejected type 0 5 check {0}", args.Player.Name)); return true; } @@ -2841,7 +2841,7 @@ namespace TShockAPI && 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); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleDoorUse rejected door gap check {0}", args.Player.Name)); return true; } @@ -2959,7 +2959,7 @@ namespace TShockAPI { 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}"); + TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleNpcStrike rejected npc strike {args.Player.Name}")); return true; } @@ -2969,7 +2969,7 @@ namespace TShockAPI { 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}"); + TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleNpcStrike rejected EoL summon from {args.Player.Name}")); return true; } else if (!TShock.Config.Settings.AnonymousBossInvasions) @@ -2986,7 +2986,7 @@ namespace TShockAPI { 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}"); + TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleNpcStrike rejected Cultist summon from {args.Player.Name}")); return true; } } @@ -3011,7 +3011,7 @@ namespace TShockAPI if (type == ProjectileID.Tombstone) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleProjectileKill rejected tombstone {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleProjectileKill rejected tombstone {0}", args.Player.Name)); args.Player.RemoveProjectile(ident, owner); return true; } @@ -3022,11 +3022,11 @@ namespace TShockAPI // https://github.com/Pryaxis/TShock/commit/a5aa9231239926f361b7246651e32144bbf28dda if (type == ProjectileID.Bomb || type == ProjectileID.DeathLaser) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleProjectileKill permitted skeletron prime exemption {0}", args.Player.Name); - TShock.Log.ConsoleDebug("If this was not skeletron prime related, please report to TShock what happened."); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleProjectileKill permitted skeletron prime exemption {0}", args.Player.Name)); + TShock.Log.ConsoleDebug(GetString("If this was not skeletron prime related, please report to TShock what happened.")); return false; } - TShock.Log.ConsoleDebug("GetDataHandlers / HandleProjectileKill rejected banned projectile {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleProjectileKill rejected banned projectile {0}", args.Player.Name)); args.Player.RemoveProjectile(ident, owner); return true; } @@ -3049,14 +3049,14 @@ namespace TShockAPI if (id != args.Player.Index) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTogglePvp rejected index mismatch {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTogglePvp rejected index mismatch {0}", args.Player.Name)); return true; } string pvpMode = TShock.Config.Settings.PvPMode.ToLowerInvariant(); if (pvpMode == "disabled" || pvpMode == "always" || (DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTogglePvp rejected fastswitch {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTogglePvp rejected fastswitch {0}", args.Player.Name)); args.Player.SendData(PacketTypes.TogglePvp, "", id); return true; } @@ -3091,7 +3091,7 @@ namespace TShockAPI item.netDefaults(type); if (stacks > item.maxStack) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleChestItem rejected max stacks {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleChestItem rejected max stacks {0}", args.Player.Name)); return true; } @@ -3116,7 +3116,7 @@ namespace TShockAPI if (!args.Player.HasBuildPermission(x, y) && TShock.Config.Settings.RegionProtectChests) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleChestActive rejected build permission and region check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleChestActive rejected build permission and region check {0}", args.Player.Name)); args.Player.SendData(PacketTypes.ChestOpen, "", -1); return true; } @@ -3141,7 +3141,7 @@ namespace TShockAPI { if (args.Player == null || args.TPlayer == null || args.Data == null) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerZone rejected null check"); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerZone rejected null check")); return true; } @@ -3209,7 +3209,7 @@ namespace TShockAPI 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.Log.ConsoleInfo(GetString($"{args.Player.Name} authenticated successfully as user {args.Player.Name}.")); TShock.UserAccounts.SetUserAccountUUID(account, args.Player.UUID); Hooks.PlayerHooks.OnPlayerPostLogin(args.Player); return true; @@ -3228,11 +3228,11 @@ namespace TShockAPI NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index); return true; } - args.Player.Kick("Invalid server password.", true, true); + args.Player.Kick(GetString("Invalid server password."), true, true); return true; } - args.Player.Kick("You have been Bounced.", true, true); + args.Player.Kick(GetParticularString("Likely non-vanilla client send zero-length password", "You have been Bounced for invalid password."), true, true); return true; } @@ -3247,21 +3247,21 @@ namespace TShockAPI //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()) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcTalk rejected npc talk {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleNpcTalk rejected npc talk {0}", args.Player.Name)); args.Player.SendData(PacketTypes.NpcTalk, "", plr, -1); return true; } if (args.Player.IsBouncerThrottled()) { - TShock.Log.ConsoleDebug("Bouncer / HandleNpcTalk rejected from bouncer throttle from {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("Bouncer / HandleNpcTalk rejected from bouncer throttle from {0}", args.Player.Name)); return true; } // -1 is a magic value, represents not talking to an NPC if (npc < -1 || npc >= Main.maxNPCs) { - TShock.Log.ConsoleDebug("Bouncer / HandleNpcTalk rejected from bouncer out of bounds from {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("Bouncer / HandleNpcTalk rejected from bouncer out of bounds from {0}", args.Player.Name)); return true; } return false; @@ -3286,7 +3286,7 @@ namespace TShockAPI if (max > TShock.Config.Settings.MaxMP && !args.Player.HasPermission(Permissions.ignoremp)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerMana rejected max mana {0} {1}/{2}", args.Player.Name, max, TShock.Config.Settings.MaxMP); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerMana rejected max mana {0} {1}/{2}", args.Player.Name, max, TShock.Config.Settings.MaxMP)); args.Player.Disable("Maximum MP beyond limit", DisableFlags.WriteToLogAndConsole); return true; } @@ -3313,7 +3313,7 @@ namespace TShockAPI if ((DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5) { args.Player.SendData(PacketTypes.PlayerTeam, "", id); - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerTeam rejected team fastswitch {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerTeam rejected team fastswitch {0}", args.Player.Name)); return true; } @@ -3331,7 +3331,7 @@ namespace TShockAPI if (x < 0 || y < 0 || x >= Main.maxTilesX || y >= Main.maxTilesY) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSignRead rejected out of bounds {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSignRead rejected out of bounds {0}", args.Player.Name)); return true; } @@ -3351,14 +3351,14 @@ namespace TShockAPI if (!args.Player.HasBuildPermission(x, y)) { args.Player.SendData(PacketTypes.SignNew, "", id); - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSign rejected sign on build permission {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSign rejected sign on build permission {0}", args.Player.Name)); return true; } if (!args.Player.IsInRange(x, y)) { args.Player.SendData(PacketTypes.SignNew, "", id); - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSign rejected sign range check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSign rejected sign range check {0}", args.Player.Name)); return true; } return false; @@ -3393,7 +3393,7 @@ namespace TShockAPI if (Netplay.Clients[args.TPlayer.whoAmI].State < 2 && (buff == 156 || buff == 47 || buff == 149)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerBuffList zeroed player buff due to below state 2 {0} {1}", args.Player.Name, buff); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerBuffList zeroed player buff due to below state 2 {0} {1}", args.Player.Name, buff)); buff = 0; } @@ -3408,7 +3408,7 @@ namespace TShockAPI } } - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerBuffList handled event and sent data {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerBuffList handled event and sent data {0}", args.Player.Name)); NetMessage.SendData((int)PacketTypes.PlayerBuff, -1, args.Player.Index, NetworkText.Empty, args.Player.Index); return true; } @@ -3423,7 +3423,7 @@ namespace TShockAPI if (type == 1 && TShock.Config.Settings.DisableDungeonGuardian) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected type 1 for {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpecial rejected type 1 for {0}", args.Player.Name)); args.Player.SendMessage(GetString("The Dungeon Guardian returned you to your spawn point."), Color.Purple); args.Player.Spawn(PlayerSpawnContext.RecallFromItem); return true; @@ -3433,13 +3433,13 @@ namespace TShockAPI { if (!args.Player.HasPermission(Permissions.usesundial)) { - TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission {args.Player.Name}"); + TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission {args.Player.Name}")); args.Player.SendErrorMessage(GetString("You do not have permission to use the Enchanted Sundial.")); return true; } else if (TShock.Config.Settings.ForceTime != "normal") { - TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission (ForceTime) {args.Player.Name}"); + TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission (ForceTime) {args.Player.Name}")); if (!args.Player.HasPermission(Permissions.cfgreload)) { args.Player.SendErrorMessage(GetString("You cannot use the Enchanted Sundial because time is stopped.")); @@ -3489,7 +3489,7 @@ namespace TShockAPI if (!args.Player.HasPermission(Permissions.movenpc)) { - TShock.Log.ConsoleDebug("GetDataHandlers / UpdateNPCHome rejected no permission {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / UpdateNPCHome rejected no permission {0}", args.Player.Name)); 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)); @@ -3504,7 +3504,7 @@ namespace TShockAPI { if (args.Player.IsBouncerThrottled()) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected bouner throttled {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawnBoss rejected bouner throttled {0}", args.Player.Name)); return true; } @@ -3514,21 +3514,21 @@ namespace TShockAPI var isKnownBoss = thingType > 0 && thingType < Main.maxNPCTypes && NPCID.Sets.MPAllowedEnemies[thingType]; if ((isKnownBoss || thingType == -16) && !args.Player.HasPermission(Permissions.summonboss)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected boss {0} {1}", args.Player.Name, thingType); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawnBoss rejected boss {0} {1}", args.Player.Name, thingType)); 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); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawnBoss rejected invasion {0} {1}", args.Player.Name, thingType)); 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); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawnBoss rejected pet {0} {1}", args.Player.Name, thingType)); args.Player.SendErrorMessage(GetString("You do not have permission to spawn pets.")); return true; } @@ -3619,7 +3619,7 @@ namespace TShockAPI if (x < 0 || y < 0 || x >= Main.maxTilesX || y >= Main.maxTilesY || t > Main.numTileColors) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected range check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePaintTile rejected range check {0}", args.Player.Name)); return true; } if (OnPaintTile(args.Player, args.Data, x, y, t)) @@ -3637,7 +3637,7 @@ namespace TShockAPI !args.Player.Accessories.Any(HasPaintSprayerAbilities) && !args.Player.Inventory.Any(HasPaintSprayerAbilities)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected select consistency {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePaintTile rejected select consistency {0}", args.Player.Name)); args.Player.SendData(PacketTypes.PaintTile, "", x, y, Main.tile[x, y].color()); return true; } @@ -3646,7 +3646,7 @@ namespace TShockAPI !args.Player.HasPaintPermission(x, y) || !args.Player.IsInRange(x, y)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected throttle/permission/range check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePaintTile rejected throttle/permission/range check {0}", args.Player.Name)); args.Player.SendData(PacketTypes.PaintTile, "", x, y, Main.tile[x, y].color()); return true; } @@ -3666,7 +3666,7 @@ namespace TShockAPI if (x < 0 || y < 0 || x >= Main.maxTilesX || y >= Main.maxTilesY || t > Main.numTileColors) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintWall rejected range check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePaintWall rejected range check {0}", args.Player.Name)); return true; } if (OnPaintWall(args.Player, args.Data, x, y, t)) @@ -3684,7 +3684,7 @@ namespace TShockAPI !args.Player.Accessories.Any(HasPaintSprayerAbilities) && !args.Player.Inventory.Any(HasPaintSprayerAbilities)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintWall rejected selector consistency {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePaintWall rejected selector consistency {0}", args.Player.Name)); args.Player.SendData(PacketTypes.PaintWall, "", x, y, Main.tile[x, y].wallColor()); return true; } @@ -3693,7 +3693,7 @@ namespace TShockAPI !args.Player.HasPaintPermission(x, y) || !args.Player.IsInRange(x, y)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintWall rejected throttle/permission/range {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePaintWall rejected throttle/permission/range {0}", args.Player.Name)); args.Player.SendData(PacketTypes.PaintWall, "", x, y, Main.tile[x, y].wallColor()); return true; } @@ -3741,7 +3741,7 @@ namespace TShockAPI //Rod of Discord teleport (usually (may be used by modded clients to teleport)) if (type == 0 && !args.Player.HasPermission(Permissions.rod)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected rod type {0} {1}", args.Player.Name, type); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleport rejected rod type {0} {1}", args.Player.Name, type)); 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; @@ -3750,7 +3750,7 @@ namespace TShockAPI //NPC teleport if (type == 1 && id >= Main.maxNPCs) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected npc teleport {0} {1}", args.Player.Name, type); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleport rejected npc teleport {0} {1}", args.Player.Name, type)); return true; } @@ -3759,13 +3759,13 @@ namespace TShockAPI { if (id >= Main.maxPlayers || Main.player[id] == null || TShock.Players[id] == null) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected p2p extents {0} {1}", args.Player.Name, type); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleport rejected p2p extents {0} {1}", args.Player.Name, type)); return true; } if (!args.Player.HasPermission(Permissions.wormhole)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected p2p wormhole permission {0} {1}", args.Player.Name, type); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleport rejected p2p wormhole permission {0} {1}", args.Player.Name, type)); 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; @@ -3793,7 +3793,7 @@ namespace TShockAPI if (Main.npc[npcID]?.catchItem == 0) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleCatchNpc catch zero {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleCatchNpc catch zero {0}", args.Player.Name)); Main.npc[npcID].active = true; NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcID); return true; @@ -3801,7 +3801,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleCatchNpc rejected catch npc {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleCatchNpc rejected catch npc {0}", args.Player.Name)); return true; } @@ -3829,7 +3829,7 @@ namespace TShockAPI void Fail(string tpItem) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected permissions {0} {1}", args.Player.Name, type); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleportationPotion rejected permissions {0} {1}", args.Player.Name, type)); args.Player.SendErrorMessage(GetString("You do not have permission to teleport using {0}.", tpItem)); } @@ -3839,7 +3839,7 @@ namespace TShockAPI if (args.Player.ItemInHand.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); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type)); return true; } @@ -3855,7 +3855,7 @@ namespace TShockAPI args.Player.ItemInHand.type != ItemID.ShellphoneOcean && args.Player.SelectedItem.type != ItemID.ShellphoneOcean) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type)); return true; } @@ -3878,7 +3878,7 @@ namespace TShockAPI args.Player.ItemInHand.type != ItemID.ShellphoneHell && args.Player.SelectedItem.type != ItemID.ShellphoneHell) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type)); return true; } @@ -3898,7 +3898,7 @@ namespace TShockAPI case 3: // Shellphone (Spawn) if (args.Player.ItemInHand.type != ItemID.ShellphoneSpawn && args.Player.SelectedItem.type != ItemID.ShellphoneSpawn) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type)); return true; } break; @@ -3917,7 +3917,7 @@ namespace TShockAPI private static bool HandleNumberOfAnglerQuestsCompleted(GetDataHandlerArgs args) { // Never sent by vanilla client, ignore this - TShock.Log.ConsoleDebug("GetDataHandlers / HandleNumberOfAnglerQuestsCompleted surprise packet! Someone tell the TShock team! {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleNumberOfAnglerQuestsCompleted surprise packet! Someone tell the TShock team! {0}", args.Player.Name)); return true; } @@ -3996,33 +3996,33 @@ namespace TShockAPI if (position.X < 0 || position.X >= (Main.maxTilesX * 16.0f) || position.Y < 0 || position.Y >= (Main.maxTilesY * 16.0f)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected extents check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSyncExtraValue rejected extents check {0}", args.Player.Name)); return true; } if (!Main.expertMode && !Main.masterMode) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected expert/master mode check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSyncExtraValue rejected expert/master mode check {0}", args.Player.Name)); return true; } if (npcIndex < 0 || npcIndex >= Main.npc.Length) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected npc id out of bounds check - NPC ID: {0}", npcIndex); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSyncExtraValue rejected npc id out of bounds check - NPC ID: {0}", npcIndex)); return true; } var npc = Main.npc[npcIndex]; if (npc == null) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected npc is null - NPC ID: {0}", npcIndex); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSyncExtraValue rejected npc is null - NPC ID: {0}", npcIndex)); return true; } var distanceFromCoinPacketToNpc = Utils.Distance(position, npc.position); 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); + TShock.Log.ConsoleDebug(GetString("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; } @@ -4039,7 +4039,7 @@ namespace TShockAPI { if (projectile.owner != args.TPlayer.whoAmI) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleKillPortal rejected owner mismatch check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleKillPortal rejected owner mismatch check {0}", args.Player.Name)); return true; } } @@ -4076,14 +4076,14 @@ namespace TShockAPI if (projectile == null || !projectile.active) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcTeleportPortal rejected null check {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleNpcTeleportPortal rejected null check {0}", args.Player.Name)); NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcIndex); return true; } if (projectile.type != ProjectileID.PortalGunGate) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcTeleportPortal rejected not thinking with portals {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleNpcTeleportPortal rejected not thinking with portals {0}", args.Player.Name)); NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcIndex); return true; } @@ -4123,7 +4123,7 @@ namespace TShockAPI { if (args.Player != null && !args.Player.HasPermission(Permissions.toggleparty)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleToggleParty rejected no party {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleToggleParty rejected no party {0}", args.Player.Name)); args.Player.SendErrorMessage(GetString("You do not have permission to start a party.")); return true; } @@ -4135,13 +4135,13 @@ namespace TShockAPI { if (args.Player.IsBouncerThrottled()) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleOldOnesArmy rejected throttled {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleOldOnesArmy rejected throttled {0}", args.Player.Name)); return true; } if (!args.Player.HasPermission(Permissions.startdd2)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleOldOnesArmy rejected permissions {0}", args.Player.Name); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleOldOnesArmy rejected permissions {0}", args.Player.Name)); args.Player.SendErrorMessage(GetString("You do not have permission to start the Old One's Army.")); return true; } @@ -4207,13 +4207,13 @@ namespace TShockAPI { if (!args.Player.Ban(banReason, "TShock")) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerKillMeV2 kicked with difficulty {0} {1}", args.Player.Name, args.TPlayer.difficulty); - args.Player.Kick("You died! Normally, you'd be banned.", true, true); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerKillMeV2 kicked with difficulty {0} {1}", args.Player.Name, args.TPlayer.difficulty)); + args.Player.Kick(GetString("You died! Normally, you'd be banned."), true, true); } } else if (shouldKick) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerKillMeV2 kicked with difficulty {0} {1}", args.Player.Name, args.TPlayer.difficulty); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerKillMeV2 kicked with difficulty {0} {1}", args.Player.Name, args.TPlayer.difficulty)); args.Player.Kick(kickReason, true, true, null, false); } } @@ -4222,7 +4222,7 @@ 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); + TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandlePlayerKillMeV2 ssc delete {0} {1}", args.Player.Name, args.TPlayer.difficulty)); args.Player.SendErrorMessage(GetString("You have fallen in hardcore mode, and your items have been lost forever.")); TShock.CharacterDB.SeedInitialData(args.Player.Account); } @@ -4368,8 +4368,8 @@ namespace TShockAPI private static bool HandleSyncCavernMonsterType(GetDataHandlerArgs args) { - args.Player.Kick("Exploit attempt detected!"); - TShock.Log.ConsoleDebug($"HandleSyncCavernMonsterType: Player is trying to modify NPC cavernMonsterType; this is a crafted packet! - From {args.Player.Name}"); + args.Player.Kick(GetString("Exploit attempt detected!")); + TShock.Log.ConsoleDebug(GetString($"HandleSyncCavernMonsterType: Player is trying to modify NPC cavernMonsterType; this is a crafted packet! - From {args.Player.Name}")); return true; } diff --git a/TShockAPI/Handlers/SendTileRectHandler.cs b/TShockAPI/Handlers/SendTileRectHandler.cs index 76d7f68a..6c6db510 100644 --- a/TShockAPI/Handlers/SendTileRectHandler.cs +++ b/TShockAPI/Handlers/SendTileRectHandler.cs @@ -426,7 +426,7 @@ namespace TShockAPI.Handlers WallID.Sets.Conversion.NewWall4[tile.wall] && WallID.Sets.Conversion.NewWall4[newTile.Wall] ) { - TShock.Log.ConsoleDebug($"Bouncer / SendTileRect processing a wall conversion update - [{tile.wall}] -> [{newTile.Wall}]"); + TShock.Log.ConsoleDebug(GetString($"Bouncer / SendTileRect processing a wall conversion update - [{tile.wall}] -> [{newTile.Wall}]")); UpdateServerTileState(tile, newTile, TileDataType.Wall); } } diff --git a/TShockAPI/ItemBans.cs b/TShockAPI/ItemBans.cs index c12f5558..df0d36b0 100644 --- a/TShockAPI/ItemBans.cs +++ b/TShockAPI/ItemBans.cs @@ -91,7 +91,7 @@ namespace TShockAPI if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[player.TPlayer.selectedItem].netID), player)) { string itemName = player.TPlayer.inventory[player.TPlayer.selectedItem].Name; - player.Disable($"holding banned item: {itemName}", disableFlags); + player.Disable(GetString($"holding banned item: {itemName}"), disableFlags); SendCorrectiveMessage(player, itemName); } @@ -160,7 +160,7 @@ namespace TShockAPI if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[args.SelectedItem].netID), args.Player)) { player.TPlayer.controlUseItem = false; - player.Disable($"holding banned item: {itemName}", disableFlags); + player.Disable(GetString($"holding banned item: {itemName}"), disableFlags); SendCorrectiveMessage(player, itemName); diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 4f18e780..d7ec7166 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -527,7 +527,7 @@ namespace TShockAPI var descattr = field.GetCustomAttributes(false).FirstOrDefault(o => o is DescriptionAttribute) as DescriptionAttribute; - var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "None"; + var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : GetString("No description available."); var commands = GetCommands(name); foreach (var c in commands) @@ -542,9 +542,9 @@ namespace TShockAPI c => c.Name + (c.Names.Count > 1 ? " ({0})".SFormat(string.Join(" ", c.Names.ToArray(), 1, c.Names.Count - 1)) : "")); - sb.AppendLine("## {0}".SFormat(name)); - sb.AppendLine("{0}".SFormat(desc)); - sb.AppendLine("* **Commands**: `{0}`".SFormat(strs.Count() > 0 ? string.Join(", ", strs) : "None")); + sb.AppendLine($"## {name}"); + sb.AppendLine($"{desc}"); + sb.AppendLine(GetString("* **Commands**: `{0}`", strs.Count() > 0 ? string.Join(", ", strs) : GetString("No associated commands."))); sb.AppendLine(); } diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index 1717c1dc..c41e7767 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -1217,34 +1217,40 @@ namespace TShockAPI var permission = method.GetCustomAttributes(false).Where(o => o is Permission); if (permission.Count() > 0) { - sb.AppendLine("* **Permissions**: `{0}`".SFormat(String.Join(", ", permission.Select(p => ((Permission)p).Name)))); + sb.AppendLine(GetString("* **Permissions**: `{0}`", String.Join(", ", permission.Select(p => ((Permission)p).Name)))); } else { - sb.AppendLine("No special permissions are required for this route."); + sb.AppendLine(GetString("No special permissions are required for this route.")); } sb.AppendLine(); var verbs = method.GetCustomAttributes(false).Where(o => o is Verb); if (verbs.Count() > 0) { - sb.AppendLine("**Verbs**:"); + sb.AppendLine(GetString("**Verbs**:")); foreach (Verb verb in verbs) { - sb.AppendLine("* `{0}` ({1}) `[{2}]` - {3}".SFormat(verb.Name, verb.Required ? "Required" : "Optional", verb.ArgumentType.Name, verb.Description)); + if (verb.Required) + sb.AppendLine(GetString("* `{0}` (Required) `{1}` - {2}".SFormat(verb.Name, verb.ArgumentType.Name, verb.Description))); + else + sb.AppendLine(GetString("* `{0}` (Optional) `{1}` - {2}".SFormat(verb.Name, verb.ArgumentType.Name, verb.Description))); } } sb.AppendLine(); var nouns = method.GetCustomAttributes(false).Where(o => o is Noun); if (nouns.Count() > 0) { - sb.AppendLine("**Nouns**:"); + sb.AppendLine(GetString("**Nouns**:")); foreach (Noun noun in nouns) { - sb.AppendLine("* `{0}` ({1}) `[{2}]` - {3}".SFormat(noun.Name, noun.Required ? "Required" : "Optional", noun.ArgumentType.Name, noun.Description)); + if (noun.Required) + sb.AppendLine(GetString("* `{0}` (Required) `{1}` - {2}".SFormat(noun.Name, noun.ArgumentType.Name, noun.Description))); + else + sb.AppendLine(GetString("* `{0}` (Optional) `{1}` - {2}".SFormat(noun.Name, noun.ArgumentType.Name, noun.Description))); } } sb.AppendLine(); - sb.AppendLine("**Example Usage**: `{0}?{1}`".SFormat(routeattr.Route, + sb.AppendLine(GetString("**Example Usage**: `{0}?{1}`", routeattr.Route, string.Join("&", nouns.Select(n => String.Format("{0}={0}", ((Noun)n).Name))))); sb.AppendLine(); } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 244914b6..553ab9d9 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1921,9 +1921,9 @@ namespace TShockAPI if (!silent) { if (string.IsNullOrWhiteSpace(adminUserName)) - TShock.Utils.Broadcast(GetString("{0} was kicked for '{1}'", Name, reason.ToLower()), Color.Green); + TShock.Utils.Broadcast(GetString("{0} was kicked for '{1}'", Name, reason), Color.Green); else - TShock.Utils.Broadcast(GetString("{0} kicked {1} for '{2}'", adminUserName, Name, reason.ToLower()), Color.Green); + TShock.Utils.Broadcast(GetString("{0} kicked {1} for '{2}'", adminUserName, Name, reason), Color.Green); } return true; } diff --git a/TShockAPI/TSServerPlayer.cs b/TShockAPI/TSServerPlayer.cs index 33f1ffe5..6c95de78 100644 --- a/TShockAPI/TSServerPlayer.cs +++ b/TShockAPI/TSServerPlayer.cs @@ -31,7 +31,7 @@ namespace TShockAPI { public class TSServerPlayer : TSPlayer { - public static string AccountName = "ServerConsole"; + public static string AccountName = GetParticularString("The account name of server console.", "ServerConsole"); public TSServerPlayer() : base("Server") @@ -197,17 +197,17 @@ namespace TShockAPI private readonly Dictionary _consoleColorMap = new Dictionary { - { Color.Red, ConsoleColor.Red }, - { Color.Green, ConsoleColor.Green }, - { Color.Blue, ConsoleColor.Cyan }, - { new Color(255, 250, 170), ConsoleColor.Yellow }, + { Color.Red, ConsoleColor.Red }, + { Color.Green, ConsoleColor.Green }, + { Color.Blue, ConsoleColor.Cyan }, + { new Color(255, 250, 170), ConsoleColor.Yellow }, { new Color(170, 170, 255), ConsoleColor.Cyan }, - { new Color(255, 170, 255), ConsoleColor.Magenta }, - { new Color(170, 255, 170), ConsoleColor.Green }, + { new Color(255, 170, 255), ConsoleColor.Magenta }, + { new Color(170, 255, 170), ConsoleColor.Green }, { new Color(255, 170, 170), ConsoleColor.Red }, - { new Color(139, 0, 0), ConsoleColor.DarkRed }, // This is the console warning color + { new Color(139, 0, 0), ConsoleColor.DarkRed }, // This is the console warning color { Color.PaleVioletRed, ConsoleColor.Magenta }, // This is the command logging color - { Color.White, ConsoleColor.White } + { Color.White, ConsoleColor.White } }; private ConsoleColor PickNearbyConsoleColor(Color color) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 10f2c525..6cbc7d45 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -205,7 +205,7 @@ namespace TShockAPI if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { var osx = Path.Combine(Environment.CurrentDirectory, "runtimes", "osx-x64"); - if(Directory.Exists(osx)) + if (Directory.Exists(osx)) matches = Directory.GetFiles(osx, "*" + libraryName + "*", SearchOption.AllDirectories); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) @@ -247,7 +247,6 @@ namespace TShockAPI public override void Initialize() { string logFilename; - string logPathSetupWarning; OTAPI.Hooks.Netplay.CreateTcpListener += (sender, args) => { @@ -294,10 +293,7 @@ namespace TShockAPI } catch (Exception ex) { - logPathSetupWarning = - "Could not apply the given log path / log format, defaults will be used. Exception details:\n" + ex; - - ServerApi.LogWriter.PluginWriteLine(this, logPathSetupWarning, TraceLevel.Error); + ServerApi.LogWriter.PluginWriteLine(this, GetString("Could not apply the given log path / log format, defaults will be used. Exception details:\n{0}", ex), TraceLevel.Error); // Problem with the log path or format use the default logFilename = Path.Combine(LogPathDefault, now.ToString(LogFormatDefault) + ".log"); @@ -353,8 +349,8 @@ namespace TShockAPI if (File.Exists(Path.Combine(SavePath, "tshock.pid"))) { - Log.ConsoleInfo( - "TShock was improperly shut down. Please use the exit command in the future to prevent this."); + Log.ConsoleInfo(GetString( + "TShock was improperly shut down. Please use the exit command in the future to prevent this.")); File.Delete(Path.Combine(SavePath, "tshock.pid")); } File.WriteAllText(Path.Combine(SavePath, "tshock.pid"), @@ -387,7 +383,7 @@ namespace TShockAPI if (Config.Settings.EnableGeoIP && File.Exists(geoippath)) Geo = new GeoIPCountry(geoippath); - Log.ConsoleInfo("TShock {0} ({1}) now running.", Version, VersionCodename); + Log.ConsoleInfo(GetString("TShock {0} ({1}) now running.", Version, VersionCodename)); ServerApi.Hooks.GamePostInitialize.Register(this, OnPostInit); ServerApi.Hooks.GameUpdate.Register(this, OnUpdate); @@ -425,14 +421,20 @@ namespace TShockAPI if (Config.Settings.RestApiEnabled) RestApi.Start(); - Log.ConsoleInfo("AutoSave " + (Config.Settings.AutoSave ? "Enabled" : "Disabled")); - Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled")); + if (Config.Settings.AutoSave) + Log.ConsoleInfo(GetString("AutoSave Enabled")); + else + Log.ConsoleInfo(GetString("AutoSave Disabled")); + if (Backups.Interval > 0) + Log.ConsoleInfo(GetString("Backups Enabled")); + else + Log.ConsoleInfo(GetString("Backups Disabled")); Initialized?.Invoke(); - Log.ConsoleInfo("Welcome to TShock for Terraria!"); - Log.ConsoleInfo("TShock comes with no warranty & is free software."); - Log.ConsoleInfo("You can modify & distribute it under the terms of the GNU GPLv3."); + Log.ConsoleInfo(GetString("Welcome to TShock for Terraria!")); + Log.ConsoleInfo(GetString("TShock comes with no warranty & is free software.")); + Log.ConsoleInfo(GetString("You can modify & distribute it under the terms of the GNU GPLv3.")); } catch (Exception ex) @@ -440,7 +442,7 @@ namespace TShockAPI // handle if Log was not initialised void SafeError(string message) { - if(Log is not null) Log.ConsoleError(message); + if (Log is not null) Log.ConsoleError(message); else Console.WriteLine(message); }; SafeError(GetString("TShock encountered a problem from which it cannot recover. The following message may help diagnose the problem.")); @@ -581,7 +583,7 @@ namespace TShockAPI { if (player.IP == ip) { - player.Kick("You logged in from the same IP.", true, true, null, true); + player.Kick(GetString("You logged in from the same IP."), true, true, null, true); args.Handled = true; return; } @@ -590,7 +592,7 @@ namespace TShockAPI var ips = JsonConvert.DeserializeObject>(player.Account.KnownIps); if (ips.Contains(ip)) { - player.Kick("You logged in from another location.", true, true, null, true); + player.Kick(GetString("You logged in from another location."), true, true, null, true); args.Handled = true; } } @@ -717,10 +719,10 @@ namespace TShockAPI tryingToShutdown = true; - Log.ConsoleInfo("Shutting down safely. To force shutdown, send SIGINT (CTRL + C) again."); + Log.ConsoleInfo(GetString("Shutting down safely. To force shutdown, send SIGINT (CTRL + C) again.")); // Perform a safe shutdown - TShock.Utils.StopServer(true, "Server console interrupted!"); + TShock.Utils.StopServer(true, GetString("Server console interrupted!")); } /// HandleCommandLine - Handles the command line parameters passed to the server. @@ -747,7 +749,7 @@ namespace TShockAPI SavePath = path ?? "tshock"; if (path != null) { - ServerApi.LogWriter.PluginWriteLine(this, "Config path has been set to " + path, TraceLevel.Info); + ServerApi.LogWriter.PluginWriteLine(this, GetString("Config path has been set to {0}", path), TraceLevel.Info); } }) @@ -757,7 +759,7 @@ namespace TShockAPI if (path != null) { Main.WorldPath = path; - ServerApi.LogWriter.PluginWriteLine(this, "World path has been set to " + path, TraceLevel.Info); + ServerApi.LogWriter.PluginWriteLine(this, GetString("World path has been set to {0}", path), TraceLevel.Info); } }) @@ -767,7 +769,7 @@ namespace TShockAPI if (path != null) { LogPath = path; - ServerApi.LogWriter.PluginWriteLine(this, "Log path has been set to " + path, TraceLevel.Info); + ServerApi.LogWriter.PluginWriteLine(this, GetString("Log path has been set to {0}", path), TraceLevel.Info); } }) @@ -877,13 +879,13 @@ namespace TShockAPI Netplay.ListenPort = port; Config.Settings.ServerPort = port; OverridePort = true; - Log.ConsoleInfo("Port overridden by startup argument. Set to " + port); + Log.ConsoleInfo(GetString("Port overridden by startup argument. Set to {0}", port)); } }) .AddFlags(restTokenSet, (token) => { RESTStartupTokens.Add(token, new SecureRest.TokenData { Username = "null", UserGroupName = "superadmin" }); - Console.WriteLine("Startup parameter overrode REST token."); + Console.WriteLine(GetString("Startup parameter overrode REST token.")); }) .AddFlags(restEnableSet, (e) => { @@ -891,7 +893,7 @@ namespace TShockAPI if (bool.TryParse(e, out enabled)) { Config.Settings.RestApiEnabled = enabled; - Console.WriteLine("Startup parameter overrode REST enable."); + Console.WriteLine(GetString("Startup parameter overrode REST enable.")); } }) .AddFlags(restPortSet, (p) => @@ -900,7 +902,7 @@ namespace TShockAPI if (int.TryParse(p, out restPort)) { Config.Settings.RestApiPort = restPort; - Console.WriteLine("Startup parameter overrode REST port."); + Console.WriteLine(GetString("Startup parameter overrode REST port.")); } }) .AddFlags(playerSet, (p) => @@ -909,7 +911,7 @@ namespace TShockAPI if (int.TryParse(p, out slots)) { Config.Settings.MaxSlots = slots; - Console.WriteLine("Startup parameter overrode maximum player slot configuration value."); + Console.WriteLine(GetString("Startup parameter overrode maximum player slot configuration value.")); } }); @@ -933,19 +935,19 @@ namespace TShockAPI //CLI defined password overrides a config password if (!string.IsNullOrEmpty(Config.Settings.ServerPassword)) { - Log.ConsoleError("!!! The server password in config.json was overridden by the interactive prompt and will be ignored."); + Log.ConsoleError(GetString("!!! The server password in config.json was overridden by the interactive prompt and will be ignored.")); } if (!Config.Settings.DisableUUIDLogin) { - Log.ConsoleError("!!! UUID login is enabled. If a user's UUID matches an account, the server password will be bypassed."); - Log.ConsoleError("!!! > Set DisableUUIDLogin to true in the config file and /reload if this is a problem."); + Log.ConsoleError(GetString("!!! UUID login is enabled. If a user's UUID matches an account, the server password will be bypassed.")); + Log.ConsoleError(GetString("!!! > Set DisableUUIDLogin to true in the config file and /reload if this is a problem.")); } if (!Config.Settings.DisableLoginBeforeJoin) { - Log.ConsoleError("!!! Login before join is enabled. Existing accounts can login & the server password will be bypassed."); - Log.ConsoleError("!!! > Set DisableLoginBeforeJoin to true in the config file and /reload if this is a problem."); + Log.ConsoleError(GetString("!!! Login before join is enabled. Existing accounts can login & the server password will be bypassed.")); + Log.ConsoleError(GetString("!!! > Set DisableLoginBeforeJoin to true in the config file and /reload if this is a problem.")); } _cliPassword = Netplay.ServerPassword; @@ -956,19 +958,19 @@ namespace TShockAPI { if (!string.IsNullOrEmpty(Config.Settings.ServerPassword)) { - Log.ConsoleInfo("A password for this server was set in config.json and is being used."); + Log.ConsoleInfo(GetString("A password for this server was set in config.json and is being used.")); } } if (!Config.Settings.DisableLoginBeforeJoin) { - Log.ConsoleInfo("Login before join enabled. Users may be prompted for an account specific password instead of a server password on connect."); + Log.ConsoleInfo(GetString("Login before join enabled. Users may be prompted for an account specific password instead of a server password on connect.")); } if (!Config.Settings.DisableUUIDLogin) { - Log.ConsoleInfo("Login using UUID enabled. Users automatically login via UUID."); - Log.ConsoleInfo("A malicious server can easily steal a user's UUID. You may consider turning this option off if you run a public server."); + Log.ConsoleInfo(GetString("Login using UUID enabled. Users automatically login via UUID.")); + Log.ConsoleInfo(GetString("A malicious server can easily steal a user's UUID. You may consider turning this option off if you run a public server.")); } // Disable the auth system if "setup.lock" is present or a user account already exists @@ -1090,7 +1092,7 @@ namespace TShockAPI { if (player.TileKillThreshold >= Config.Settings.TileKillThreshold) { - player.Disable("Reached TileKill threshold.", flags); + player.Disable(GetString("Reached TileKill threshold."), flags); TSPlayer.Server.RevertTiles(player.TilesDestroyed); player.TilesDestroyed.Clear(); } @@ -1107,7 +1109,7 @@ namespace TShockAPI { if (player.TilePlaceThreshold >= Config.Settings.TilePlaceThreshold) { - player.Disable("Reached TilePlace threshold", flags); + player.Disable(GetString("Reached TilePlace threshold"), flags); lock (player.TilesCreated) { TSPlayer.Server.RevertTiles(player.TilesCreated); @@ -1151,7 +1153,7 @@ namespace TShockAPI if (player.TileLiquidThreshold >= Config.Settings.TileLiquidThreshold) { - player.Disable("Reached TileLiquid threshold", flags); + player.Disable(GetString("Reached TileLiquid threshold"), flags); } if (player.TileLiquidThreshold > 0) { @@ -1160,7 +1162,7 @@ namespace TShockAPI if (player.ProjectileThreshold >= Config.Settings.ProjectileThreshold) { - player.Disable("Reached projectile threshold", flags); + player.Disable(GetString("Reached projectile threshold"), flags); } if (player.ProjectileThreshold > 0) { @@ -1169,7 +1171,7 @@ namespace TShockAPI if (player.PaintThreshold >= Config.Settings.TilePaintThreshold) { - player.Disable("Reached paint threshold", flags); + player.Disable(GetString("Reached paint threshold"), flags); } if (player.PaintThreshold > 0) { @@ -1178,7 +1180,7 @@ namespace TShockAPI if (player.HealOtherThreshold >= TShock.Config.Settings.HealOtherThreshold) { - player.Disable("Reached HealOtherPlayer threshold", flags); + player.Disable(GetString("Reached HealOtherPlayer threshold"), flags); } if (player.HealOtherThreshold > 0) { @@ -1282,7 +1284,7 @@ namespace TShockAPI { if (ShuttingDown) { - NetMessage.SendData((int)PacketTypes.Disconnect, args.Who, -1, NetworkText.FromLiteral("Server is shutting down...")); + NetMessage.SendData((int)PacketTypes.Disconnect, args.Who, -1, NetworkText.FromLiteral(GetString("Server is shutting down..."))); args.Handled = true; return; } @@ -1311,7 +1313,7 @@ namespace TShockAPI { if (Config.Settings.KickProxyUsers) { - player.Kick("Connecting via a proxy is not allowed.", true, true, null, false); + player.Kick(GetString("Connecting via a proxy is not allowed."), true, true, null, false); args.Handled = true; return; } @@ -1333,7 +1335,7 @@ namespace TShockAPI if (Config.Settings.KickEmptyUUID && String.IsNullOrWhiteSpace(player.UUID)) { - player.Kick("Your client sent a blank UUID. Configure it to send one or use a different client.", true, true, null, false); + player.Kick(GetString("Your client sent a blank UUID. Configure it to send one or use a different client."), true, true, null, false); args.Handled = true; return; } @@ -1379,8 +1381,8 @@ namespace TShockAPI if (tsplr.ReceivedInfo) { if (!tsplr.SilentKickInProgress && tsplr.State >= 3) - Utils.Broadcast(tsplr.Name + " has left.", Color.Yellow); - Log.Info("{0} disconnected.", tsplr.Name); + Utils.Broadcast(GetString("{0} has left.", tsplr.Name), Color.Yellow); + Log.Info(GetString("{0} disconnected."), tsplr.Name); if (tsplr.IsLoggedIn && !tsplr.IsDisabledPendingTrashRemoval && Main.ServerSideCharacter && (!tsplr.Dead || tsplr.TPlayer.difficulty != 2)) { @@ -1430,7 +1432,7 @@ namespace TShockAPI if (args.Text.Length > 500) { - tsplr.Kick("Crash attempt via long chat packet.", true); + tsplr.Kick(GetString("Crash attempt via long chat packet."), true); args.Handled = true; return; } @@ -1466,12 +1468,12 @@ namespace TShockAPI { // This is required in case anyone makes HandleCommand return false again 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(GetString("Unable to parse command '{0}' from player {1}."), text, tsplr.Name); } } catch (Exception ex) { - Log.ConsoleError("An exception occurred executing a command."); + Log.ConsoleError(GetString("An exception occurred executing a command.")); Log.Error(ex.ToString()); } } @@ -1569,7 +1571,10 @@ namespace TShockAPI if (args.Command == "autosave") { Main.autoSave = Config.Settings.AutoSave = !Config.Settings.AutoSave; - Log.ConsoleInfo("AutoSave " + (Config.Settings.AutoSave ? "Enabled" : "Disabled")); + if (Config.Settings.AutoSave) + Log.ConsoleInfo(GetString("AutoSave Enabled")); + else + Log.ConsoleInfo(GetString("AutoSave Disabled")); } else if (args.Command.StartsWith(Commands.Specifier) || args.Command.StartsWith(Commands.SilentSpecifier)) { diff --git a/TShockAPI/UpdateManager.cs b/TShockAPI/UpdateManager.cs index 8cb277f9..b01d92a2 100644 --- a/TShockAPI/UpdateManager.cs +++ b/TShockAPI/UpdateManager.cs @@ -80,11 +80,11 @@ namespace TShockAPI string msg = ex.BuildExceptionString(); //Give the console a brief Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine($"UpdateManager warning: {msg}"); + Console.WriteLine(GetString($"UpdateManager warning: {msg}")); Console.ForegroundColor = ConsoleColor.Gray; //And log the full exception - TShock.Log.Warn($"UpdateManager warning: {ex.ToString()}"); - TShock.Log.ConsoleError("Retrying in 5 minutes."); + TShock.Log.Warn(GetString($"UpdateManager warning: {ex.ToString()}")); + TShock.Log.ConsoleError(GetString("Retrying in 5 minutes.")); CheckXMinutes = 5; } } @@ -117,8 +117,7 @@ namespace TShockAPI { reason = "none"; } - throw new WebException("Update server did not respond with an OK. " - + $"Server message: [error {resp.StatusCode}] {reason}"); + throw new WebException(GetString($"Update server did not respond with an OK. Server message: [error {resp.StatusCode}] {reason}")); } string json = await resp.Content.ReadAsStringAsync();